File indexing completed on 2024-11-10 12:49:03

0001 /*
0002     SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef OPERATION_H
0008 #define OPERATION_H
0009 
0010 #include <pulse/operation.h>
0011 
0012 namespace PulseAudioQt
0013 {
0014 /**
0015  * @brief The PAOperation class
0016  * Helps with management of pa_operations. pa_operations need to be expicitly
0017  * unref'd after use, so this class is essentially a fancy scoping helper where
0018  * destruction of an instance would also unref the held operation (if there is
0019  * one).
0020  */
0021 class PAOperation
0022 {
0023 public:
0024     /**
0025      * @brief PAOperation
0026      * @param operation operation to manage the scope of
0027      */
0028     explicit PAOperation(pa_operation *operation = nullptr);
0029     ~PAOperation();
0030 
0031     PAOperation &operator=(pa_operation *operation);
0032 
0033     /**
0034      * @brief operator !
0035      * @return whether or not there is an operation pointer
0036      */
0037     bool operator!();
0038 
0039     /**
0040      * @brief operator bool representing whether there is an operation
0041      */
0042     operator bool();
0043 
0044     /**
0045      * @brief operator *
0046      * @return pointer to internal pa_operation object
0047      */
0048     pa_operation *&operator*();
0049 
0050 private:
0051     pa_operation *m_operation;
0052 };
0053 
0054 } // PulseAudioQt
0055 
0056 #endif // OPERATION_H