Changeset 1940
- Timestamp:
- Oct 18, 2008, 10:58:46 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src
- Files:
-
- 15 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/BaseObject.h
r1841 r1940 93 93 inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; } 94 94 95 pr ivate:95 protected: 96 96 std::string name_; //!< The name of the object 97 bool bInitialized_; //!< True if the object was initialized (passed the object registration)98 97 bool bActive_; //!< True = the object is active 99 98 bool bVisible_; //!< True = the object is visible 99 100 private: 101 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 100 102 const Level* level_; //!< The level that loaded this object 101 103 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader -
code/branches/objecthierarchy/src/core/ClassFactory.h
r1747 r1940 55 55 { 56 56 public: 57 static bool create(const std::string& name );57 static bool create(const std::string& name, bool bLoadable = true); 58 58 BaseObject* fabricate(); 59 59 … … 68 68 /** 69 69 @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory. 70 @param name The name of the class 71 @param bLoadable True if the class can be loaded through XML 70 72 @return Always true (this is needed because the compiler only allows assignments before main()) 71 73 */ 72 74 template <class T> 73 bool ClassFactory<T>::create(const std::string& name )75 bool ClassFactory<T>::create(const std::string& name, bool bLoadable) 74 76 { 75 77 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 76 78 ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>); 79 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); 77 80 Factory::add(name, ClassIdentifier<T>::getIdentifier()); 78 81 -
code/branches/objecthierarchy/src/core/CoreIncludes.h
r1856 r1940 98 98 */ 99 99 #define CreateFactory(ClassName) \ 100 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName) 100 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true) 101 102 /** 103 @brief Creates the entry in the Factory for classes which should not be loaded through XML. 104 @param ClassName The name of the class 105 */ 106 #define CreateUnloadableFactory(ClassName) \ 107 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false) 101 108 102 109 /** … … 111 118 @param String The name of the class 112 119 */ 113 #define ClassBy Name(String) \120 #define ClassByString(String) \ 114 121 orxonox::Factory::getIdentifier(String) 115 122 -
code/branches/objecthierarchy/src/core/Factory.cc
r1856 r1940 46 46 Identifier* Factory::getIdentifier(const std::string& name) 47 47 { 48 return getFactoryPointer()->identifierStringMap_[name]; 48 std::map<std::string, Identifier*>::const_iterator it = getFactoryPointer()->identifierStringMap_.find(name); 49 if (it != getFactoryPointer()->identifierStringMap_.end()) 50 return it->second; 51 else 52 return 0; 49 53 } 50 54 … … 56 60 Identifier* Factory::getIdentifier(const unsigned int id) 57 61 { 58 return getFactoryPointer()->identifierNetworkIDMap_[id]; 62 std::map<unsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id); 63 if (it != getFactoryPointer()->identifierNetworkIDMap_.end()) 64 return it->second; 65 else 66 return 0; 59 67 } 60 68 … … 68 76 getFactoryPointer()->identifierStringMap_[name] = identifier; 69 77 getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 78 std::cout << identifier->getName() << ": " << identifier->getNetworkID() << std::endl; 70 79 } 71 80 … … 80 89 getFactoryPointer()->identifierNetworkIDMap_.erase(oldID); 81 90 getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier; 91 std::cout << identifier->getName() << ": " << oldID << " -> " << newID << std::endl; 82 92 } 83 93 -
code/branches/objecthierarchy/src/core/Identifier.cc
r1856 r1940 59 59 this->bSetName_ = false; 60 60 this->factory_ = 0; 61 this->bLoadable_ = true; 61 62 62 63 this->bHasConfigValues_ = false; -
code/branches/objecthierarchy/src/core/Identifier.h
r1856 r1940 107 107 bool isDirectParentOf(const Identifier* identifier) const; 108 108 109 /** @brief Returns true if the class can be loaded through XML. */ 110 inline bool isLoadable() const { return this->bLoadable_; } 111 /** @brief Set the class to be loadable through XML or not. */ 112 inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; } 113 109 114 /** @brief Returns the list of all existing objects of this class. @return The list */ 110 115 inline ObjectListBase* getObjects() const … … 285 290 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 286 291 bool bSetName_; //!< True if the name is set 292 bool bLoadable_; //!< False = it's not permitted to load the object through XML 287 293 std::string name_; //!< The name of the class the Identifier belongs to 288 294 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) -
code/branches/objecthierarchy/src/core/XMLPort.h
r1889 r1940 468 468 for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++) 469 469 { 470 Identifier* identifier = ClassBy Name(child->Value());470 Identifier* identifier = ClassByString(child->Value()); 471 471 if (identifier) 472 472 { 473 473 if (identifier->isA(Class(O))) 474 474 { 475 if ( this->identifierIsIncludedInLoaderMask(identifier))475 if (identifier->isLoadable()) 476 476 { 477 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; 478 479 BaseObject* newObject = identifier->fabricate(); 480 newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " "); 481 newObject->setLevel(((BaseObject*)object)->getLevel()); 482 newObject->setNamespace(((BaseObject*)object)->getNamespace()); 483 484 if (this->bLoadBefore_) 477 if (this->identifierIsIncludedInLoaderMask(identifier)) 485 478 { 486 newObject->XMLPort(*child, XMLPort::LoadObject); 487 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 479 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; 480 481 BaseObject* newObject = identifier->fabricate(); 482 newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " "); 483 newObject->setLevel(((BaseObject*)object)->getLevel()); 484 newObject->setNamespace(((BaseObject*)object)->getNamespace()); 485 486 if (this->bLoadBefore_) 487 { 488 newObject->XMLPort(*child, XMLPort::LoadObject); 489 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 490 } 491 else 492 { 493 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 494 } 495 496 COUT(5) << ((BaseObject*)object)->getLoaderIndentation(); 497 (*this->loadexecutor_)(object, newObject); 498 499 if (!this->bLoadBefore_) 500 newObject->XMLPort(*child, XMLPort::LoadObject); 501 502 COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl; 488 503 } 489 else 490 { 491 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 492 } 493 494 COUT(5) << ((BaseObject*)object)->getLoaderIndentation(); 495 (*this->loadexecutor_)(object, newObject); 496 497 if (!this->bLoadBefore_) 498 newObject->XMLPort(*child, XMLPort::LoadObject); 499 500 COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl; 504 } 505 else 506 { 507 COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl; 501 508 } 502 509 } -
code/branches/objecthierarchy/src/network/CMakeLists.txt
r1938 r1940 22 22 23 23 IF(WIN32) 24 ADD_LIBRARY( network SHARED${NETWORK_SRC_FILES} )24 ADD_LIBRARY( network ${NETWORK_SRC_FILES} ) 25 25 ELSE(WIN32) 26 26 ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} ) -
code/branches/objecthierarchy/src/network/ClientConnectionListener.h
r1939 r1940 8 8 namespace network{ 9 9 10 class _NetworkExport ClientConnectionListener : public orxonox::OrxonoxClass10 class _NetworkExport ClientConnectionListener : virtual public orxonox::OrxonoxClass 11 11 { 12 friend class Server; 13 12 14 public: 13 15 ClientConnectionListener(); 16 virtual ~ClientConnectionListener() {} 14 17 15 18 void getConnectedClients(); 16 19 20 protected: 17 21 virtual void clientConnected(unsigned int clientID) = 0; 18 22 virtual void clientDisconnected(unsigned int clientID) = 0; -
code/branches/objecthierarchy/src/network/GamestateClient.cc
r1917 r1940 77 77 packet::Gamestate *processed = processGamestate(tempGamestate_); 78 78 // assert(processed); 79 if (!processed) 80 return false; 79 81 //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs 80 82 tempGamestate_=NULL; -
code/branches/objecthierarchy/src/network/Synchronisable.cc
r1907 r1940 51 51 namespace network 52 52 { 53 53 54 54 55 55 std::map<unsigned int, Synchronisable *> Synchronisable::objectMap_; … … 68 68 objectMode_=0x1; // by default do not send data to server 69 69 objectID=idCounter++; 70 classID = (unsigned int)-1; 70 71 syncList = new std::list<synchronisableVariable *>; 71 72 } 72 73 73 74 /** 74 * Destructor: 75 * Destructor: 75 76 * Delete all callback objects and remove objectID from the objectMap_ 76 77 */ … … 96 97 this->classID = this->getIdentifier()->getNetworkID(); 97 98 // COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl; 98 99 99 100 // COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl; 100 101 // objectMap_[objectID]=this; … … 145 146 } 146 147 147 148 148 149 /** 149 150 * Finds and deletes the Synchronisable with the appropriate objectID … … 164 165 return true; 165 166 } 166 167 167 168 /** 168 169 * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable … … 185 186 } 186 187 187 188 188 189 /** 189 190 * This function is used to register a variable to be synchronized … … 240 241 if(classID==0) 241 242 COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl; 243 244 if (this->classID == (unsigned int)-1) 245 this->classID = this->getIdentifier()->getNetworkID(); 246 242 247 assert(this->classID==this->getIdentifier()->getNetworkID()); 243 248 // this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this … … 314 319 assert(this->objectID==syncHeader->objectID); 315 320 // assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ? 316 321 317 322 COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl; 318 323 for(i=syncList->begin(); i!=syncList->end() && mem <= data+syncHeader->size; i++){ -
code/branches/objecthierarchy/src/network/Synchronisable.h
r1916 r1940 41 41 #include "util/Integers.h" 42 42 43 #define REGISTERDATA(varname ) registerVar(&varname, sizeof(varname), network::DATA)44 #define REGISTERDATA_WITHDIR(varname, mode) registerVar(&varname, sizeof(varname), network::DATA, mode)45 #define REGISTERSTRING(stringname ) registerVar(&stringname, stringname.length()+1, network::STRING)46 #define REGISTERSTRING_WITHDIR(stringname, mode) registerVar(&stringname, stringname.length()+1, network::STRING, mode)43 #define REGISTERDATA(varname, ...) \ 44 registerVar((void*)&varname, sizeof(varname), network::DATA, __VA_ARGS__) 45 #define REGISTERSTRING(stringname, ...) \ 46 registerVar(&stringname, stringname.length()+1, network::STRING, __VA_ARGS__) 47 47 48 48 namespace network … … 112 112 void setObjectMode(int mode); 113 113 void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; } 114 virtual void registerAllVariables()=0;115 114 116 115 -
code/branches/objecthierarchy/src/network/packet/Packet.cc
r1907 r1940 49 49 50 50 namespace packet{ 51 51 52 52 #define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE 53 53 #define _PACKETID 0 54 54 55 55 std::map<ENetPacket *, Packet *> Packet::packetMap_; 56 56 57 57 Packet::Packet(){ 58 58 flags_ = PACKET_FLAG_DEFAULT; … … 112 112 packetMap_[enetPacket_] = this; 113 113 } 114 #ifndef NDEBUG 114 #ifndef NDEBUG 115 115 switch( *(ENUM::Type *)(data_ + _PACKETID) ) 116 116 { -
code/branches/objecthierarchy/src/orxonox/CMakeLists.txt
r1916 r1940 42 42 tools/WindowEventListener.cc 43 43 44 objects/worldentities/WorldEntity.cc 45 objects/worldentities/PositionableEntity.cc 44 46 # objects/Backlight.cc 45 47 objects/Camera.cc … … 50 52 objects/RadarViewable.cc 51 53 objects/Tickable.cc 54 55 objects/infos/Info.cc 56 objects/infos/LevelInfo.cc 57 objects/infos/PlayerInfo.cc 58 59 objects/gametypes/Gametype.cc 52 60 53 61 tolua/tolua_bind.cc -
code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h
r1916 r1940 81 81 82 82 // objects 83 class WorldEntity; 84 class PositionableEntity; 85 class MovableEntity; 86 class ControllableEntity; 87 83 88 class Backlight; 84 89 class Camera; 85 90 class ParticleSpawner; 91 92 class Info; 93 class LevelInfo; 94 class PlayerInfo; 95 96 class Gametype; 86 97 87 98 // tools -
code/branches/objecthierarchy/src/orxonox/Settings.cc
r1907 r1940 52 52 , bHasServer_(false) 53 53 , bIsClient_(false) 54 , bIsStandalone_(false) 55 , bIsMaster_(false) 54 56 { 55 57 RegisterRootObject(Settings); -
code/branches/objecthierarchy/src/orxonox/Settings.h
r1907 r1940 54 54 friend class GSClient; 55 55 friend class GSDedicated; 56 friend class GSStandalone; 56 57 57 58 public: … … 65 66 static bool hasServer() { assert(singletonRef_s); return singletonRef_s->bHasServer_; } 66 67 static bool isClient() { assert(singletonRef_s); return singletonRef_s->bIsClient_; } 68 static bool isStandalone() { assert(singletonRef_s); return singletonRef_s->bIsStandalone_; } 69 static bool isMaster() { assert(singletonRef_s); return singletonRef_s->bIsMaster_; } 67 70 68 71 private: 69 72 // GSRoot has access to these 70 static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; } 71 static void setHasServer (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_ = val; } 72 static void setIsClient (bool val) { assert(singletonRef_s); singletonRef_s->bIsClient_ = val; } 73 static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; singletonRef_s->updateIsMaster(); } 74 static void setHasServer (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_ = val; singletonRef_s->updateIsMaster(); } 75 static void setIsClient (bool val) { assert(singletonRef_s); singletonRef_s->bIsClient_ = val; singletonRef_s->updateIsMaster(); } 76 static void setIsStandalone (bool val) { assert(singletonRef_s); singletonRef_s->bIsStandalone_ = val; singletonRef_s->updateIsMaster(); } 77 static void updateIsMaster () { assert(singletonRef_s); singletonRef_s->bIsMaster_ = (singletonRef_s->bHasServer_ || singletonRef_s->bIsStandalone_); } 73 78 74 79 Settings(); … … 85 90 bool bHasServer_; //!< global variable that tells whether this is a server 86 91 bool bIsClient_; 92 bool bIsStandalone_; 93 bool bIsMaster_; 87 94 88 95 std::string dataPath_; //!< Path to the game data -
code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.cc
r1907 r1940 51 51 void GSClient::enter() 52 52 { 53 Settings::_getInstance(). bIsClient_ = true;53 Settings::_getInstance().setIsClient(true); 54 54 55 55 GSLevel::enter(); … … 81 81 GSLevel::leave(); 82 82 83 Settings::_getInstance(). bIsClient_ = false;83 Settings::_getInstance().setIsClient(false); 84 84 } 85 85 -
code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.cc
r1790 r1940 57 57 void GSDedicated::enter() 58 58 { 59 Settings::_getInstance(). bHasServer_ = true;59 Settings::_getInstance().setHasServer(true); 60 60 61 61 // create Ogre SceneManager for the level … … 97 97 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 98 98 99 Settings::_getInstance(). bHasServer_ = false;99 Settings::_getInstance().setHasServer(false); 100 100 } 101 101 -
code/branches/objecthierarchy/src/orxonox/gamestates/GSGraphics.cc
r1891 r1940 101 101 void GSGraphics::enter() 102 102 { 103 Settings::_getInstance(). bShowsGraphics_ = true;103 Settings::_getInstance().setShowsGraphics(true); 104 104 105 105 // initialise graphics engine. Doesn't load the render window yet! … … 196 196 delete graphicsEngine_; 197 197 198 Settings::_getInstance(). bShowsGraphics_ = false;198 Settings::_getInstance().setShowsGraphics(false); 199 199 } 200 200 … … 221 221 this->console_->tick(dt); 222 222 this->tickChild(time); 223 223 224 224 unsigned long long timeAfterTick = time.getRealMicroseconds(); 225 225 -
code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.cc
r1910 r1940 52 52 void GSServer::enter() 53 53 { 54 Settings::_getInstance(). bHasServer_ = true;54 Settings::_getInstance().setHasServer(true); 55 55 56 56 GSLevel::enter(); … … 85 85 86 86 GSLevel::leave(); 87 88 Settings::_getInstance(). bHasServer_ = false;87 88 Settings::_getInstance().setHasServer(false); 89 89 } 90 90 -
code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.cc
r1755 r1940 32 32 #include "core/input/InputManager.h" 33 33 #include "core/ConsoleCommand.h" 34 #include "Settings.h" 34 35 35 36 namespace orxonox … … 57 58 // level is loaded: we can start capturing the input 58 59 InputManager::getInstance().requestEnterState("game"); 60 61 Settings::_getInstance().setIsStandalone(true); 59 62 } 60 63 … … 68 71 69 72 GSLevel::leave(); 73 74 Settings::_getInstance().setIsStandalone(false); 70 75 } 71 76
Note: See TracChangeset
for help on using the changeset viewer.