Changeset 1486 for code/branches/network/src
- Timestamp:
- May 30, 2008, 3:02:03 PM (16 years ago)
- Location:
- code/branches/network/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/core/InputBuffer.cc
r1446 r1486 88 88 } 89 89 90 void InputBuffer::unregisterListener(InputBufferListener* listener)91 {92 for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )93 {94 if ((*it).listener_ == listener)95 this->listeners_.erase(it++);96 else97 ++it;98 }99 }100 101 90 void InputBuffer::set(const std::string& input, bool update) 102 91 { … … 165 154 void InputBuffer::updated() 166 155 { 167 for (std::list< InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)168 { 169 if ((*it) .bListenToAllChanges_)170 (* (*it).listener_.*(*it).function_)();156 for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 157 { 158 if ((*it)->bListenToAllChanges_) 159 (*it)->callFunction(); 171 160 } 172 161 } … … 174 163 void InputBuffer::updated(const char& update, bool bSingleInput) 175 164 { 176 for (std::list< InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)177 { 178 if ((!(*it) .trueKeyFalseChar_) && ((*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput))179 (* (*it).listener_.*(*it).function_)();165 for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 166 { 167 if ((!(*it)->trueKeyFalseChar_) && ((*it)->bListenToAllChanges_ || ((*it)->char_ == update)) && (!(*it)->bOnlySingleInput_ || bSingleInput)) 168 (*it)->callFunction(); 180 169 } 181 170 } … … 195 184 return; 196 185 197 for (std::list< InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)198 { 199 if ((*it) .trueKeyFalseChar_ && ((*it).key_ == evt.key))200 (* (*it).listener_.*(*it).function_)();186 for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 187 { 188 if ((*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.key)) 189 (*it)->callFunction(); 201 190 } 202 191 -
code/branches/network/src/core/InputBuffer.h
r1461 r1486 40 40 namespace orxonox 41 41 { 42 class _CoreExport InputBufferListener 43 {}; 42 class BaseInputBufferListenerTuple 43 { 44 public: 45 BaseInputBufferListenerTuple(bool bListenToAllChanges, bool bOnlySingleInput, 46 bool trueKeyFalseChar, char _char, KeyCode::Enum key) 47 : bListenToAllChanges_(bListenToAllChanges), bOnlySingleInput_(bOnlySingleInput), 48 trueKeyFalseChar_(trueKeyFalseChar), char_(_char), key_(key) 49 { } 50 virtual void callFunction() = 0; 51 bool bListenToAllChanges_; 52 bool bOnlySingleInput_; 53 bool trueKeyFalseChar_; 54 char char_; 55 KeyCode::Enum key_; 56 }; 57 58 template <class T> 59 class InputBufferListenerTuple : public BaseInputBufferListenerTuple 60 { 61 public: 62 InputBufferListenerTuple(T* listener, void (T::*function)(), bool bListenToAllChanges, 63 bool bOnlySingleInput, bool trueKeyFalseChar, char _char, KeyCode::Enum key) 64 : BaseInputBufferListenerTuple(bListenToAllChanges, bOnlySingleInput, trueKeyFalseChar, _char, key), 65 listener_(listener), function_(function) 66 { } 67 void InputBufferListenerTuple::callFunction() 68 { 69 (listener_->*function_)(); 70 } 71 T* listener_; 72 void (T::*function_)(); 73 }; 44 74 45 75 class _CoreExport InputBuffer : public KeyHandler, public OrxonoxClass 46 76 { 47 struct InputBufferListenerTuple48 {49 InputBufferListener* listener_;50 void (InputBufferListener::*function_)();51 bool bListenToAllChanges_;52 bool bOnlySingleInput_;53 bool trueKeyFalseChar_;54 char char_;55 KeyCode::Enum key_;56 };57 58 77 public: 59 78 InputBuffer(); … … 65 84 void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput) 66 85 { 67 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned}; 68 // TODO: this is a major hack!!! 69 // Fix it properly 70 *((int*)(&newListener.listener_)) = (int)(listener); 71 72 this->listeners_.insert(this->listeners_.end(), newListener); 86 InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned); 87 this->listeners_.insert(this->listeners_.end(), newTuple); 73 88 } 74 89 template <class T> 75 90 void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput) 76 91 { 77 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned}; 78 *((int*)(&newListener.listener_)) = (int)(listener); 79 this->listeners_.insert(this->listeners_.end(), newListener); 92 InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned); 93 this->listeners_.insert(this->listeners_.end(), newTuple); 80 94 } 81 82 95 template <class T> 83 96 void registerListener(T* listener, void (T::*function)(), char _char, bool bOnlySingleInput) 84 97 { 85 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned}; 86 *((int*)(&newListener.listener_)) = (int)(listener); 87 this->listeners_.insert(this->listeners_.end(), newListener); 98 InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned); 99 this->listeners_.insert(this->listeners_.end(), newTuple); 88 100 } 89 101 template <class T> 90 102 void registerListener(T* listener, void (T::*function)() const, char _char, bool bOnlySingleInput) 91 103 { 92 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned}; 93 *((int*)(&newListener.listener_)) = (int)(listener); 94 this->listeners_.insert(this->listeners_.end(), newListener); 104 InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned); 105 this->listeners_.insert(this->listeners_.end(), newTuple); 95 106 } 96 107 … … 98 109 void registerListener(T* listener, void (T::*function)(), KeyCode::Enum key) 99 110 { 100 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, true, true, '\0', key}; 101 *((int*)(&newListener.listener_)) = (int)(listener); 102 this->listeners_.insert(this->listeners_.end(), newListener); 111 InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key); 112 this->listeners_.insert(this->listeners_.end(), newTuple); 103 113 } 104 114 template <class T> 105 115 void registerListener(T* listener, void (T::*function)() const, KeyCode::Enum key) 106 116 { 107 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, true, true, '\0', key}; 108 *((int*)(&newListener.listener_)) = (int)(listener); 109 this->listeners_.insert(this->listeners_.end(), newListener); 117 InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key); 118 this->listeners_.insert(this->listeners_.end(), newTuple); 110 119 } 111 120 112 void unregisterListener(InputBufferListener* listener); 121 template <class T> 122 void unregisterListener(T* listener) 123 { 124 for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) 125 { 126 InputBufferListenerTuple<T>* refListener = dynamic_cast<InputBufferListenerTuple<T>*>(*it); 127 if (refListener && refListener->listener_ == listener) 128 this->listeners_.erase(it++); 129 else 130 it++; 131 } 132 } 113 133 114 134 void set(const std::string& input, bool update = true); … … 151 171 152 172 std::string buffer_; 153 std::list< InputBufferListenerTuple> listeners_;173 std::list<BaseInputBufferListenerTuple*> listeners_; 154 174 std::string allowedChars_; 155 175 unsigned int cursor_; -
code/branches/network/src/core/Shell.h
r1446 r1486 57 57 }; 58 58 59 class _CoreExport Shell : virtual public OrxonoxClass, public InputBufferListener, publicOutputBufferListener59 class _CoreExport Shell : virtual public OrxonoxClass, public OutputBufferListener 60 60 { 61 61 public: -
code/branches/network/src/orxonox/GraphicsEngine.cc
r1477 r1486 149 149 #endif 150 150 151 /* // create a logManager 151 // TODO: LogManager doesn't work on specific systems. The why is unknown yet. 152 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 153 // create a logManager 152 154 // note: If there's already a logManager, Ogre will complain by a failed assertation. 153 155 // but that shouldn't happen, since this is the first time to create a logManager.. … … 164 166 165 167 myLog->setLogDetail(Ogre::LL_BOREME); 166 myLog->addListener(this);*/ 168 myLog->addListener(this); 169 #endif 167 170 168 171 // Root will detect that we've already created a Log -
code/branches/network/src/orxonox/objects/Model.cc
r1466 r1486 85 85 86 86 //HACK!! 87 if ((this->meshSrc_ == "assff.mesh") || (this->meshSrc_ == "ast1.mesh") || (this->meshSrc_ == "ast2.mesh") || (this->meshSrc_ == "ast3.mesh") || (this->meshSrc_ == "ast4.mesh") ||(this->meshSrc_ == "ast5.mesh") || (this->meshSrc_ == "ast6.mesh"))87 /*if ((this->meshSrc_ == "assff.mesh") || (this->meshSrc_ == "ast1.mesh") || (this->meshSrc_ == "ast2.mesh") || (this->meshSrc_ == "ast3.mesh") || (this->meshSrc_ == "ast4.mesh") ||(this->meshSrc_ == "ast5.mesh") || (this->meshSrc_ == "ast6.mesh")) 88 88 { 89 89 Ogre::MeshPtr pMesh = this->mesh_.getEntity()->getMesh(); … … 104 104 105 105 106 } 106 }*/ 107 107 COUT(4) << "Loader (Model.cc): Created model" << std::endl; 108 108 }
Note: See TracChangeset
for help on using the changeset viewer.