Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

CPlugIn Class Reference

#include <PlugIn.h>

Inheritance diagram for CPlugIn:

Inheritance graph
[legend]
Collaboration diagram for CPlugIn:

Collaboration graph
[legend]

Public Member Functions

void addMenuID (int n)
 CPlugIn ()
IPluginEntityCreatePluginEntity (entity_t *)
void dispatchCommand (const char *p, vec3_t vMin, vec3_t vMax, BOOL bSingleBrush)
void free ()
const char * getCommand (int n)
int getCommandCount ()
HMODULE GetDLLModule ()
void * getFuncTable ()
const char * getMenuName ()
LPVOID getSurfaceFlags ()
_QERTextureInfogetTextureInfo ()
const char * getVersionStr ()
void InitBSPFrontendPlugin ()
void InitSurfacePlugin ()
bool load (const char *p)
void loadTexture (LPCSTR pFilename)
bool ownsCommandID (int n)
void RegisterPluginEntities ()
virtual ~CPlugIn ()

Private Attributes

CWordArray m_CommandIDs
CStringArray m_CommandStrings
HMODULE m_hDLL
PFN_QERPLUG_DISPATCH m_pfnDispatch
PFN_QERPLUG_GETCOMMANDLIST m_pfnGetCommandList
PFN_QERPLUG_GETFUNCTABLE m_pfnGetFuncTable
PFN_QERPLUG_GETNAME m_pfnGetName
PFN_QERPLUG_GETSURFACEFLAGS m_pfnGetSurfaceFlags
PFN_QERPLUG_GETTEXTUREINFO m_pfnGetTextureInfo
PFN_QERPLUG_INIT m_pfnInit
PFN_QERPLUG_INITSURFACEPROPERTIES m_pfnInitSurfaceProperties
PFN_QERPLUG_LOADTEXTURE m_pfnLoadTexture
PFN_QERPLUG_REGISTERPLUGINENTITIES m_pfnRegisterPluginEntities
PFN_QERPLUG_REQUESTINTERFACE m_pfnRequestInterface
_QERPlugEntitiesFactorym_pQERPlugEntitiesFactory
CString m_strName
CString m_strVersion

Constructor & Destructor Documentation

CPlugIn  ) 
 

Definition at line 40 of file PlugIn.cpp.

References m_hDLL, and m_pQERPlugEntitiesFactory.

00041 {
00042   m_hDLL = NULL;
00043   m_pQERPlugEntitiesFactory = NULL;
00044 }

~CPlugIn  )  [virtual]
 

Definition at line 46 of file PlugIn.cpp.

References free(), and m_hDLL.

00047 {
00048     if (m_pQERPlugEntitiesFactory)
00049         delete m_pQERPlugEntitiesFactory;
00050     if (m_hDLL != NULL)
00051         free();
00052 }

Here is the call graph for this function:


Member Function Documentation

void addMenuID int  n  ) 
 

Definition at line 189 of file PlugIn.cpp.

References m_CommandIDs, and n.

Referenced by CMainFrame::AddPlugInMenuItem().

00190 {
00191   m_CommandIDs.Add(n);
00192 }

IPluginEntity * CreatePluginEntity entity_t  ) 
 

Definition at line 283 of file PlugIn.cpp.

References e, _QERPlugEntitiesFactory::m_pfnCreateEntity, m_pQERPlugEntitiesFactory, and Sys_Printf().

Referenced by Entity_Create(), and Entity_Parse().

00284 {
00285     if (m_pQERPlugEntitiesFactory)
00286     {
00287         // create an IEpair interface for e->epairs
00288         CEpairsWrapper *pEp = new CEpairsWrapper( e );
00289         IPluginEntity *pEnt = m_pQERPlugEntitiesFactory->m_pfnCreateEntity( e->eclass, pEp );
00290         if ( pEnt )
00291             return pEnt;
00292         delete pEp;
00293         return NULL;
00294     }
00295     Sys_Printf("WARNING: unexpected m_pQERPlugEntitiesFactory is NULL in CPlugin::CreatePluginEntity\n");
00296     return NULL;
00297 }

Here is the call graph for this function:

