Cleanup
[jack2.git] / common / JackGlobals.h
blob44fb171c404ab35890092ee26fabdc6b59bcf611
1 /*
2 Copyright (C) 2004-2006 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __JackGlobals__
21 #define __JackGlobals__
23 #include "JackError.h"
25 namespace Jack
28 class JackSynchro;
29 class JackServerNotifyChannelInterface;
30 class JackClientChannelInterface;
31 class JackNotifyChannelInterface;
32 class JackServerChannelInterface;
33 class JackSyncInterface;
34 class JackThread;
35 class JackDriverClientInterface;
36 class JackRunnableInterface;
37 class JackEngine;
39 /*!
40 \brief Factory description
42 \totdo possibly use in a dynamic way to test different communication/synchro implementations.
45 class JackFactoryImpl
47 public:
49 JackFactoryImpl()
51 virtual ~JackFactoryImpl()
54 virtual JackSynchro* MakeSynchro() = 0;
55 virtual JackServerNotifyChannelInterface* MakeServerNotifyChannel() = 0;
56 virtual JackClientChannelInterface* MakeClientChannel() = 0;
57 virtual JackNotifyChannelInterface* MakeNotifyChannel() = 0;
58 virtual JackServerChannelInterface* MakeServerChannel() = 0;
59 virtual JackSyncInterface* MakeInterProcessSync() = 0;
60 virtual JackThread* MakeThread(JackRunnableInterface* runnable) = 0;
63 #ifdef __linux__
65 class JackFactoryLinuxServer : public JackFactoryImpl
67 public:
69 JackFactoryLinuxServer()
71 virtual ~JackFactoryLinuxServer()
74 JackSynchro* MakeSynchro();
75 JackServerNotifyChannelInterface* MakeServerNotifyChannel();
76 JackClientChannelInterface* MakeClientChannel();
77 JackNotifyChannelInterface* MakeNotifyChannel();
78 JackServerChannelInterface* MakeServerChannel();
79 JackSyncInterface* MakeInterProcessSync();
80 JackThread* MakeThread(JackRunnableInterface* runnable);
83 class JackFactoryLinuxClient : public JackFactoryImpl
85 public:
87 JackFactoryLinuxClient()
89 virtual ~JackFactoryLinuxClient()
92 JackSynchro* MakeSynchro();
93 JackServerNotifyChannelInterface* MakeServerNotifyChannel();
94 JackClientChannelInterface* MakeClientChannel();
95 JackNotifyChannelInterface* MakeNotifyChannel();
96 JackServerChannelInterface* MakeServerChannel();
97 JackSyncInterface* MakeInterProcessSync();
98 JackThread* MakeThread(JackRunnableInterface* runnable);
101 #endif
103 #ifdef WIN32
105 class JackFactoryWindowsServer : public JackFactoryImpl
107 public:
109 JackFactoryWindowsServer()
111 virtual ~JackFactoryWindowsServer()
114 JackSynchro* MakeSynchro();
115 JackServerNotifyChannelInterface* MakeServerNotifyChannel();
116 JackClientChannelInterface* MakeClientChannel();
117 JackNotifyChannelInterface* MakeNotifyChannel();
118 JackServerChannelInterface* MakeServerChannel();
119 JackSyncInterface* MakeInterProcessSync();
120 JackThread* MakeThread(JackRunnableInterface* runnable);
123 class JackFactoryWindowsClient : public JackFactoryImpl
125 public:
127 JackFactoryWindowsClient()
129 virtual ~JackFactoryWindowsClient()
132 JackSynchro* MakeSynchro();
133 JackServerNotifyChannelInterface* MakeServerNotifyChannel();
134 JackClientChannelInterface* MakeClientChannel();
135 JackNotifyChannelInterface* MakeNotifyChannel();
136 JackServerChannelInterface* MakeServerChannel();
137 JackSyncInterface* MakeInterProcessSync();
138 JackThread* MakeThread(JackRunnableInterface* runnable);
141 #endif
143 #if defined(__APPLE__)
145 class JackFactoryOSXServer : public JackFactoryImpl
147 public:
149 JackFactoryOSXServer()
151 virtual ~JackFactoryOSXServer()
154 JackSynchro* MakeSynchro();
155 JackServerNotifyChannelInterface* MakeServerNotifyChannel();
156 JackClientChannelInterface* MakeClientChannel();
157 JackNotifyChannelInterface* MakeNotifyChannel();
158 JackServerChannelInterface* MakeServerChannel();
159 JackSyncInterface* MakeInterProcessSync();
160 JackThread* MakeThread(JackRunnableInterface* runnable);
163 class JackFactoryOSXClient : public JackFactoryImpl
165 public:
167 JackFactoryOSXClient()
169 virtual ~JackFactoryOSXClient()
172 JackSynchro* MakeSynchro();
173 JackServerNotifyChannelInterface* MakeServerNotifyChannel();
174 JackClientChannelInterface* MakeClientChannel();
175 JackNotifyChannelInterface* MakeNotifyChannel();
176 JackServerChannelInterface* MakeServerChannel();
177 JackSyncInterface* MakeInterProcessSync();
178 JackThread* MakeThread(JackRunnableInterface* runnable);
181 #endif
184 \brief Factory for OS specific ressources.
187 class JackGlobals
189 private:
191 static JackFactoryImpl* fInstance;
193 public:
195 JackGlobals()
197 virtual ~JackGlobals()
200 static JackSynchro* MakeSynchro()
202 return fInstance->MakeSynchro();
204 static JackServerNotifyChannelInterface* MakeServerNotifyChannel()
206 return fInstance->MakeServerNotifyChannel();
208 static JackClientChannelInterface* MakeClientChannel()
210 return fInstance->MakeClientChannel();
212 static JackNotifyChannelInterface* MakeNotifyChannel()
214 return fInstance->MakeNotifyChannel();
216 static JackServerChannelInterface* MakeServerChannel()
218 return fInstance->MakeServerChannel();
220 static JackSyncInterface* MakeInterProcessSync()
222 return fInstance->MakeInterProcessSync();
224 static JackThread* MakeThread(JackRunnableInterface* runnable)
226 return fInstance->MakeThread(runnable);
229 static void InitServer()
231 JackLog("JackGlobals InitServer\n");
232 if (!fInstance) {
234 #ifdef __APPLE__
235 fInstance = new JackFactoryOSXServer();
236 #endif
238 #ifdef WIN32
239 fInstance = new JackFactoryWindowsServer();
240 #endif
242 #ifdef __linux__
243 fInstance = new JackFactoryLinuxServer();
244 #endif
249 static void InitClient()
251 JackLog("JackGlobals InitClient\n");
252 if (!fInstance) {
254 #ifdef __APPLE__
255 fInstance = new JackFactoryOSXClient();
256 #endif
258 #ifdef WIN32
259 fInstance = new JackFactoryWindowsClient();
260 #endif
262 #ifdef __linux__
263 fInstance = new JackFactoryLinuxClient();
264 #endif
269 static void Destroy()
271 JackLog("JackGlobals Destroy\n");
272 if (fInstance) {
273 delete fInstance;
274 fInstance = NULL;
280 } // end of namespace
282 #endif