Changeset 1676 for code/branches/core3/src/orxonox/objects/Projectile.h
- Timestamp:
- Aug 28, 2008, 11:50:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.