Changeset 7105 for code/branches/presentation3
- Timestamp:
- Jun 3, 2010, 2:24:14 AM (14 years ago)
- Location:
- code/branches/presentation3/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/libraries/core/BaseObject.cc
r6926 r7105 196 196 { 197 197 this->templates_.insert(temp); 198 if( temp->isLink() ) 199 { 200 this->networkTemplateNames_.insert(temp->getLink()); 201 assert( !Template::getTemplate(temp->getLink())->isLink() ); 202 } 203 else 204 this->networkTemplateNames_.insert(temp->getName()); 198 205 temp->applyOn(this); 199 206 } -
code/branches/presentation3/src/libraries/core/BaseObject.h
r6926 r7105 191 191 EventState* getEventState(const std::string& name) const; 192 192 193 std::string name_; //!< The name of the object 194 std::string oldName_; //!< The old name of the object 195 mbool bActive_; //!< True = the object is active 196 mbool bVisible_; //!< True = the object is visible 197 std::string mainStateName_; 198 Functor* mainStateFunctor_; 193 std::string name_; //!< The name of the object 194 std::string oldName_; //!< The old name of the object 195 mbool bActive_; //!< True = the object is active 196 mbool bVisible_; //!< True = the object is visible 197 std::string mainStateName_; 198 Functor* mainStateFunctor_; 199 std::set<std::string> networkTemplateNames_; 199 200 200 201 private: -
code/branches/presentation3/src/libraries/core/Template.h
r6938 r7105 51 51 inline const std::string& getLink() const 52 52 { return this->link_; } 53 inline bool isLink() const 54 { return this->bIsLink_; } 53 55 54 56 inline void setLoadDefaults(bool bLoadDefaults) -
code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.h
r6417 r7105 37 37 #include <map> 38 38 #include <queue> 39 #include <set> 39 40 40 41 #include "util/mbool.h" … … 138 139 Synchronisable(BaseObject* creator); 139 140 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false); 141 template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false); 140 142 141 143 void setPriority(unsigned int freq){ objectFrequency_ = freq; } … … 181 183 } 182 184 } 185 186 template <class T> void Synchronisable::registerVariable( std::set<T>& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 187 { 188 SynchronisableVariableBase* sv; 189 if (bidirectional) 190 sv = new SynchronisableVariableBidirectional<std::set<T> >(variable, mode, cb); 191 else 192 sv = new SynchronisableVariable<std::set<T> >(variable, mode, cb); 193 syncList.push_back(sv); 194 stringList.push_back(sv); 195 } 183 196 184 197 template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional); 198 // template <class T> _NetworkExport void Synchronisable::registerVariable<std::set<T> >( std::set<T>& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional); 185 199 186 200 -
code/branches/presentation3/src/libraries/util/Serialise.h
r6746 r7105 38 38 39 39 #include <cstring> 40 #include <set> 40 41 #include "Math.h" 41 42 #include "mbool.h" … … 635 636 return checkEquality( (unsigned char&)((mbool&)variable).getMemory(), mem ); 636 637 } 638 639 // =========== std::set 640 641 template <class T> inline uint32_t returnSize( const std::set<T>& variable ) 642 { 643 uint32_t tempsize = sizeof(uint32_t); // for the number of entries 644 for( typename std::set<T>::iterator it=((std::set<T>*)(&variable))->begin(); it!=((std::set<T>*)(&variable))->end(); ++it) 645 tempsize += returnSize( *it ); 646 return tempsize; 647 } 648 649 template <class T> inline void saveAndIncrease( const std::set<T>& variable, uint8_t*& mem ) 650 { 651 typename std::set<T>::const_iterator it = variable.begin(); 652 saveAndIncrease( (uint32_t)variable.size(), mem ); 653 for( ; it!=variable.end(); ++it ) 654 saveAndIncrease( *it, mem ); 655 } 656 657 template <class T> inline void loadAndIncrease( const std::set<T>& variable, uint8_t*& mem ) 658 { 659 uint32_t nrOfElements = 0; 660 loadAndIncrease( nrOfElements, mem ); 661 typename std::set<T>::const_iterator it = variable.begin(); 662 for( uint32_t i = 0; i<nrOfElements; ++i ) 663 { 664 T temp; 665 loadAndIncrease(temp, mem); 666 while( it!=variable.end() && *it!=temp ) 667 { 668 ((std::set<T>*)(&variable))->erase(it++); 669 ++it; 670 } 671 if( it==variable.end() ) 672 { 673 ((std::set<T>*)(&variable))->insert(temp); 674 } 675 } 676 } 677 678 template <class T> inline bool checkEquality( const std::set<T>& variable, uint8_t* mem ) 679 { 680 uint8_t* temp = mem; 681 uint32_t nrOfElements; 682 loadAndIncrease(nrOfElements, mem); 683 if( variable.size() == nrOfElements ) 684 { 685 T tempT; 686 for( uint32_t i=0; i<nrOfElements; ++i ) 687 { 688 loadAndIncrease(tempT, mem); 689 if( variable.find(tempT) == variable.end() ) 690 { 691 mem = temp; 692 return false; 693 } 694 } 695 } 696 else 697 { 698 mem = temp; 699 return false; 700 } 701 return true; 702 } 637 703 } 638 704 -
code/branches/presentation3/src/orxonox/Level.cc
r7036 r7105 80 80 void Level::registerVariables() 81 81 { 82 registerVariable(this->xmlfilename_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile)); 83 registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::changedName)); 84 registerVariable(this->description_, VariableDirection::ToClient); 82 registerVariable(this->xmlfilename_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile)); 83 registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::changedName)); 84 registerVariable(this->description_, VariableDirection::ToClient); 85 registerVariable(this->networkTemplateNames_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::networkCallbackTemplatesChanged)); 85 86 } 86 87 … … 97 98 98 99 Loader::open(this->xmlfile_); 100 } 101 102 void Level::networkCallbackTemplatesChanged() 103 { 104 for( std::set<std::string>::iterator it = this->networkTemplateNames_.begin(); it!=this->networkTemplateNames_.end(); ++it ) 105 { 106 assert(Template::getTemplate(*it)); 107 Template::getTemplate(*it)->applyOn(this); 108 } 99 109 } 100 110 -
code/branches/presentation3/src/orxonox/Level.h
r7039 r7105 66 66 67 67 void addLodInfo(MeshLodInformation* object); 68 void networkCallbackTemplatesChanged(); 68 69 // const MeshLodInformation* getLodInfo(std::string meshName) const; 69 70 // MeshLodInformation* getLodInfo(unsigned int index) const; -
code/branches/presentation3/src/orxonox/Test.cc
r6417 r7105 88 88 void Test::registerVariables() 89 89 { 90 registerVariable ( u1, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::checkU1 )); 91 registerVariable ( u2, VariableDirection::ToServer, new NetworkCallback<Test> ( this, &Test::checkU2 )); 92 registerVariable ( u3, Bidirectionality::ServerMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true ); 93 registerVariable ( u4, Bidirectionality::ClientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true ); 90 registerVariable ( this->mySet_, VariableDirection::ToClient ); 91 92 // registerVariable ( u1, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::checkU1 )); 93 // registerVariable ( u2, VariableDirection::ToServer, new NetworkCallback<Test> ( this, &Test::checkU2 )); 94 // registerVariable ( u3, Bidirectionality::ServerMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true ); 95 // registerVariable ( u4, Bidirectionality::ClientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true ); 94 96 95 registerVariable ( s1, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::checkS1 ));96 registerVariable ( s2, VariableDirection::ToServer, new NetworkCallback<Test> ( this, &Test::checkS2 ));97 registerVariable ( s3, Bidirectionality::ServerMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );98 registerVariable ( s4, Bidirectionality::ClientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );97 // registerVariable ( s1, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::checkS1 )); 98 // registerVariable ( s2, VariableDirection::ToServer, new NetworkCallback<Test> ( this, &Test::checkS2 )); 99 // registerVariable ( s3, Bidirectionality::ServerMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true ); 100 // registerVariable ( s4, Bidirectionality::ClientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true ); 99 101 100 registerVariable ( pointer_, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::printPointer ) );102 // registerVariable ( pointer_, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::printPointer ) ); 101 103 } 102 104 -
code/branches/presentation3/src/orxonox/Test.h
r6417 r7105 35 35 #include "tools/interfaces/Tickable.h" 36 36 37 #include <set> 37 38 38 39 typedef int TYPE; … … 78 79 void printPointer(); 79 80 80 static void printV1(){ instance_-> checkU1(); }81 static void printV2(){ instance_-> checkU2(); }81 static void printV1(){ instance_->blub(); } 82 static void printV2(){ instance_->blub2(); } 82 83 static void printV3(){ instance_->checkU3(); } 83 84 static void printV4(){ instance_->checkU4(); } … … 97 98 98 99 Test* pointer_; 100 101 std::set<uint32_t> mySet_; 99 102 100 103 static Test* instance_; 104 105 void blub() 106 { mySet_.insert(2); } 107 108 void blub2() 109 { for( std::set<uint32_t>::iterator it=mySet_.begin(); it!=mySet_.end(); ++it ) COUT(0) << *it << endl; } 101 110 }; 102 111 }
Note: See TracChangeset
for help on using the changeset viewer.