00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __NEMODULE_H
00030 #define __NEMODULE_H
00031
00032 #ifndef __NEED_VECTOR_STRING
00033 # define __NEED_VECTOR_STRING
00034 #endif
00035
00036 #include "base.h"
00037 #include "hashtable.h"
00038 #include "pointer.h"
00039
00040 #include <string>
00041 #include <vector>
00042
00043
00044
00050 namespace NeoEngine
00051 {
00052
00053
00054 #if defined( WIN32 )
00055
00056 typedef void *ModLib;
00057 typedef void *ModSymbol;
00058
00059 #elif defined( __APPLE__ )
00060
00061 typedef void* ModLib;
00062 typedef void* ModSymbol;
00063
00064 #elif defined( POSIX )
00065
00066 typedef void* ModLib;
00067 typedef void* ModSymbol;
00068
00069 #else
00070 # error "Feature Module unimplemented on this platform"
00071 #endif
00072
00073
00074 HashTableExport( Module );
00075
00076
00077
00078 class ModuleManager;
00079
00080
00088 class NEOENGINE_API Module : public RefCounter
00089 {
00090 friend class ModuleManager;
00091
00092 protected:
00093
00095 ModuleManager *m_pkManager;
00096
00098 HashString m_strName;
00099
00100
00101 public:
00102
00108 Module( const HashString &rstrName, ModuleManager *pkManager );
00109
00112 virtual ~Module();
00113
00117 virtual bool IsValid() const = 0;
00118
00122 virtual bool IsStatic() const = 0;
00123
00129 virtual ModSymbol LookupSymbol( const HashString &rstrSymbol ) = 0;
00130
00134 const HashString &GetName() const { return m_strName; }
00135 };
00136
00137
00138 #ifndef __HAVE_SMARTPOINTER_MODULE
00139 SmartPointer( Module );
00140 # define __HAVE_SMARTPOINTER_MODULE
00141 #endif
00142
00143
00148 class NEOENGINE_API ModuleDynamic : public Module
00149 {
00150 private:
00151
00153 HashString m_strPathName;
00154
00156 ModLib m_Lib;
00157
00158 #ifdef __APPLE__
00159
00161 bool m_bIsMacBundleLib;
00162
00163 #endif
00164
00165 public:
00166
00174 ModuleDynamic( const HashString &rstrName, const HashString &rstrFullPath, ModuleManager *pkManager, bool bMacBundleLib = false );
00175
00179 virtual ~ModuleDynamic();
00180
00184 virtual bool IsValid() const { return( m_Lib != 0 ); }
00185
00189 virtual bool IsStatic() const { return false; }
00190
00196 virtual ModSymbol LookupSymbol( const HashString &rstrSymbol );
00197 };
00198
00199
00200 #if defined( WIN32 ) && defined( _MSC_VER ) && !defined( BUILD_STATIC )
00201
00202 EXPIMP_TEMPLATE template class NEOENGINE_API HashTable< ModSymbol >;
00203
00204 #endif
00205
00206
00211 class NEOENGINE_API ModuleStatic : public Module
00212 {
00213 public:
00214
00216 HashTable< ModSymbol > m_Symbols;
00217
00218
00219
00224 ModuleStatic( const HashString &rstrName );
00225
00228 virtual ~ModuleStatic();
00229
00233 virtual bool IsValid() const { return true; }
00234
00238 virtual bool IsStatic() const { return true; }
00239
00245 virtual ModSymbol LookupSymbol( const HashString &rstrSymbol );
00246 };
00247
00248
00249 #ifdef WIN32
00250 # ifndef __HAVE_VECTOR_HASHSTRING_NOPOINTER
00251 UDTVectorEXPIMP( class HashString );
00252 # define __HAVE_VECTOR_HASHSTRING_NOPOINTER
00253 # endif
00254 #endif
00255
00256
00265 class NEOENGINE_API ModuleManager
00266 {
00267 friend class Module;
00268
00269 protected:
00270
00272 std::vector< HashString > m_vstrSearchPaths;
00273
00275 HashTable< Module > m_hashModules;
00276
00281 bool PathExists( const HashString &rstrPath );
00282
00283
00284 public:
00285
00289 ModuleManager();
00290
00294 virtual ~ModuleManager ();
00295
00302 bool AddSearchPath( const HashString &rstrPath, bool bForce = false );
00303
00308 void RemoveSearchPath( const HashString &rstrPath );
00309
00315 virtual ModulePtr LoadModule( const HashString &rstrName );
00316
00321 virtual void InsertModule( Module *pkModule );
00322
00328 virtual void RemoveModule( Module *pkModule, bool bDeleted = false );
00329 };
00330
00331
00332 };
00333
00334
00335 #endif