void dispatchCommand const char *  p,
vec3_t  vMin,
vec3_t  vMax,
BOOL  bSingleBrush
 

Definition at line 181 of file PlugIn.cpp.

Referenced by CPlugInManager::Dispatch().

00182 {
00183   if (m_pfnDispatch)
00184   {
00185     (*m_pfnDispatch)(p, vMin, vMax, bSingleBrush);
00186   }
00187 }

void free  ) 
 

Definition at line 154 of file PlugIn.cpp.

References m_hDLL.

Referenced by CPlugInManager::Cleanup(), load(), and ~CPlugIn().

00155 {
00156   if (m_hDLL != NULL)
00157     ::FreeLibrary(m_hDLL);
00158   m_hDLL = NULL;
00159 }

const char * getCommand int  n  ) 
 

Definition at line 176 of file PlugIn.cpp.

References m_CommandStrings, and n.

Referenced by CMainFrame::AddPlugInMenuItem().

00177 {
00178   return m_CommandStrings.GetAt(n);
00179 }

int getCommandCount  ) 
 

Definition at line 171 of file PlugIn.cpp.

References m_CommandStrings.

Referenced by CMainFrame::AddPlugInMenuItem().

00172 {
00173   return m_CommandStrings.GetSize();
00174 }

HMODULE GetDLLModule  )  [inline]
 

Definition at line 59 of file PlugIn.h.

References HMODULE.

00059 { return m_hDLL; }

void * getFuncTable  ) 
 

Definition at line 204 of file PlugIn.cpp.

Referenced by CPlugInManager::FillFuncTable().

00205 {
00206   if (m_pfnGetFuncTable)
00207   {
00208     return (*m_pfnGetFuncTable)();
00209   }
00210   return NULL;
00211 }

const char * getMenuName  ) 
 

Definition at line 166 of file PlugIn.cpp.

Referenced by CMainFrame::AddPlugInMenuItem().

00167 {
00168   return m_strName;
00169 }

LPVOID getSurfaceFlags  ) 
 

Definition at line 145 of file PlugIn.cpp.

References LPVOID, and m_pfnGetSurfaceFlags.

Referenced by CPlugInManager::GetSurfaceFlags(), and CPlugInManager::Init().

00146 {
00147   if (m_pfnGetSurfaceFlags != NULL)
00148   {
00149     return reinterpret_cast<LPVOID>((*m_pfnGetSurfaceFlags)());
00150   }
00151   return NULL;
00152 }

_QERTextureInfo * getTextureInfo  ) 
 

Definition at line 128 of file PlugIn.cpp.

References m_pfnGetTextureInfo.

Referenced by CPlugInManager::GetTextureInfo(), and CPlugInManager::Init().

00129 {
00130   if (m_pfnGetTextureInfo != NULL)
00131   {
00132     return reinterpret_cast<_QERTextureInfo*>((*m_pfnGetTextureInfo)());
00133   }
00134   return NULL;
00135 }

const char * getVersionStr  ) 
 

Definition at line 161 of file PlugIn.cpp.

References m_pfnGetName.

Referenced by CPlugInManager::FillFuncTable().

00162 {
00163     return m_pfnGetName();
00164 }

void InitBSPFrontendPlugin  ) 
 

Definition at line 237 of file PlugIn.cpp.

References QEGlobals_t::bBSPFrontendPlugin, g_BSPFrontendTable, g_qeglobals, _QERPlugBSPFrontendTable::m_nSize, and m_pfnRequestInterface.

Referenced by CPlugInManager::Init().

00238 {
00239     if (m_pfnRequestInterface)
00240     {
00241         // request a _QERPlugBSPFrontendTable
00242         g_BSPFrontendTable.m_nSize = sizeof( _QERPlugBSPFrontendTable );
00243         if ( m_pfnRequestInterface( QERPlugBSPFrontendTable_GUID, &g_BSPFrontendTable ) )
00244         {
00245             g_qeglobals.bBSPFrontendPlugin = true;
00246         }
00247     }
00248 }

void InitSurfacePlugin  ) 
 

Definition at line 250 of file PlugIn.cpp.

