Changeset 1676 for code/branches/core3/src
- Timestamp:
- Aug 28, 2008, 11:50:53 PM (16 years ago)
- Location:
- code/branches/core3/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/core/ConfigFileManager.cc
r1658 r1676 327 327 file.close(); 328 328 329 COUT( 3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;329 COUT(0) << "Loaded config file \"" << this->filename_ << "\"." << std::endl; 330 330 331 331 // Save the file in case something changed (like stripped whitespaces) -
code/branches/core3/src/core/Factory.cc
r1586 r1676 98 98 } 99 99 (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy(); 100 /* 101 for (it = Identifier::getIdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it) 102 (*it).second->createSuperFunctionCaller(); 103 */ 100 104 COUT(3) << "*** Factory: Finished class-hierarchy creation" << std::endl; 101 105 } -
code/branches/core3/src/core/Identifier.cc
r1610 r1676 145 145 // Tell the parent we're one of it's direct children 146 146 (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this); 147 148 // Create the super-function dependencies 149 (*it)->createSuperFunctionCaller(); 147 150 } 148 151 } -
code/branches/core3/src/core/Identifier.h
r1610 r1676 62 62 #include "MetaObjectList.h" 63 63 #include "Iterator.h" 64 #undef SUPER_INTRUSIVE 65 #include "Super.h" 64 66 #include "util/Debug.h" 65 67 #include "util/String.h" … … 224 226 static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal); 225 227 228 virtual void createSuperFunctionCaller() const = 0; 229 226 230 /** @brief Returns the map that stores all Identifiers. @return The map */ 227 231 static std::map<std::string, Identifier*>& getIdentifierMapIntern(); … … 229 233 static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern(); 230 234 231 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents)232 ObjectListBase* objects_; //!< The list of all objects of this class233 234 private:235 235 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 236 236 inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); } … … 238 238 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); } 239 239 240 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 241 ObjectListBase* objects_; //!< The list of all objects of this class 242 243 private: 240 244 /** 241 245 @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. … … 295 299 class ClassIdentifier : public Identifier 296 300 { 301 #define SUPER_INTRUSIVE_DECLARATION 302 #include "Super.h" 303 297 304 public: 298 305 static ClassIdentifier<T> *getIdentifier(); … … 311 318 312 319 private: 313 ClassIdentifier() {} 320 ClassIdentifier() 321 { 322 #define SUPER_INTRUSIVE_CONSTRUCTOR 323 #include "Super.h" 324 } 314 325 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 315 326 ~ClassIdentifier() {} // don't delete -
code/branches/core3/src/orxonox/objects/BillboardProjectile.cc
r1559 r1676 48 48 this->scale(0.5); 49 49 } 50 51 std::cout << "a:\n"; 52 SUPER(BillboardProjectile, testfunction); 53 std::cout << "b:\n"; 50 54 } 51 55 … … 66 70 this->billboard_.setVisible(this->isVisible()); 67 71 } 72 73 void BillboardProjectile::testfunction() { SUPER(BillboardProjectile, testfunction); std::cout << "2 -> " << std::endl; } 68 74 } -
code/branches/core3/src/orxonox/objects/BillboardProjectile.h
r1558 r1676 46 46 virtual void setColour(const ColourValue& colour); 47 47 virtual void changedVisibility(); 48 virtual void testfunction(); 48 49 49 50 private: -
code/branches/core3/src/orxonox/objects/ParticleProjectile.cc
r1610 r1676 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/ConfigValueIncludes.h" 35 //#include "util/FastDelegate.h" 36 //using namespace fastdelegate; 37 35 38 namespace orxonox 36 39 { 37 40 CreateFactory(ParticleProjectile); 41 42 struct FunctionPointerViewer 43 { 44 void* ptr1_; 45 void* ptr2_; 46 47 void view() 48 { 49 std::cout << ptr1_ << "." << ptr2_ << std::endl; 50 } 51 }; 52 53 union FunctionPointerViewer1 54 { 55 FunctionPointerViewer viewer_; 56 void (Projectile::*function_) (); 57 }; 58 59 union FunctionPointerViewer2 60 { 61 FunctionPointerViewer viewer_; 62 void (BillboardProjectile::*function_) (); 63 }; 64 65 union FunctionPointerViewer3 66 { 67 FunctionPointerViewer viewer_; 68 void (ParticleProjectile::*function_) (); 69 }; 38 70 39 71 ParticleProjectile::ParticleProjectile(SpaceShip* owner) : BillboardProjectile(owner) … … 54 86 55 87 this->setConfigValues(); 88 /* 89 FunctionPointerViewer1 fpw1; 90 fpw1.function_ = &Projectile::testfunction; 91 FunctionPointerViewer2 fpw2; 92 fpw2.function_ = &BillboardProjectile::testfunction; 93 FunctionPointerViewer3 fpw3; 94 fpw3.function_ = &ParticleProjectile::testfunction; 95 96 std::cout << sizeof(void (Projectile::*) ()) << std::endl; 97 fpw1.viewer_.view(); 98 fpw2.viewer_.view(); 99 fpw3.viewer_.view(); 100 101 { 102 std::cout << "1:" << std::endl; 103 FastDelegate0<> delegate1(this, &ParticleProjectile::testfunction); 104 delegate1(); 105 FastDelegate0<> delegate2((BillboardProjectile*)this, &BillboardProjectile::testfunction); 106 delegate2(); 107 FastDelegate0<> delegate3(this, &Projectile::testfunction); 108 delegate3(); 109 } 110 { 111 std::cout << "2:" << std::endl; 112 BillboardProjectile temp; 113 // FastDelegate0<> delegate1(&temp, &ParticleProjectile::testfunction); 114 // delegate1(); 115 FastDelegate0<> delegate2(&temp, &BillboardProjectile::testfunction); 116 delegate2(); 117 FastDelegate0<> delegate3(&temp, &Projectile::testfunction); 118 delegate3(); 119 } 120 std::cout << "done" << std::endl; 121 122 std::cout << "0:" << std::endl; 123 this->Projectile::testfunction(); 124 this->BillboardProjectile::testfunction(); 125 this->ParticleProjectile::testfunction(); 126 this->testfunction(); 127 128 std::cout << "1:" << std::endl; 129 (this->*fpw1.function_)(); 130 std::cout << "2:" << std::endl; 131 (this->*fpw2.function_)(); 132 std::cout << "3:" << std::endl; 133 (this->*fpw3.function_)(); 134 std::cout << "done" << std::endl; 135 */ 136 std::cout << "c:\n"; 137 SUPER(ParticleProjectile, testfunction); 138 std::cout << "d:\n"; 139 140 std::cout << "e:\n"; 141 this->testfunction(); 142 std::cout << "f:\n"; 143 144 // (*((ClassIdentifier<SuperDummy>*)this->getIdentifier())->superFunctionCaller_testfunction_)(this); 56 145 } 57 146 … … 72 161 this->particles_->setEnabled(this->isVisible()); 73 162 } 163 164 void ParticleProjectile::testfunction() { SUPER(ParticleProjectile, testfunction); std::cout << "3 -> " << std::endl; } 74 165 } -
code/branches/core3/src/orxonox/objects/ParticleProjectile.h
r1597 r1676 44 44 virtual ~ParticleProjectile(); 45 45 virtual void changedVisibility(); 46 virtual void testfunction(); 46 47 void setConfigValues(); 47 48 -
code/branches/core3/src/orxonox/objects/Projectile.cc
r1610 r1676 121 121 delete this; 122 122 } 123 124 void Projectile::testfunction() { std::cout << "1 -> " << std::endl; } 123 125 } -
code/branches/core3/src/orxonox/objects/Projectile.h
r1596 r1676 34 34 #include "WorldEntity.h" 35 35 #include "tools/Timer.h" 36 #undef SUPER_INTRUSIVE 37 #include "core/Super.h" 36 38 37 39 namespace orxonox … … 45 47 void destroyObject(); 46 48 virtual void tick(float dt); 49 virtual void testfunction(); 47 50 48 51 static float getSpeed() … … 64 67 Timer<Projectile> destroyTimer_; 65 68 }; 69 70 // Partially specialized template (templatehack is now specialized too) 71 template <class T> 72 struct SuperFunctionCondition<0, 0, T> 73 { 74 // Checks if class U isA baseclass and sets the functionpointer if the check returned true 75 static void check() 76 { 77 std::cout << "check superfunction \"testfunction\" in " << ClassIdentifier<T>::getIdentifier()->getName() << std::endl; 78 79 T* temp; 80 SuperFunctionCondition<0, 0, T>::apply(temp); 81 82 std::cout << "done" << std::endl; 83 84 // Calls the condition of the next super-function 85 SuperFunctionCondition<0 + 1, 0, T>::check(); 86 } 87 88 static void apply(void* temp) 89 { 90 std::cout << ClassIdentifier<T>::getIdentifier()->getName() << " is not a Projectile" << std::endl; 91 // nop 92 } 93 94 static void apply(Projectile* temp) 95 { 96 std::cout << ClassIdentifier<T>::getIdentifier()->getName() << " is a Projectile" << std::endl; 97 ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); 98 99 SuperFunctionCaller_testfunction* superFunctionCaller = 0; 100 // Search for an existing caller within all direct children 101 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) 102 if (((ClassIdentifier<T>*)(*it))->superFunctionCaller_testfunction_) 103 superFunctionCaller = ((ClassIdentifier<T>*)(*it))->superFunctionCaller_testfunction_; 104 // Check if we've found an existing caller - if not, create a new one 105 if (!superFunctionCaller) 106 superFunctionCaller = new SuperFunctionClassCaller_testfunction<T>; 107 // Iterate through all children and assign the caller 108 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) 109 { 110 if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_testfunction_) 111 { 112 std::cout << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; 113 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_testfunction_ = superFunctionCaller; 114 } 115 } 116 } 117 }; 66 118 } 67 119
Note: See TracChangeset
for help on using the changeset viewer.