My Project
CadImporterFactory.h
1 
2 
3 #pragma once
4 
5 #include "PluginManager.h"
6 #include "PluginAPI.h"
7 
8 namespace ParaEngine
9 {
10 #ifdef _DEBUG
11  const char* OCCPlugin_DLL_FILE_PATH = "OCCPlugin_d.dll";
12 #else
13  const char* OCCPlugin_DLL_FILE_PATH = "OCCPlugin.dll";
14 #endif
15 
17  {
18  static ICadModelImporter* g_pImproter;
19 
20  public:
21 
22  static ICadModelImporter* GetImporter()
23  {
24  if(g_pImproter)
25  return g_pImproter;
26 
27  DLLPlugInEntity* pPluginEntity = CGlobals::GetPluginManager()->GetPluginEntity(OCCPlugin_DLL_FILE_PATH);
28  if(pPluginEntity == 0)
29  {
30  pPluginEntity = ParaEngine::CGlobals::GetPluginManager()->LoadDLL("", OCCPlugin_DLL_FILE_PATH);
31  }
32 
33  if(pPluginEntity != 0)
34  {
35  for (int i=0; i < pPluginEntity->GetNumberOfClasses(); ++i)
36  {
37  ClassDescriptor* pClassDesc = pPluginEntity->GetClassDescriptor(i);
38 
39  if(pClassDesc && (strcmp(pClassDesc->ClassName(), "ICadModelImporter") == 0))
40  {
41  g_pImproter = (ICadModelImporter*) pClassDesc->Create();
42  }
43  }
44  }
45  return g_pImproter;
46  }
47  };
48 
49  ICadModelImporter* CadImporterFactory::g_pImproter = NULL;
50 
51 }
int GetNumberOfClasses()
return the number of plugin classes inside the DLL
Definition: PluginManager.cpp:149
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: CadImporterFactory.h:16
Definition: ICadModelImporter.h:50
virtual void * Create(bool loading=false)=0
return a pointer to an instance of the class.When the system needs to delete an instance of a plugin ...
DLLPlugInEntity * LoadDLL(const string &sIdentifier, const string &fileName)
Load a DLL at the given path [thread safe].
Definition: PluginManager.cpp:48
virtual const char * ClassName()=0
class name
a DLL plug-in loaded explicitly at runtime.
Definition: PluginManager.h:39
ClassDescriptor * GetClassDescriptor(int i)
The plugin must provide the system with a way to retrieve the Class Descriptors defined by the plugin...
Definition: PluginManager.cpp:136
System keeps a list of the DLL&#39;s found on startup.
Definition: PluginAPI.h:61