- Timestamp:
- Nov 17, 2005, 1:20:48 AM (19 years ago)
- Location:
- branches/world_entities/src
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/world_entities/src/lib/graphics/light.cc
r5357 r5622 29 29 using namespace std; 30 30 31 CREATE_FACTORY(Light );31 CREATE_FACTORY(Light, CL_LIGHT); 32 32 33 33 //! Definition of the Lights and their Names -
branches/world_entities/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc
r5373 r5622 25 25 #include "load_param.h" 26 26 27 CREATE_FACTORY(GLMenuImageScreen );27 CREATE_FACTORY(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN); 28 28 29 29 using namespace std; -
branches/world_entities/src/lib/particles/particle_emitter.cc
r5445 r5622 28 28 29 29 30 CREATE_FACTORY(ParticleEmitter );30 CREATE_FACTORY(ParticleEmitter, CL_PARTICLE_EMITTER); 31 31 32 32 /** -
branches/world_entities/src/lib/particles/particle_system.cc
r5511 r5622 32 32 #include "tinyxml.h" 33 33 34 CREATE_FACTORY(ParticleSystem );34 CREATE_FACTORY(ParticleSystem, CL_PARTICLE_SYSTEM); 35 35 SHELL_COMMAND(texture, ParticleSystem, setMaterialTexture) 36 36 ->defaultValues(1, "maps/evil-flower.png"); -
branches/world_entities/src/lib/physics/fields/gravity.cc
r5357 r5622 23 23 using namespace std; 24 24 25 CREATE_FACTORY(Gravity );25 CREATE_FACTORY(Gravity, CL_FIELD_GRAVITY); 26 26 27 27 Gravity::Gravity(const TiXmlElement* root) -
branches/world_entities/src/lib/physics/physics_connection.cc
r5357 r5622 29 29 using namespace std; 30 30 31 CREATE_FACTORY(PhysicsConnection );31 CREATE_FACTORY(PhysicsConnection, CL_PHYSICS_CONNECTION); 32 32 33 33 /** -
branches/world_entities/src/story_entities/world.cc
r5558 r5622 81 81 82 82 //! This creates a Factory to fabricate a World 83 CREATE_FACTORY(World );83 CREATE_FACTORY(World, CL_WORLD); 84 84 85 85 World::World(const TiXmlElement* root) -
branches/world_entities/src/subprojects/collision_detection/collision_test_entity.cc
r5487 r5622 26 26 27 27 using namespace std; 28 CREATE_FACTORY(CollisionTestEntity );28 CREATE_FACTORY(CollisionTestEntity, CL_ENVIRONMENT); 29 29 30 30 /** -
branches/world_entities/src/util/loading/factory.cc
r5298 r5622 34 34 set everything to zero and define factoryName 35 35 */ 36 Factory::Factory (const char* factoryName )36 Factory::Factory (const char* factoryName, ClassID classID) 37 37 { 38 38 this->setClassID(CL_FACTORY, "Factory"); … … 40 40 41 41 this->next = NULL; 42 this->classID = classID; 42 43 43 44 Factory::registerFactory(this); -
branches/world_entities/src/util/loading/factory.h
r5357 r5622 33 33 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file) 34 34 */ 35 #define CREATE_FACTORY(CLASS_NAME ) \36 tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME )35 #define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \ 36 tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID) 37 37 38 38 //! The Factory is a loadable object handler … … 40 40 41 41 public: 42 Factory (const char* factoryName = NULL );42 Factory (const char* factoryName = NULL, ClassID classID = CL_NULL); 43 43 virtual ~Factory (); 44 44 45 45 void fabricate(const char* className, const char* entityName); 46 virtual BaseObject* fabricate(ClassID classID) = NULL; 46 47 virtual BaseObject* fabricate(const TiXmlElement* root) = NULL; 47 48 virtual BaseObject* fabricateDirect() = NULL; … … 57 58 Factory* getNext() const { return this->next; }; 58 59 60 61 protected: 62 ClassID classID; //!< The CLass-Identifyer of the Factory. 63 59 64 private: 60 65 Factory* next; //!< pointer to the next factory. … … 64 69 /** 65 70 * a factory that is able to load any kind of Object 66 67 */71 * (this is a Functor) 72 */ 68 73 template<class T> class tFactory : public Factory 69 74 { 70 public:71 tFactory(const char* factoryName);72 virtual ~tFactory();75 public: 76 tFactory(const char* factoryName, ClassID classID); 77 virtual ~tFactory(); 73 78 74 79 private: 75 virtual BaseObject* fabricate(const TiXmlElement* root); 76 virtual BaseObject* fabricateDirect(); 80 virtual BaseObject* fabricate(ClassID classID); 81 virtual BaseObject* fabricate(const TiXmlElement* root); 82 virtual BaseObject* fabricateDirect(); 77 83 }; 78 84 … … 82 88 */ 83 89 template<class T> 84 tFactory<T>::tFactory(const char* factoryName) : Factory(factoryName)90 tFactory<T>::tFactory(const char* factoryName, ClassID classID) : Factory(factoryName, classID) 85 91 { 86 92 PRINTF(4)("Class: %s loadable\n", this->getName()); 87 93 } 88 94 89 95 /** 96 * destructs the type-Factory 97 */ 90 98 template<class T> 91 tFactory<T>::~tFactory()99 tFactory<T>::~tFactory() 92 100 {} 93 101 102 /** 103 * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*) 104 * @param root the TiXmlElement T should load parameters from. 105 * @return the newly fabricated T, NULL otherwise. 106 */ 94 107 template<class T> 95 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)108 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root) 96 109 { 97 110 if (root == NULL) … … 106 119 } 107 120 121 122 /** 123 * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*) 124 * @param classID the ClassID of T that should be created. 125 * @return the newly fabricated T if fabricated NULL otherwise. 126 */ 127 template<class T> 128 BaseObject* tFactory<T>::fabricate(ClassID classID) 129 { 130 if(classID == this->classID) 131 return this->fabricateDirect(); 132 else if( getNext() != NULL) 133 return getNext()->fabricate( classID); 134 else 135 return NULL; 136 } 137 138 /** 139 * directly fabricate an Entity of this factory. 140 */ 108 141 template<class T> 109 142 BaseObject* tFactory<T>::fabricateDirect() -
branches/world_entities/src/world_entities/environment.cc
r5500 r5622 28 28 29 29 using namespace std; 30 CREATE_FACTORY(Environment );30 CREATE_FACTORY(Environment, CL_ENVIRONMENT); 31 31 32 32 /** -
branches/world_entities/src/world_entities/player.cc
r5621 r5622 37 37 using namespace std; 38 38 39 CREATE_FACTORY(Player );39 CREATE_FACTORY(Player, CL_PLAYER); 40 40 41 41 /** … … 83 83 Weapon* wpLeft = new TestGun(this->weaponMan, 1); 84 84 wpLeft->setName("testGun Left"); 85 Weapon* cannon = new Cannon(this->weaponMan); 85 Weapon* cannon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(CL_CANNON)); 86 cannon->setWeaponManager(this->weaponMan); 86 87 cannon->setName("BFG"); 87 88 -
branches/world_entities/src/world_entities/power_ups/laser_power_up.cc
r5500 r5622 25 25 using namespace std; 26 26 27 CREATE_FACTORY(LaserPowerUp );27 CREATE_FACTORY(LaserPowerUp, CL_LASER_POWER_UP); 28 28 29 29 LaserPowerUp::LaserPowerUp () -
branches/world_entities/src/world_entities/power_ups/turret_power_up.cc
r5500 r5622 25 25 using namespace std; 26 26 27 CREATE_FACTORY(TurretPowerUp );27 CREATE_FACTORY(TurretPowerUp, CL_TURRET_POWER_UP); 28 28 29 29 TurretPowerUp::TurretPowerUp () -
branches/world_entities/src/world_entities/skybox.cc
r5511 r5622 25 25 using namespace std; 26 26 27 CREATE_FACTORY(SkyBox );27 CREATE_FACTORY(SkyBox, CL_SKYBOX); 28 28 29 29 /** -
branches/world_entities/src/world_entities/terrain.cc
r5511 r5622 29 29 using namespace std; 30 30 31 CREATE_FACTORY(Terrain );31 CREATE_FACTORY(Terrain, CL_TERRAIN); 32 32 33 33 /** -
branches/world_entities/src/world_entities/weapons/aiming_turret.cc
r5576 r5622 30 30 #include "factory.h" 31 31 32 CREATE_FACTORY(AimingTurret );32 CREATE_FACTORY(AimingTurret, CL_AIMING_TURRET); 33 33 34 34 using namespace std; -
branches/world_entities/src/world_entities/weapons/cannon.cc
r5621 r5622 41 41 using namespace std; 42 42 43 CREATE_FACTORY(Cannon );43 CREATE_FACTORY(Cannon, CL_CANNON); 44 44 45 45 /** -
branches/world_entities/src/world_entities/weapons/test_gun.cc
r5500 r5622 41 41 using namespace std; 42 42 43 CREATE_FACTORY(TestGun );43 CREATE_FACTORY(TestGun, CL_TEST_GUN); 44 44 45 45 /** -
branches/world_entities/src/world_entities/weapons/turret.cc
r5512 r5622 30 30 #include "factory.h" 31 31 32 CREATE_FACTORY(Turret );32 CREATE_FACTORY(Turret, CL_TURRET); 33 33 34 34 using namespace std;
Note: See TracChangeset
for help on using the changeset viewer.