My Project
PluginAPI.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2004 - 2006 ParaEngine Dev Studio, All Rights Reserved.
3 // Date: 2006.8
4 // Description: API for plug in.
5 //-----------------------------------------------------------------------------
6 #pragma once
7 #include "coreexport.h"
8 #include "PEtypes.h"
9 #include "IParaEngineCore.h"
10 
11 namespace ParaEngine
12 {
13  class IParaEngineCore;
14 }
15 
16 namespace ParaEngine
17 {
19 #ifndef PE_MODULE_STANDALONE
20 
21  PE_CORE_DECL DWORD GetParaEngineVersion();
22 
25 #endif
26 
27  //-------------------------------------------
28  // Super-classes that are plugable.
30  #define BASE_OBJECT_CLASS_ID 0x00000001
31 
32  #define OBJECT_MODIFIER_CLASS_ID 0x00000002
33 
34  #define NPL_FILE_CLASS_ID 0x00000003
35 
36  #define GUI_OBJECT_CLASS_ID 0x00000004
37 
38  #define GAME_OBJECT_CLASS_ID 0x00000005
39 
40  #define EXTENSION_CLASS_ID 0x00000006
41 
62  {
63  public:
64  virtual ~ClassDescriptor() {}
70  virtual void * Create(bool loading=false)=0;
71 
75  virtual const char* ClassName()=0;
79  virtual SClass_ID SuperClassID()=0;
83  virtual Class_ID ClassID()=0;
87  virtual const char* Category()=0;
91  virtual HINSTANCE HInstance() { return NULL; }
92 
93 
95  virtual int IsPublic(){return TRUE;};
97  virtual int UseGDI(){return FALSE;};
98 
99 
101  virtual void* activate(int cmd, void* arg1=0, void* arg2=0, void* arg3=0) { return 0; }
102  };
103 }
104 
105 #if !defined(PE_CORE_EXPORTING) && !defined(PARAENGINE_MOBILE) && !defined(NPLRUNTIME_STATICLIB)
106 
107 namespace ParaEngine
108 {
109  typedef IParaEngineCore* (STDCALL* funcPtrGetCOREInterface_type)();
110 
116  class CParaEngineCore
117  {
118  public:
119  static IParaEngineCore* GetParaEngineCOREInterface()
120  {
121  static IParaEngineCore* s_pCore = NULL;
122  if (s_pCore == NULL)
123  {
124 #ifdef WIN32
125 #ifdef _DEBUG
126  HINSTANCE hDLL = (HINSTANCE)::LoadLibrary(_T("ParaEngineClient_d.dll"));
127 #else
128  HINSTANCE hDLL = (HINSTANCE)::LoadLibrary(_T("ParaEngineClient.dll"));
129 #endif
130  if(hDLL != INVALID_HANDLE_VALUE)
131  {
132  funcPtrGetCOREInterface_type pFuncPtr = (funcPtrGetCOREInterface_type)::GetProcAddress(hDLL, "GetParaEngineCOREInterface");
133  if(pFuncPtr){
134  s_pCore = pFuncPtr();
135  }
136  else{
137  throw "can not GetCOREInterface";
138  }
139  ::FreeLibrary(hDLL);
140  }
141 #else
142  s_pCore = GetCOREInterface();
143 #endif
144  }
145  return s_pCore;
146  }
147  };
148 }
149 
150 #endif
PE_CORE_DECL void * GetProcAddress(void *Lib, const char *Fnname)
Definition: os_calls.cpp:99
IParaEngineCore * GetCOREInterface()
get IParaEngineCore interface.
Definition: PluginAPI.cpp:23
virtual HINSTANCE HInstance()
returns owning module handle (DLL handle)
Definition: PluginAPI.h:91
virtual const char * Category()=0
it may be some predefined category name.
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual Class_ID ClassID()=0
uniquely identifies a specific plugin class.
virtual SClass_ID SuperClassID()=0
This method returns a system-defined constant describing the class that this plugin class was derived...
virtual int IsPublic()
whether the class is accessible from the UI.
Definition: PluginAPI.h:95
This class represents the unique class ID for a ParaEngine plug-in.
Definition: PEtypes.h:240
virtual int UseGDI()
whether the class uses windows GDI to draw controls.
Definition: PluginAPI.h:97
a table of virtual functions which are used by plug-ins to access the game engine ...
Definition: IParaEngineCore.h:17
It implements the IParaEngineCore interface, which exposes everything in ParaEngine to plug-in applic...
Definition: ParaEngineCore.h:15
DWORD GetParaEngineVersion()
define PE_MODULE_STANDALONE if the plugin does not link to Core lib under win32
Definition: PluginAPI.cpp:18
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 ...
virtual void * activate(int cmd, void *arg1=0, void *arg2=0, void *arg3=0)
genetic activation function as the one in the NPL script file.
Definition: PluginAPI.h:101
virtual const char * ClassName()=0
class name
int SClass_ID
class ID for built-in classes only.
Definition: PEtypes.h:220
System keeps a list of the DLL's found on startup.
Definition: PluginAPI.h:61