/[svn]/linuxsampler/trunk/src/plugins/InstrumentEditorFactory.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/plugins/InstrumentEditorFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1480 by senoner, Tue Nov 13 19:19:18 2007 UTC revision 1481 by senoner, Wed Nov 14 23:42:15 2007 UTC
# Line 35  Line 35 
35  # error "Configuration macro CONFIG_PLUGIN_DIR not defined!"  # error "Configuration macro CONFIG_PLUGIN_DIR not defined!"
36  #endif // CONFIG_PLUGIN_DIR  #endif // CONFIG_PLUGIN_DIR
37    
38    #if defined(WIN32)
39    typedef void* (*InnerFactoryRegisterFunction)(void);
40    #endif
41    
42  namespace LinuxSampler {  namespace LinuxSampler {
43    
44      std::map<String, InstrumentEditorFactory::InnerFactory*> InstrumentEditorFactory::InnerFactories;      std::map<String, InstrumentEditorFactory::InnerFactory*> InstrumentEditorFactory::InnerFactories;
# Line 118  namespace LinuxSampler { Line 122  namespace LinuxSampler {
122                  if(!(win32FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {                  if(!(win32FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
123                      String sPath = (String)CONFIG_PLUGIN_DIR + ((String)"\\" + (String)win32FindData.cFileName);                      String sPath = (String)CONFIG_PLUGIN_DIR + ((String)"\\" + (String)win32FindData.cFileName);
124                      // load the DLL (the plugins should register themselfes automatically)                      // load the DLL (the plugins should register themselfes automatically)
125                      void* pDLL = myhinstance = LoadLibrary( sPath.c_str() );                      HINSTANCE hinstLib;
126                      if (pDLL) LoadedDLLs.push_back(pDLL);                      void* pDLL = hinstLib = LoadLibrary( sPath.c_str() );
127                      else {                      if (!pDLL) {
128                          std::cerr << "Failed to load instrument editor plugin: "                          std::cerr << "Failed to load instrument editor plugin: "
129                                    << sPath << std::endl;                                    << sPath << std::endl;
130                            continue;
131                        }
132                        
133                        //(InnerFactory*) (*fn)(void);
134                        InnerFactoryRegisterFunction fn;
135                        fn = (InnerFactoryRegisterFunction)
136                            GetProcAddress(
137                                hinstLib,
138                                "createInstrumentEditorInnerFactory"
139                            );
140                        if (fn == NULL) {
141                            std::cerr << "ERROR: unable to find "
142                                         "createInstrumentEditorInnerFactory() "
143                                         "in DLL\n" << std::flush;
144                            FreeLibrary(hinstLib);
145                            continue;
146                        }
147                        
148                        // get the plugin instance and register it to the factory
149                        
150                        InnerFactory* pInnerFactory = (InnerFactory*)fn();
151                        if (!pInnerFactory) {
152                            std::cerr << "ERROR: !pInnerFactory\n" << std::flush;
153                            FreeLibrary(hinstLib);
154                            continue;
155                        }
156                        InstrumentEditor* pEditor = pInnerFactory->Create();
157                        if (InnerFactories.count(pEditor->Name())) {
158                            std::cerr << "ERROR: a plugin with name '"
159                                      << pEditor->Name()
160                                      << "' already loaded (skipping)\n"
161                                      << std::flush;
162                            pInnerFactory->Destroy(pEditor);
163                            FreeLibrary(hinstLib);
164                            continue;
165                      }                      }
166                        InnerFactories[pEditor->Name()] = pInnerFactory;
167                        pInnerFactory->Destroy(pEditor);
168                        
169                        LoadedDLLs.push_back(pDLL);
170                  }                  }
171                  int res = FindNextFile(hDir, &win32FindData);                  int res = FindNextFile(hDir, &win32FindData);
172                  if(res == 0 && GetLastError() != ERROR_NO_MORE_FILES) {                  if(res == 0 && GetLastError() != ERROR_NO_MORE_FILES) {

Legend:
Removed from v.1480  
changed lines
  Added in v.1481

  ViewVC Help
Powered by ViewVC