cAudio  2.3.0
3d Audio Engine
cPluginManager.h
1 // Copyright (c) 2008-2011 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones, Murat (wolfmanfx) Sari
2 // This file is part of the "cAudio Engine"
3 // For conditions of distribution and use, see copyright notice in cAudio.h
4 
5 #pragma once
6 
7 #include "cMutex.h"
8 #include "IPluginManager.h"
9 #include "IAudioPlugin.h"
10 #include "cSTLAllocator.h"
11 #include "cAudioString.h"
12 
13 #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
14 
15 #ifdef CAUDIO_PLATFORM_WIN
16 
17 struct HINSTANCE__;
18 typedef struct HINSTANCE__* hInstance;
19 
20 # define DYNLIB_HANDLE hInstance
21 # define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
22 # define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
23 # define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
24 #elif defined(CAUDIO_PLATFORM_MAC) || defined(CAUDIO_PLATFORM_LINUX)
25 # include <dlfcn.h>
26 # define DYNLIB_HANDLE void*
27 # define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
28 # define DYNLIB_GETSYM( a, b ) dlsym( a, b )
29 # define DYNLIB_UNLOAD( a ) dlclose( a )
30 #endif
31 
32 namespace cAudio
33 {
34  class cPluginManager : public IPluginManager
35  {
36  public:
37  cPluginManager();
38  ~cPluginManager();
39 
40  static cPluginManager* Instance()
41  {
42  static cPluginManager theInstance;
43  return &theInstance;
44  }
45 
46  virtual bool installPlugin(IAudioPlugin* plugin, const char* name);
47  virtual bool installPlugin(const char* filename, const char* name);
48 
49  virtual bool checkForPlugin(const char* name);
50  virtual IAudioPlugin* getPlugin(const char* name);
51  virtual unsigned int getPluginCount();
52  cAudioVector<IAudioPlugin*>::Type getPluginList();
53 
54  virtual void uninstallPlugin(IAudioPlugin* plugin);
55  virtual void uninstallPlugin(const char* name);
56 
57  void autoLoadPlugins();
58  protected:
59  cAudioString getError();
60 
61  cAudioMap<cAudioString, IAudioPlugin*>::Type RegisteredPlugins;
62  typedef cAudioMap<cAudioString, IAudioPlugin*>::Type::iterator RegisteredPluginsIterator;
63  cAudioMap<IAudioPlugin*, DYNLIB_HANDLE>::Type DynamicallyLoadedPlugins;
64  typedef cAudioMap<IAudioPlugin*, DYNLIB_HANDLE>::Type::iterator DynamicallyLoadedPluginsIterator;
65  };
66 };
67 
68 #endif //! CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
cAudio
Main namespace for the entire cAudio library.
Definition: cAudioCapture.h:16