- Timestamp:
- Feb 19, 2006, 3:18:08 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/defs/class_id.h
r7123 r7167 335 335 CL_QUICK_ANIMATION = 0x00000e02, 336 336 337 CL_FACTORY = 0x00000e03, 338 CL_FAST_FACTORY = 0x00000e01, 339 CL_LOAD_PARAM = 0x00000e07, 337 CL_FACTORY = 0x00e01000, 338 CL_FAST_FACTORY = 0x00000ea2, 339 CL_LOAD_PARAM = 0x00000ea3, 340 CL_DYNAMIC_LOADER = 0x00000ea8, 340 341 341 342 CL_INI_PARSER = 0x00000e04, 342 343 CL_TRACK_ELEMENT = 0x00000e0b,344 CL_LIST = 0x00000e05,345 CL_SUBSTRING = 0x00000e06,346 CL_CURVE = 0x00000e08,347 CL_CHARACTER_ATTRIBUTES = 0x00000e0a,348 CL_NUMBER = 0x00000e0c,349 CL_EXECUTOR = 0x00000e0d,350 343 351 344 CL_SHELL = 0x00000e10, … … 356 349 CL_SHELL_COMMAND_ALIAS = 0x00000e15, 357 350 351 CL_TRACK_ELEMENT = 0x00000e2b, 352 CL_LIST = 0x00000e25, 353 CL_SUBSTRING = 0x00000e26, 354 CL_CURVE = 0x00000e28, 355 CL_CHARACTER_ATTRIBUTES = 0x00000e2a, 356 CL_NUMBER = 0x00000e2c, 357 CL_EXECUTOR = 0x00000e2d, 358 358 359 // Spatial Data Separation 359 360 CL_SPATIAL_SEPARATION = 0x00000e0d, -
trunk/src/orxonox.cc
r7126 r7167 289 289 } 290 290 291 #include "dynamic_loader.h" 291 292 292 293 /** … … 330 331 ResourceManager::getInstance()->addImageDir(imageDir); 331 332 delete[] imageDir; 333 334 DynamicLoader::loadDyLib("libtest.so"); 332 335 333 336 // start the collision detection engine -
trunk/src/util/Makefile.am
r7151 r7167 6 6 libORXutils_a_SOURCES = fast_factory.cc \ 7 7 object_manager.cc \ 8 loading/factory.cc \9 8 state.cc \ 10 9 hud.cc \ … … 20 19 loading/load_param.cc \ 21 20 loading/load_param_description.cc \ 21 loading/factory.cc \ 22 loading/dynamic_loader.cc \ 22 23 \ 23 24 track/pilot_node.cc \ … … 38 39 \ 39 40 loading/resource_manager.h \ 40 loading/factory.h \41 41 loading/game_loader.h \ 42 42 loading/load_param.h \ 43 43 loading/load_param_description.h \ 44 loading/factory.h \ 45 loading/dynamic_loader.h \ 44 46 \ 45 47 track/pilot_node.h \ -
trunk/src/util/loading/dynamic_loader.cc
r7164 r7167 10 10 11 11 ### File Specific: 12 main-programmer: ...12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 14 */ 15 15 16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING 17 17 18 #include "proto_class.h" 18 #include "dynamic_loader.h" 19 20 21 #include <dlfcn.h> 22 19 23 20 24 using namespace std; … … 25 29 * @todo this constructor is not jet implemented - do it 26 30 */ 27 ProtoClass::ProtoClass () 31 DynamicLoader::DynamicLoader (const std::string& libName) 32 : Factory(NULL, CL_NULL) 28 33 { 29 this->setClassID(CL_PROTO_ID, "ProtoClass");34 this->setClassID(CL_DYNAMIC_LOADER, "DynamicLoader"); 30 35 31 /* If you make a new class, what is most probably the case when you write this file 32 don't forget to: 33 1. Add the new file new_class.cc to the ./src/Makefile.am 34 2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS 36 this->handle = NULL; 35 37 36 Advanced Topics: 37 - if you want to let your object be managed via the ObjectManager make sure to read 38 the object_manager.h header comments. You will use this most certanly only if you 39 make many objects of your class, like a weapon bullet. 40 */ 38 if (loadDynamicLib(libName)); 39 this->setName(&libName[0]); 41 40 } 42 41 … … 45 44 * standard deconstructor 46 45 */ 47 ProtoClass::~ProtoClass()46 DynamicLoader::~DynamicLoader () 48 47 { 49 48 // delete what has to be deleted here 49 if (this->handle != NULL) 50 dlclose(this->handle); 50 51 } 52 53 54 bool DynamicLoader::loadDynamicLib(const std::string& libName) 55 { 56 this->handle = dlopen(&libName[0], RTLD_NOW); 57 if(this->handle == NULL) 58 { 59 return false; 60 } 61 void *mkr = dlsym( this->handle, "maker"); 62 } 63 64 bool DynamicLoader::loadDyLib(const std::string& libName) 65 { 66 void* handle; 67 handle = dlopen(&libName[0], RTLD_NOW); 68 if(handle == NULL) 69 { 70 PRINTF(0)("unable to load %s\n", &libName[0]); 71 return false; 72 } 73 // void *mkr = dlsym("maker"); 74 75 } 76 77 78 BaseObject* DynamicLoader::fabricateObject(const TiXmlElement* root) const 79 { 80 } -
trunk/src/util/loading/dynamic_loader.h
r7164 r7167 1 1 /*! 2 * @file proto_class.h3 * @brief Definition of ...2 * @file dynamic_loader.h 3 * @brief Definition of The Dynamic Loader Factory. 4 4 */ 5 5 6 #ifndef _ PROTO_CLASS_H7 #define _ PROTO_CLASS_H6 #ifndef _DYNAMIC_LOADER_H 7 #define _DYNAMIC_LOADER_H 8 8 9 #include "base_object.h" 9 #include "factory.h" 10 11 #include <string> 12 13 #define DYNAMIC_LINKAGE_FACTORY(CLASS_NAME, CLASS_ID) \ 14 void* DynamicCreator(const TiXmlElement* root) { return new CLASS_NAME(root); }; 10 15 11 16 // FORWARD DECLARATION 12 17 18 //! A class for ... 19 class DynamicLoader : public Factory 20 { 21 22 public: 23 DynamicLoader(const std::string& libName); 24 virtual ~DynamicLoader(); 25 26 bool loadDynamicLib(const std::string& libName); 27 virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const; 28 29 static bool loadDyLib(const std::string& libName); 13 30 14 31 15 //! A class for ... 16 class ProtoClass : public BaseObject { 17 18 public: 19 ProtoClass(); 20 virtual ~ProtoClass(); 21 22 23 private: 24 32 private: 33 void* handle; 25 34 }; 26 35 27 #endif /* _ PROTO_CLASS_H */36 #endif /* _DYNAMIC_LOADER_H */ -
trunk/src/util/loading/factory.h
r6341 r7167 38 38 tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID) 39 39 40 // #define CREATE_DYNAMIC_FACTORY(CLASS_NAME, CLASS_ID) \ 41 // tFactory<CLASS_NAME>* global_##CLASS_NAME##_Dynamic_Factory = new DynamicLoader<CLASS_NAME>(#CLASS_NAME, CLASS_ID) 42 40 43 //! The Factory is a loadable object handler 41 44 class Factory : public BaseObject { 42 45 43 46 public: 44 Factory (const char* factoryName, ClassID classID);45 47 virtual ~Factory (); 46 48 … … 56 58 57 59 protected: 60 Factory (const char* factoryName, ClassID classID); 58 61 virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0; 59 62 -
trunk/src/world_entities/WorldEntities.am
r7155 r7167 4 4 world_entities/npcs/npc_test.cc \ 5 5 world_entities/npcs/ground_turret.cc \ 6 \ 6 7 world_entities/environment.cc \ 7 8 world_entities/skysphere.cc \
Note: See TracChangeset
for help on using the changeset viewer.