1 /*
2     Drumstick RT (realtime MIDI In/Out)
3     Copyright (C) 2009-2021 Pedro Lopez-Cabanillas <plcl@users.sf.net>
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 3 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef BACKENDMANAGER_H
20 #define BACKENDMANAGER_H
21 
22 #include <QObject>
23 #include <QScopedPointer>
24 #include "macros.h"
25 #include "rtmidiinput.h"
26 #include "rtmidioutput.h"
27 
28 /**
29  * @file backendmanager.h
30  * BackendManager class declaration
31  */
32 
33 namespace drumstick {
34 /**
35  * @ingroup RT
36  * @brief Drumstick Real-Time library
37  */
38 namespace rt {
39 
40     /**
41      * @addtogroup RT Realtime MIDI (I/O)
42      * @{
43      */
44 
45     /**
46      * @brief The BackendManager class manages lists of dynamic and static
47      * backends for applications based on drumstick-rt
48      */
49     class DRUMSTICK_EXPORT BackendManager
50     {
51     public:
52         /**
53          * @brief BackendManager constructor
54          */
55         explicit BackendManager();
56 
57         /**
58          * @brief ~BackendManager destructor
59          */
60         virtual ~BackendManager();
61 
62         /**
63          * @brief refresh the list of backends
64          * @param settings Program settings
65          */
66         void refresh(QSettings* settings = nullptr);
67 
68         /**
69          * @brief refresh the list of backends
70          * @param map Program settings relevant section
71          */
72         void refresh(const QVariantMap& map);
73 
74         /**
75          * @brief availableInputs
76          * @return list of available MIDI inputs
77          */
78         QList<MIDIInput*> availableInputs();
79 
80         /**
81          * @brief availableOutputs
82          * @return list of available MIDI outputs
83          */
84         QList<MIDIOutput*> availableOutputs();
85 
86         /**
87          * @brief defaultPaths
88          * @return list of paths for backends search
89          */
90         QStringList defaultPaths();
91 
92         /**
93          * @brief inputBackendByName
94          * @param name The name of some input backend
95          * @return Input backend instance if available
96          */
97         MIDIInput* inputBackendByName(const QString name);
98 
99         /**
100          * @brief outputBackendByName
101          * @param name The name of some output backend
102          * @return Output backend instance if available
103          */
104         MIDIOutput* outputBackendByName(const QString name);
105 
106         /**
107          * @brief findInput returns the backend corresponding
108          * to the provided name, or a suitable input instead.
109          * @param name The name of some input backend
110          * @return Input backend instance if available
111          */
112         MIDIInput* findInput(QString name);
113 
114         /**
115          * @brief findOutput returns the backend corresponding
116          * to the provided name, or a suitable output instead.
117          * @param name The name of some output backend
118          * @return Output backend instance if available
119          */
120         MIDIOutput* findOutput(QString name);
121 
122         static const QString QSTR_DRUMSTICK;
123         static const QString QSTR_DRUMSTICK_VERSION;
124         static const QString QSTR_DRUMSTICKRT;
125         static const QString QSTR_DRUMSTICKRT_GROUP;
126         static const QString QSTR_DRUMSTICKRT_PUBLICNAMEIN;
127         static const QString QSTR_DRUMSTICKRT_PUBLICNAMEOUT;
128         static const QString QSTR_DRUMSTICKRT_EXCLUDED;
129         static const QString QSTR_DRUMSTICKRT_PATH;
130 
131     private:
132         class BackendManagerPrivate;
133         QScopedPointer<BackendManagerPrivate> d;
134     };
135 
136     QString DRUMSTICK_EXPORT drumstickLibraryVersion();
137 
138 /** @} */
139 
140 }} // namespace drumstick::rt
141 
142 #endif // BACKENDMANAGER_H
143