Changeset 5610 for code/branches/resource2/src
- Timestamp:
- Aug 5, 2009, 5:15:35 PM (15 years ago)
- Location:
- code/branches/resource2/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource2/src/core/ClassFactory.h
r3196 r5610 54 54 class ClassFactory : public BaseFactory 55 55 { 56 friend class Factory; 57 56 58 public: 57 59 static bool create(const std::string& name, bool bLoadable = true); … … 59 61 60 62 private: 61 ClassFactory( ) {} // Don't create62 ClassFactory(const ClassFactory& factory) {}// Don't copy63 ClassFactory(bool bLoadable) : bLoadable_(bLoadable) {} 64 ClassFactory(const ClassFactory& factory); // Don't copy 63 65 virtual ~ClassFactory() {} // Don't delete 64 66 65 static T* createNewObject(BaseObject* creator); 67 Identifier* createIdentifier(const std::string& name); 68 69 bool bLoadable_; 66 70 }; 67 71 … … 76 80 { 77 81 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 78 ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>); 79 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); 80 Factory::add(name, ClassIdentifier<T>::getIdentifier()); 82 Factory::add(name, new ClassFactory<T>(bLoadable)); 81 83 82 84 return true; … … 90 92 inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator) 91 93 { 92 return ClassFactory<T>::createNewObject(creator);94 return new T(creator); 93 95 } 94 96 95 97 /** 96 @brief Creates and returns a new object of class T; this is a wrapper for the new operator.97 @return The new object98 98 */ 99 99 template <class T> 100 inline T* ClassFactory<T>::createNewObject(BaseObject* creator)100 inline Identifier* ClassFactory<T>::createIdentifier(const std::string& name) 101 101 { 102 return new T(creator); 102 Identifier* identifier = ClassIdentifier<T>::getIdentifier(name); 103 identifier->addFactory(this); 104 identifier->setLoadable(this->bLoadable_); 105 return identifier; 103 106 } 104 107 } -
code/branches/resource2/src/core/Factory.cc
r3196 r5610 73 73 @param identifier The identifier to add 74 74 */ 75 void Factory::add(const std::string& name, Identifier* identifier)75 void Factory::add(const std::string& name, BaseFactory* factory) 76 76 { 77 getFactoryPointer()->identifierStringMap_[name] = identifier; 78 getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 77 getFactoryPointer()->factoryMap_[name] = factory; 79 78 } 80 79 … … 105 104 { 106 105 COUT(3) << "*** Factory: Create class-hierarchy" << std::endl; 107 std::map<std::string, Identifier*>::iterator it;108 it = getFactoryPointer()-> identifierStringMap_.begin();109 (*getFactoryPointer()->identifierStringMap_.begin()).second->startCreatingHierarchy();110 for (it = getFactoryPointer()-> identifierStringMap_.begin(); it != getFactoryPointer()->identifierStringMap_.end(); ++it)106 std::map<std::string, BaseFactory*>::iterator it; 107 it = getFactoryPointer()->factoryMap_.begin(); 108 Identifier::startCreatingHierarchy(); 109 for (it = getFactoryPointer()->factoryMap_.begin(); it != getFactoryPointer()->factoryMap_.end(); ++it) 111 110 { 111 // Create the corresponding identifier first 112 Identifier* identifier = it->second->createIdentifier(it->first); 113 getFactoryPointer()->identifierStringMap_[it->first] = identifier; 114 getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 112 115 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 113 BaseObject* temp = (*it).second->fabricate(0);116 BaseObject* temp = identifier->fabricate(0); 114 117 delete temp; 115 118 } 116 (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy();119 Identifier::stopCreatingHierarchy(); 117 120 COUT(3) << "*** Factory: Finished class-hierarchy creation" << std::endl; 118 121 } -
code/branches/resource2/src/core/Factory.h
r2761 r5610 61 61 static Identifier* getIdentifier(const std::string& name); 62 62 static Identifier* getIdentifier(const uint32_t id); 63 static void add(const std::string& name, Identifier* identifier);63 static void add(const std::string& name, BaseFactory* factory); 64 64 static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID); 65 65 static void cleanNetworkIDs(); … … 69 69 70 70 /** @brief Returns the factory-map. */ 71 static const std::map<std::string, Identifier*>& getFac btoryMap()71 static const std::map<std::string, Identifier*>& getFactoryMap() 72 72 { return Factory::getFactoryPointer()->identifierStringMap_; } 73 73 /** @brief Returns the begin-iterator of the factory-map. */ … … 85 85 std::map<std::string, Identifier*> identifierStringMap_; //!< The map, mapping the name with the Identifier 86 86 std::map<uint32_t, Identifier*> identifierNetworkIDMap_; //!< The map, mapping the network ID with the Identifier 87 std::map<std::string, BaseFactory*> factoryMap_; 87 88 }; 88 89 … … 95 96 public: 96 97 virtual BaseObject* fabricate(BaseObject* creator) = 0; 98 virtual Identifier* createIdentifier(const std::string& name) = 0; 97 99 virtual ~BaseFactory() {}; 98 100 }; -
code/branches/resource2/src/network/CMakeLists.txt
r3304 r5610 35 35 TrafficControl.cc 36 36 ) 37 38 SET_SOURCE_FILES(NETWORK_HDR_FILES 39 ChatListener.h 40 Client.h 41 ClientConnection.h 42 ClientConnectionListener.h 43 ClientInformation.h 44 Connection.h 45 FunctionCallManager.h 46 GamestateClient.h 47 GamestateHandler.h 48 GamestateManager.h 49 Host.h 50 NetworkFunction.h 51 NetworkPrecompiledHeaders.h 52 NetworkPrereqs.h 53 Server.h 54 ServerConnection.h 55 TrafficControl.h 56 ) 57 37 58 ADD_SUBDIRECTORY(packet) 38 59 ADD_SUBDIRECTORY(synchronisable) 39 60 40 61 ORXONOX_ADD_LIBRARY(network 41 FIND_HEADER_FILES42 62 DEFINE_SYMBOL 43 63 "NETWORK_SHARED_BUILD" … … 51 71 core 52 72 SOURCE_FILES 53 ${NETWORK_SRC_FILES} 73 ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES} 54 74 ) -
code/branches/resource2/src/network/packet/CMakeLists.txt
r3084 r5610 1 1 ADD_SOURCE_FILES(NETWORK_SRC_FILES 2 Packet.cc3 2 Acknowledgement.cc 4 3 Chat.cc … … 8 7 FunctionCalls.cc 9 8 Gamestate.cc 9 Packet.cc 10 10 Welcome.cc 11 11 ) 12 13 ADD_SOURCE_FILES(NETWORK_HDR_FILES 14 Acknowledgement.h 15 Chat.cc 16 Chat.h 17 ClassID.h 18 DeleteObjects.h 19 FunctionCalls.h 20 FunctionIDs.h 21 Gamestate.h 22 Packet.h 23 Welcome.h 24 ) -
code/branches/resource2/src/network/synchronisable/CMakeLists.txt
r2710 r5610 5 5 SynchronisableVariable.cc 6 6 ) 7 8 ADD_SOURCE_FILES(NETWORK_HDR_FILES 9 NetworkCallback.h 10 NetworkCallbackManager.h 11 Synchronisable.h 12 SynchronisableVariable.h 13 ) -
code/branches/resource2/src/util/CMakeLists.txt
r3280 r5610 33 33 ) 34 34 35 SET_SOURCE_FILES(UTIL_HDR_FILES 36 CRC32.h 37 Clipboard.h 38 Convert.h 39 Debug.h 40 Exception.h 41 ExprParser.h 42 Math.h 43 MathConvert.h 44 mbool.h 45 MultiType.h 46 MultiTypeValue.h 47 OgreForwardRefs.h 48 OrxAssert.h 49 OrxEnum.h 50 OutputBuffer.h 51 OutputHandler.h 52 RefToValue.h 53 ScopeGuard.h 54 Serialise.h 55 SignalHandler.h 56 Singleton.h 57 Sleep.h 58 StringUtils.h 59 SubString.h 60 TemplateUtils.h 61 TypeTraits.h 62 UTFStringConversions.h 63 UtilPrereqs.h 64 ) 65 35 66 IF(GCC_NO_SYSTEM_HEADER_SUPPORT) 36 67 # Get around displaying a few hundred lines of warning code … … 39 70 40 71 ORXONOX_ADD_LIBRARY(util 41 FIND_HEADER_FILES42 72 DEFINE_SYMBOL 43 73 "UTIL_SHARED_BUILD" … … 45 75 ${OGRE_LIBRARY} 46 76 SOURCE_FILES 47 ${UTIL_SRC_FILES} 77 ${UTIL_SRC_FILES} ${UTIL_HDR_FILES} 48 78 )
Note: See TracChangeset
for help on using the changeset viewer.