References QEGlobals_t::bSurfacePropertiesPlugin, g_qeglobals, g_SurfaceTable, _QERPlugSurfaceTable::m_nSize, m_pfnInitSurfaceProperties, m_pfnRequestInterface, m_strName, and Sys_Printf().

Referenced by CPlugInManager::Init().

00251 {
00252     // if we found the QERPlug_InitSurfaceProperties export, it means this plugin does surface properties
00253     if (m_pfnInitSurfaceProperties)
00254     {
00255         if (g_qeglobals.bSurfacePropertiesPlugin)
00256         {
00257             Sys_Printf( "WARNING: conflict for surface properties plugins. %s ignored.\n", m_strName );
00258             return;
00259         }
00260         if (m_pfnRequestInterface)
00261         {
00262             // call the plugin surface properties init
00263             m_pfnInitSurfaceProperties();
00264             // request filling of the global _QERPlugSurfaceTable
00265             g_SurfaceTable.m_nSize = sizeof( g_SurfaceTable );
00266             if ( m_pfnRequestInterface( QERPlugSurfaceTable_GUID, &g_SurfaceTable ) )
00267             {
00268                 // update the global so we know we have a surface properties plugin
00269                 g_qeglobals.bSurfacePropertiesPlugin = true;
00270             }
00271             else
00272                 Sys_Printf( "WARNING: _QERPlugSurfaceTable interface request failed for surface plugin\n" );
00273         }
00274         else
00275             Sys_Printf("WARNING: QERPlug_RequestInterface export not found in surface properties plugin.\n");
00276     }
00277 }

Here is the call graph for this function:

bool load const char *  p  ) 
 

Definition at line 54 of file PlugIn.cpp.

References free(), g_pParentWnd, LPVOID, m_CommandStrings, m_hDLL, m_pfnDispatch, m_pfnGetCommandList, m_pfnGetFuncTable, m_pfnGetName, m_pfnGetSurfaceFlags, m_pfnGetTextureInfo, m_pfnInit, m_pfnInitSurfaceProperties, m_pfnLoadTexture, m_pfnRegisterPluginEntities, m_pfnRequestInterface, m_strName, m_strVersion, NULL, p, strcpy(), strtok(), Sys_Printf(), and token.

Referenced by CPlugInManager::Init().

