Changeset 9629 for code/branches/core6/src/libraries
- Timestamp:
- Aug 9, 2013, 9:26:46 PM (11 years ago)
- Location:
- code/branches/core6/src/libraries
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/BaseObject.cc
r9590 r9629 55 55 @brief Constructor: Registers the object in the BaseObject-list. 56 56 */ 57 BaseObject::BaseObject( BaseObject* creator) : bInitialized_(false)57 BaseObject::BaseObject(Context* context) : bInitialized_(false) 58 58 { 59 59 RegisterRootObject(BaseObject); … … 70 70 this->mainStateFunctor_ = 0; 71 71 72 if (context) 73 this->setContext(context); 74 75 BaseObject* creator = orxonox_cast<BaseObject*>(context); 72 76 this->setCreator(creator); 73 77 if (this->creator_) … … 201 205 { 202 206 this->networkTemplateNames_.insert(temp->getLink()); 203 207 204 208 Template* link; 205 209 assert(!(link = Template::getTemplate(temp->getLink())) || !link->isLink()); -
code/branches/core6/src/libraries/core/BaseObject.h
r9607 r9629 65 65 66 66 public: 67 BaseObject( BaseObject* creator);67 BaseObject(Context* context); 68 68 virtual ~BaseObject(); 69 69 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); -
code/branches/core6/src/libraries/core/Loader.cc
r9557 r9629 209 209 210 210 orxout(verbose, context::loader) << " creating root-namespace..." << endl; 211 Namespace* rootNamespace = new Namespace( 0);211 Namespace* rootNamespace = new Namespace(Context::getRootContext()); 212 212 rootNamespace->setLoaderIndentation(" "); 213 213 rootNamespace->setFile(file); -
code/branches/core6/src/libraries/core/Namespace.cc
r7401 r9629 40 40 CreateFactory(Namespace); 41 41 42 Namespace::Namespace( BaseObject* creator) : BaseObject(creator),42 Namespace::Namespace(Context* context) : BaseObject(context), Context(context), 43 43 bAutogeneratedFileRootNamespace_(false), 44 44 bRoot_(false), -
code/branches/core6/src/libraries/core/Namespace.h
r7401 r9629 40 40 #include <string> 41 41 #include "BaseObject.h" 42 #include "object/Context.h" 42 43 43 44 namespace orxonox 44 45 { 45 class Namespace : public BaseObject 46 class Namespace : public BaseObject, public Context 46 47 { 47 48 public: 48 Namespace( BaseObject* creator);49 Namespace(Context* context); 49 50 virtual ~Namespace(); 50 51 -
code/branches/core6/src/libraries/core/Template.cc
r9564 r9629 40 40 CreateFactory(Template); 41 41 42 Template::Template( BaseObject* creator) : BaseObject(creator)42 Template::Template(Context* context) : BaseObject(context) 43 43 { 44 44 this->xmlelement_ = new TiXmlElement(""); -
code/branches/core6/src/libraries/core/Template.h
r7401 r9629 51 51 { 52 52 public: 53 Template( BaseObject* creator);53 Template(Context* context); 54 54 virtual ~Template(); 55 55 -
code/branches/core6/src/libraries/core/XMLPort.cc
r9564 r9629 89 89 orxout(verbose, context::xml) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << endl; 90 90 91 BaseObject* newObject = orxonox_cast<BaseObject*>(identifier->fabricate(object ));91 BaseObject* newObject = orxonox_cast<BaseObject*>(identifier->fabricate(object->getContext())); 92 92 newObject->setLoaderIndentation(object->getLoaderIndentation() + " "); 93 93 -
code/branches/core6/src/libraries/core/class/Identifier.cc
r9606 r9629 174 174 @return The new object 175 175 */ 176 OrxonoxClass* Identifier::fabricate( BaseObject* creator)176 OrxonoxClass* Identifier::fabricate(Context* context) 177 177 { 178 178 if (this->factory_) 179 179 { 180 return this->factory_->fabricate(c reator);180 return this->factory_->fabricate(context); 181 181 } 182 182 else -
code/branches/core6/src/libraries/core/class/Identifier.h
r9626 r9629 125 125 inline bool hasFactory() const { return (this->factory_ != 0); } 126 126 127 OrxonoxClass* fabricate( BaseObject* creator);127 OrxonoxClass* fabricate(Context* context); 128 128 129 129 /// Returns true if the class can be loaded through XML. -
code/branches/core6/src/libraries/core/class/SubclassIdentifier.h
r9563 r9629 163 163 164 164 /// Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T. 165 T* fabricate( BaseObject* creator) const166 { 167 OrxonoxClass* newObject = this->identifier_->fabricate(c reator);165 T* fabricate(Context* context) const 166 { 167 OrxonoxClass* newObject = this->identifier_->fabricate(context); 168 168 169 169 // Check if the creation was successful -
code/branches/core6/src/libraries/core/object/ClassFactory.h
r9602 r9629 55 55 public: 56 56 virtual ~Factory() {}; 57 virtual OrxonoxClass* fabricate( BaseObject* creator) = 0;57 virtual OrxonoxClass* fabricate(Context* context) = 0; 58 58 }; 59 59 … … 82 82 @return The new object 83 83 */ 84 inline OrxonoxClass* fabricate( BaseObject* creator)84 inline OrxonoxClass* fabricate(Context* context) 85 85 { 86 return static_cast<OrxonoxClass*>(new T(c reator));86 return static_cast<OrxonoxClass*>(new T(context)); 87 87 } 88 88 }; -
code/branches/core6/src/libraries/core/object/Context.cc
r9610 r9629 56 56 /*static*/ Context* Context::getRootContext() 57 57 { 58 static Context rootContext ;58 static Context rootContext(NULL); 59 59 return &rootContext; 60 60 } -
code/branches/core6/src/libraries/core/object/Context.h
r9610 r9629 48 48 static Context* getRootContext(); 49 49 50 Context(Context* context = NULL);50 Context(Context* context); 51 51 virtual ~Context(); 52 52 -
code/branches/core6/src/libraries/network/packet/Gamestate.cc
r9579 r9629 133 133 tempsize = it->getData(mem, this->sizes_, id, mode); 134 134 if ( tempsize != 0 ) 135 dataVector_.push_back( obj(it->getObjectID(), it->getC reatorID(), tempsize, mem-data_) );135 dataVector_.push_back( obj(it->getObjectID(), it->getContextID(), tempsize, mem-data_) ); 136 136 137 137 #ifndef NDEBUG … … 469 469 { 470 470 assert( objectHeader.getClassID() == htemp.getClassID() ); 471 assert( objectHeader.getC reatorID() == htemp.getCreatorID() );471 assert( objectHeader.getContextID() == htemp.getContextID() ); 472 472 return true; 473 473 } -
code/branches/core6/src/libraries/network/synchronisable/Synchronisable.cc
r9564 r9629 49 49 * Initializes all Variables and sets the right objectID_ 50 50 */ 51 Synchronisable::Synchronisable( BaseObject* creator)51 Synchronisable::Synchronisable(Context* context) 52 52 { 53 53 RegisterRootObject(Synchronisable); … … 69 69 this->setPriority( Priority::Normal ); 70 70 71 // get creator id 72 if( creator ) 73 this->creatorID_ = creator->getSceneID(); 74 else 75 this->creatorID_ = OBJECTID_UNKNOWN; 71 // get context id 72 this->contextID_ = this->findContextID(context); 76 73 } 77 74 … … 100 97 } 101 98 99 /** 100 * @brief Returns the id of the context. 101 * If the context is not Synchronisable, it moves on to its parent, recursively. 102 */ 103 uint32_t Synchronisable::findContextID(Context* context) 104 { 105 if (context == NULL) 106 return OBJECTID_UNKNOWN; 107 108 Synchronisable* synchronisableContext = orxonox_cast<Synchronisable*>(context); 109 if (synchronisableContext != NULL) 110 return synchronisableContext->getObjectID(); 111 else 112 return this->findContextID(context->getParentContext()); 113 } 102 114 103 115 /** … … 142 154 } 143 155 assert(id); 144 BaseObject* creator= 0;145 if (header.getC reatorID() != OBJECTID_UNKNOWN)146 { 147 Synchronisable* synchronisable_c reator = Synchronisable::getSynchronisable(header.getCreatorID());148 if (!synchronisable_c reator)156 Context* context = 0; 157 if (header.getContextID() != OBJECTID_UNKNOWN) 158 { 159 Synchronisable* synchronisable_context = Synchronisable::getSynchronisable(header.getContextID()); 160 if (!synchronisable_context) 149 161 { 150 162 mem += header.getDataSize()+SynchronisableHeader::getSize(); //.TODO: this suckz.... remove size from header … … 153 165 } 154 166 else 155 c reator = orxonox_cast<BaseObject*>(synchronisable_creator);167 context = orxonox_cast<Context*>(synchronisable_context); 156 168 } 157 169 assert(getSynchronisable(header.getObjectID())==0); //make sure no object with this id exists 158 BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(c reator));170 BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(context)); 159 171 assert(bo); 160 172 Synchronisable *no = orxonox_cast<Synchronisable*>(bo); … … 162 174 assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() ); 163 175 no->setObjectID(header.getObjectID()); 164 //no->c reatorID=header.getCreatorID(); //TODO: remove this176 //no->contextID=header.getContextID(); //TODO: remove this 165 177 no->setClassID(header.getClassID()); 166 assert(no->creatorID_ == header.getCreatorID()); 167 if( creator ) 168 bo->setLevel(creator->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself) 178 assert(no->contextID_ == header.getContextID()); 179 if( context ) 180 { 181 BaseObject* boContext = orxonox_cast<BaseObject*>(context); 182 if (boContext) 183 bo->setLevel(boContext->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself) 184 } 169 185 //assert(no->classID_ == header.getClassID()); 170 186 orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl; … … 274 290 275 291 header.setObjectID( this->objectID_ ); 276 header.setC reatorID( this->creatorID_ );292 header.setContextID( this->contextID_ ); 277 293 header.setClassID( this->classID_ ); 278 294 header.setDataSize( tempsize ); … … 331 347 SynchronisableHeader syncHeader2(mem); 332 348 assert( this->getClassID() == syncHeader2.getClassID() ); 333 assert( this->getC reatorID() == syncHeader2.getCreatorID() );349 assert( this->getContextID() == syncHeader2.getContextID() ); 334 350 mem += SynchronisableHeader::getSize(); 335 351 std::vector<SynchronisableVariableBase *>::iterator i; -
code/branches/core6/src/libraries/network/synchronisable/Synchronisable.h
r9587 r9629 107 107 * @brief: stores information about a Synchronisable 108 108 * 109 * This class stores the information about a Synchronisable (objectID_, classID_, c reatorID_, dataSize)109 * This class stores the information about a Synchronisable (objectID_, classID_, contextID_, dataSize) 110 110 * in an emulated bitset. 111 111 * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream … … 113 113 * Byte 5 to 8: objectID_ 114 114 * Byte 9 to 12: classID_ 115 * Byte 13 to 16: c reatorID_115 * Byte 13 to 16: contextID_ 116 116 */ 117 117 class _NetworkExport SynchronisableHeader: public SynchronisableHeaderLight … … 126 126 inline void setClassID(uint32_t classID_) 127 127 { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()) = classID_; } 128 inline uint32_t getC reatorID() const128 inline uint32_t getContextID() const 129 129 { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4); } 130 inline void setC reatorID(uint32_t creatorID_)131 { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = c reatorID_; }130 inline void setContextID(uint32_t contextID_) 131 { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = contextID_; } 132 132 inline void operator=(SynchronisableHeader& h) 133 133 { memcpy(data_, h.data_, getSize()); } … … 158 158 159 159 inline uint32_t getObjectID() const {return this->objectID_;} 160 inline unsigned int getC reatorID() const {return this->creatorID_;}160 inline unsigned int getContextID() const {return this->contextID_;} 161 161 inline uint32_t getClassID() const {return this->classID_;} 162 162 inline unsigned int getPriority() const { return this->objectFrequency_;} … … 170 170 171 171 protected: 172 Synchronisable( BaseObject* creator);172 Synchronisable(Context* context); 173 173 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false); 174 174 template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false); … … 176 176 177 177 void setPriority(unsigned int freq){ objectFrequency_ = freq; } 178 178 uint32_t findContextID(Context* context); 179 179 180 180 private: … … 189 189 190 190 uint32_t objectID_; 191 uint32_t c reatorID_;191 uint32_t contextID_; 192 192 uint32_t classID_; 193 193 -
code/branches/core6/src/libraries/tools/ResourceCollection.cc
r8858 r9629 39 39 CreateFactory(ResourceCollection); 40 40 41 ResourceCollection::ResourceCollection( BaseObject* creator)42 : BaseObject(c reator)41 ResourceCollection::ResourceCollection(Context* context) 42 : BaseObject(context) 43 43 { 44 44 RegisterObject(ResourceCollection); -
code/branches/core6/src/libraries/tools/ResourceCollection.h
r7401 r9629 41 41 { 42 42 public: 43 ResourceCollection( BaseObject* creator);43 ResourceCollection(Context* context); 44 44 virtual ~ResourceCollection(); 45 45 -
code/branches/core6/src/libraries/tools/ResourceLocation.cc
r8858 r9629 43 43 CreateFactory(ResourceLocation); 44 44 45 ResourceLocation::ResourceLocation( BaseObject* creator)46 : BaseObject(c reator)45 ResourceLocation::ResourceLocation(Context* context) 46 : BaseObject(context) 47 47 { 48 48 RegisterObject(ResourceLocation); -
code/branches/core6/src/libraries/tools/ResourceLocation.h
r7401 r9629 43 43 44 44 public: 45 ResourceLocation( BaseObject* creator);45 ResourceLocation(Context* context); 46 46 virtual ~ResourceLocation(); 47 47
Note: See TracChangeset
for help on using the changeset viewer.