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