00055 {
00056     m_hDLL = ::LoadLibrary(p);
00057     if (m_hDLL != NULL)
00058     {
00059         m_pfnInit = reinterpret_cast<PFN_QERPLUG_INIT>(::GetProcAddress(m_hDLL, QERPLUG_INIT));
00060         if (m_pfnInit != NULL)
00061         {
00062             m_strVersion = (*m_pfnInit)(AfxGetApp()->m_hInstance, g_pParentWnd->GetSafeHwnd());
00063             Sys_Printf("Loaded plugin > %s\n", m_strVersion);
00064             
00065             m_pfnGetName = reinterpret_cast<PFN_QERPLUG_GETNAME>(::GetProcAddress(m_hDLL, QERPLUG_GETNAME));
00066             if (m_pfnGetName != NULL)
00067             {
00068                 m_strName = (*m_pfnGetName)();
00069             }
00070             
00071             m_pfnGetCommandList = reinterpret_cast<PFN_QERPLUG_GETCOMMANDLIST>(::GetProcAddress(m_hDLL, QERPLUG_GETCOMMANDLIST));
00072             if (m_pfnGetCommandList)
00073             {
00074                 CString str = (*m_pfnGetCommandList)();
00075                 char cTemp[1024];
00076                 strcpy(cTemp, str);
00077                 char* token = strtok(cTemp, ",;");
00078                 if (token && *token == ' ')
00079                 {
00080                     while (*token == ' ')
00081                         token++;
00082                 }
00083                 while (token != NULL)
00084                 {
00085                     m_CommandStrings.Add(token);
00086                     token = strtok(NULL, ",;");
00087                 }
00088             }
00089             
00090             m_pfnDispatch = reinterpret_cast<PFN_QERPLUG_DISPATCH>(::GetProcAddress(m_hDLL, QERPLUG_DISPATCH));
00091             m_pfnGetFuncTable = reinterpret_cast<PFN_QERPLUG_GETFUNCTABLE>(::GetProcAddress(m_hDLL, QERPLUG_GETFUNCTABLE));
00092             
00093             m_pfnGetTextureInfo = reinterpret_cast<PFN_QERPLUG_GETTEXTUREINFO>(::GetProcAddress(m_hDLL, QERPLUG_GETTEXTUREINFO));
00094             m_pfnLoadTexture = reinterpret_cast<PFN_QERPLUG_LOADTEXTURE>(::GetProcAddress(m_hDLL, QERPLUG_LOADTEXTURE));
00095             
00096             m_pfnGetSurfaceFlags = reinterpret_cast<PFN_QERPLUG_GETSURFACEFLAGS>(::GetProcAddress(m_hDLL, QERPLUG_GETSURFACEFLAGS));
00097             
00098             m_pfnRegisterPluginEntities = reinterpret_cast<PFN_QERPLUG_REGISTERPLUGINENTITIES>(::GetProcAddress(m_hDLL, QERPLUG_REGISTERPLUGINENTITIES));
00099             
00100             m_pfnInitSurfaceProperties = reinterpret_cast<PFN_QERPLUG_INITSURFACEPROPERTIES>(::GetProcAddress(m_hDLL, QERPLUG_INITSURFACEPROPERTIES));
00101             
00102             m_pfnRequestInterface = reinterpret_cast<PFN_QERPLUG_REQUESTINTERFACE>(::GetProcAddress(m_hDLL, QERPLUG_REQUESTINTERFACE));
00103 
00104             return (m_pfnDispatch != NULL && m_pfnGetFuncTable != NULL);
00105             //--return true;
00106         }
00107         Sys_Printf("FAILED to Load plugin > %s\n", p);
00108     }
00109     LPVOID lpMsgBuf;
00110     FormatMessage( 
00111         FORMAT_MESSAGE_ALLOCATE_BUFFER | 
00112         FORMAT_MESSAGE_FROM_SYSTEM | 
00113         FORMAT_MESSAGE_IGNORE_INSERTS,
00114         NULL,
00115         GetLastError(),
00116         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00117         (LPTSTR) &lpMsgBuf,
00118         0,
00119         NULL 
00120     );
00121     Sys_Printf("LoadLibrary failed on %s: GetLastError: %s\n", p, lpMsgBuf );
00122     // Free the buffer.
00123     LocalFree( lpMsgBuf );
00124     free();
00125     return false;
00126 }

Here is the call graph for this function:

void loadTexture LPCSTR  pFilename  ) 
 

Definition at line 137 of file PlugIn.cpp.

References m_pfnLoadTexture.

Referenced by CPlugInManager::Init(), and CPlugInManager::LoadTexture().

00138 {
00139   if (m_pfnLoadTexture != NULL)
00140   {
00141     (*m_pfnLoadTexture)(pFilename);
00142   }
00143 }

bool ownsCommandID int  n  ) 
 

Definition at line 194 of file PlugIn.cpp.

References i, and m_CommandIDs.

Referenced by CPlugInManager::Dispatch().

00195 {
00196   for (int i = 0; i < m_CommandIDs.GetSize(); i++)
00197   {
00198     if (m_CommandIDs.GetAt(i) == n)
00199       return true;
00200   }
00201   return false;
00202 }

void RegisterPluginEntities  ) 
 

Definition at line 213 of file PlugIn.cpp.

References QEGlobals_t::d_project_entity, g_qeglobals, _QERPlugEntitiesFactory::m_nSize, m_pfnRegisterPluginEntities, m_pfnRequestInterface, m_pQERPlugEntitiesFactory, m_strName, and Sys_Printf().

Referenced by CPlugInManager::Init().

00214 {
00215     // if we found the QERPlug_RegisterPluginEntities export, it means this plugin provides his own entities
00216     if (m_pfnRegisterPluginEntities)
00217     {
00218         // resquest a _QERPlugEntitiesFactory
00219         if (m_pfnRequestInterface)
00220         {
00221             m_pQERPlugEntitiesFactory = new _QERPlugEntitiesFactory;
00222             m_pQERPlugEntitiesFactory->m_nSize = sizeof(_QERPlugEntitiesFactory);
00223             if (m_pfnRequestInterface( QERPlugEntitiesFactory_GUID, m_pQERPlugEntitiesFactory ))
00224             {
00225                 // create an IEpair interface for the project settings
00226                 CEpairsWrapper *pProjectEp = new CEpairsWrapper( g_qeglobals.d_project_entity );
00227                 m_pfnRegisterPluginEntities( pProjectEp );
00228             }
00229             else
00230                 Sys_Printf( "WARNING: failed to request QERPlugEntitiesFactory from plugin %s\n", m_strName.GetBuffer(0) );
00231         }
00232         else
00233             Sys_Printf( "WARNING: QERPlug_RequestInterface not found in %s\n", m_strName.GetBuffer(0) );
00234     }
00235 }

Here is the call graph for this function:


Field Documentation

CWordArray m_CommandIDs [private]
 

Definition at line 48 of file PlugIn.h.

Referenced by addMenuID(), and ownsCommandID().

CStringArray m_CommandStrings [private]
 

Definition at line 49 of file PlugIn.h.

Referenced by getCommand(), getCommandCount(), and load().

HMODULE m_hDLL [private]
 

Definition at line 36 of file PlugIn.h.

Referenced by CPlugIn(), free(), load(), and ~CPlugIn().

PFN_QERPLUG_DISPATCH m_pfnDispatch [private]
 

Definition at line 40 of file PlugIn.h.

Referenced by load().

PFN_QERPLUG_GETCOMMANDLIST m_pfnGetCommandList [private]
 

Definition at line 39 of file PlugIn.h.

Referenced by load().

PFN_QERPLUG_GETFUNCTABLE m_pfnGetFuncTable [private]
 

Definition at line 41 of file PlugIn.h.

Referenced by load().

PFN_QERPLUG_GETNAME m_pfnGetName [private]
 

Definition at line 38 of file PlugIn.h.

Referenced by getVersionStr(), and load().

PFN_QERPLUG_GETSURFACEFLAGS m_pfnGetSurfaceFlags [private]
 

Definition at line 44 of file PlugIn.h.

Referenced by getSurfaceFlags(), and load().

PFN_QERPLUG_GETTEXTUREINFO m_pfnGetTextureInfo [private]
 

Definition at line 42 of file PlugIn.h.

Referenced by getTextureInfo(), and load().

PFN_QERPLUG_INIT m_pfnInit [private]
 

Definition at line 37 of file PlugIn.h.

Referenced by load().

PFN_QERPLUG_INITSURFACEPROPERTIES m_pfnInitSurfaceProperties [private]
 

Definition at line 46 of file PlugIn.h.

Referenced by InitSurfacePlugin(), and load().

PFN_QERPLUG_LOADTEXTURE m_pfnLoadTexture [private]
 

Definition at line 43 of file PlugIn.h.

Referenced by load(), and loadTexture().

PFN_QERPLUG_REGISTERPLUGINENTITIES m_pfnRegisterPluginEntities [private]
 

Definition at line 45 of file PlugIn.h.

Referenced by load(), and RegisterPluginEntities().

PFN_QERPLUG_REQUESTINTERFACE m_pfnRequestInterface [private]
 

Definition at line 47 of file PlugIn.h.

Referenced by InitBSPFrontendPlugin(), InitSurfacePlugin(), load(), and RegisterPluginEntities().

_QERPlugEntitiesFactory* m_pQERPlugEntitiesFactory [private]
 

Definition at line 54 of file PlugIn.h.

Referenced by CPlugIn(), CreatePluginEntity(), and RegisterPluginEntities().

CString m_strName [private]
 

Definition at line 50 of file PlugIn.h.

Referenced by InitSurfacePlugin(), load(), and RegisterPluginEntities().

CString m_strVersion [private]
 

Definition at line 51 of file PlugIn.h.

Referenced by load().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 19:35:41 2005 for Quake III Arena by  doxygen 1.3.9.1