[Orxonox-commit 887] r5610 - in code/branches/resource2: cmake src/core src/network src/network/packet src/network/synchronisable src/util
rgrieder at orxonox.net
rgrieder at orxonox.net
Wed Aug 5 17:15:35 CEST 2009
Author: rgrieder
Date: 2009-08-05 17:15:35 +0200 (Wed, 05 Aug 2009)
New Revision: 5610
Modified:
code/branches/resource2/cmake/ParseMacroArguments.cmake
code/branches/resource2/src/core/ClassFactory.h
code/branches/resource2/src/core/Factory.cc
code/branches/resource2/src/core/Factory.h
code/branches/resource2/src/network/CMakeLists.txt
code/branches/resource2/src/network/packet/CMakeLists.txt
code/branches/resource2/src/network/synchronisable/CMakeLists.txt
code/branches/resource2/src/util/CMakeLists.txt
Log:
Improved CMake performance for runs after the first one.
There are some optimisations in the macro argument parser and I manually added the header files for util and network (since they don't change too much and it still compiles with a missing header files).
Modified: code/branches/resource2/cmake/ParseMacroArguments.cmake
===================================================================
--- code/branches/resource2/cmake/ParseMacroArguments.cmake 2009-08-02 19:07:41 UTC (rev 5609)
+++ code/branches/resource2/cmake/ParseMacroArguments.cmake 2009-08-05 15:15:35 UTC (rev 5610)
@@ -35,42 +35,52 @@
#
MACRO(PARSE_MACRO_ARGUMENTS _switches _list_names)
+
+ # Using LIST(FIND ...) speeds up the process
+ SET(_keywords ${_switches} ${_list_names})
+
# Parse all the arguments and set the corresponding variable
# If the option is just a switch, set the variable to its name for later use
FOREACH(_arg ${ARGN})
- SET(_arg_found FALSE)
- # Switches
- FOREACH(_switch ${_switches})
- IF(${_switch} STREQUAL ${_arg})
- SET(_arg_${_switch} ${_switch})
- SET(_arg_found TRUE)
- # Avoid interpreting arguments after this one as options args for the previous one
- SET(_storage_var)
- BREAK()
- ENDIF()
- ENDFOREACH(_switch)
+ # Is the argument a keyword?
+ LIST(FIND _keywords ${_arg} _keyword_index)
+ IF(NOT _keyword_index EQUAL -1)
- # Input options
- IF(NOT _arg_found)
- FOREACH(_list_name ${_list_names})
- IF(${_list_name} STREQUAL ${_arg})
- SET(_storage_var _arg_${_list_name})
- SET(_arg_found TRUE)
+ # Another optimisation
+ SET(_arg_found FALSE)
+ # Switches
+ FOREACH(_switch ${_switches})
+ IF(${_switch} STREQUAL ${_arg})
+ SET(_arg_${_switch} ${_switch})
+ SET(_arg_found TRUE)
+ # Avoid interpreting arguments after this one as options args for the previous one
+ SET(_storage_var)
BREAK()
ENDIF()
- ENDFOREACH(_list_name)
- ENDIF(NOT _arg_found)
+ ENDFOREACH(_switch)
- # Arguments of an input option (like source files for SOURCE_FILES)
- IF(NOT _arg_found)
+ # Input options
+ IF(NOT _arg_found)
+ FOREACH(_list_name ${_list_names})
+ IF(${_list_name} STREQUAL ${_arg})
+ SET(_storage_var _arg_${_list_name})
+ BREAK()
+ ENDIF()
+ ENDFOREACH(_list_name)
+ ENDIF(NOT _arg_found)
+
+ ELSE()
+
+ # Arguments of an input option (like source files for SOURCE_FILES)
IF(_storage_var)
# Store in variable define above in the foreach loop
SET(${_storage_var} ${${_storage_var}} ${_arg})
ELSE()
MESSAGE(FATAL_ERROR "ORXONOX_ADD_${_target_type} was given a non compliant argument: ${_arg}")
ENDIF(_storage_var)
- ENDIF(NOT _arg_found)
+ ENDIF()
+
ENDFOREACH(_arg)
ENDMACRO(PARSE_MACRO_ARGUMENTS)
Modified: code/branches/resource2/src/core/ClassFactory.h
===================================================================
--- code/branches/resource2/src/core/ClassFactory.h 2009-08-02 19:07:41 UTC (rev 5609)
+++ code/branches/resource2/src/core/ClassFactory.h 2009-08-05 15:15:35 UTC (rev 5610)
@@ -53,16 +53,20 @@
template <class T>
class ClassFactory : public BaseFactory
{
+ friend class Factory;
+
public:
static bool create(const std::string& name, bool bLoadable = true);
BaseObject* fabricate(BaseObject* creator);
private:
- ClassFactory() {} // Don't create
- ClassFactory(const ClassFactory& factory) {} // Don't copy
+ ClassFactory(bool bLoadable) : bLoadable_(bLoadable) {}
+ ClassFactory(const ClassFactory& factory); // Don't copy
virtual ~ClassFactory() {} // Don't delete
- static T* createNewObject(BaseObject* creator);
+ Identifier* createIdentifier(const std::string& name);
+
+ bool bLoadable_;
};
/**
@@ -75,9 +79,7 @@
bool ClassFactory<T>::create(const std::string& name, bool bLoadable)
{
COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
- ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>);
- ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
- Factory::add(name, ClassIdentifier<T>::getIdentifier());
+ Factory::add(name, new ClassFactory<T>(bLoadable));
return true;
}
@@ -89,17 +91,18 @@
template <class T>
inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
{
- return ClassFactory<T>::createNewObject(creator);
+ return new T(creator);
}
/**
- @brief Creates and returns a new object of class T; this is a wrapper for the new operator.
- @return The new object
*/
template <class T>
- inline T* ClassFactory<T>::createNewObject(BaseObject* creator)
+ inline Identifier* ClassFactory<T>::createIdentifier(const std::string& name)
{
- return new T(creator);
+ Identifier* identifier = ClassIdentifier<T>::getIdentifier(name);
+ identifier->addFactory(this);
+ identifier->setLoadable(this->bLoadable_);
+ return identifier;
}
}
Modified: code/branches/resource2/src/core/Factory.cc
===================================================================
--- code/branches/resource2/src/core/Factory.cc 2009-08-02 19:07:41 UTC (rev 5609)
+++ code/branches/resource2/src/core/Factory.cc 2009-08-05 15:15:35 UTC (rev 5610)
@@ -72,10 +72,9 @@
@param name The name of the identifier
@param identifier The identifier to add
*/
- void Factory::add(const std::string& name, Identifier* identifier)
+ void Factory::add(const std::string& name, BaseFactory* factory)
{
- getFactoryPointer()->identifierStringMap_[name] = identifier;
- getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
+ getFactoryPointer()->factoryMap_[name] = factory;
}
/**
@@ -104,16 +103,20 @@
void Factory::createClassHierarchy()
{
COUT(3) << "*** Factory: Create class-hierarchy" << std::endl;
- std::map<std::string, Identifier*>::iterator it;
- it = getFactoryPointer()->identifierStringMap_.begin();
- (*getFactoryPointer()->identifierStringMap_.begin()).second->startCreatingHierarchy();
- for (it = getFactoryPointer()->identifierStringMap_.begin(); it != getFactoryPointer()->identifierStringMap_.end(); ++it)
+ std::map<std::string, BaseFactory*>::iterator it;
+ it = getFactoryPointer()->factoryMap_.begin();
+ Identifier::startCreatingHierarchy();
+ for (it = getFactoryPointer()->factoryMap_.begin(); it != getFactoryPointer()->factoryMap_.end(); ++it)
{
+ // Create the corresponding identifier first
+ Identifier* identifier = it->second->createIdentifier(it->first);
+ getFactoryPointer()->identifierStringMap_[it->first] = identifier;
+ getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
// To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
- BaseObject* temp = (*it).second->fabricate(0);
+ BaseObject* temp = identifier->fabricate(0);
delete temp;
}
- (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy();
+ Identifier::stopCreatingHierarchy();
COUT(3) << "*** Factory: Finished class-hierarchy creation" << std::endl;
}
Modified: code/branches/resource2/src/core/Factory.h
===================================================================
--- code/branches/resource2/src/core/Factory.h 2009-08-02 19:07:41 UTC (rev 5609)
+++ code/branches/resource2/src/core/Factory.h 2009-08-05 15:15:35 UTC (rev 5610)
@@ -60,7 +60,7 @@
public:
static Identifier* getIdentifier(const std::string& name);
static Identifier* getIdentifier(const uint32_t id);
- static void add(const std::string& name, Identifier* identifier);
+ static void add(const std::string& name, BaseFactory* factory);
static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);
static void cleanNetworkIDs();
static void createClassHierarchy();
@@ -68,7 +68,7 @@
static Factory* getFactoryPointer(); // avoid overriding order problem in the static intialisation process
/** @brief Returns the factory-map. */
- static const std::map<std::string, Identifier*>& getFacbtoryMap()
+ static const std::map<std::string, Identifier*>& getFactoryMap()
{ return Factory::getFactoryPointer()->identifierStringMap_; }
/** @brief Returns the begin-iterator of the factory-map. */
static std::map<std::string, Identifier*>::const_iterator getFactoryMapBegin()
@@ -84,6 +84,7 @@
std::map<std::string, Identifier*> identifierStringMap_; //!< The map, mapping the name with the Identifier
std::map<uint32_t, Identifier*> identifierNetworkIDMap_; //!< The map, mapping the network ID with the Identifier
+ std::map<std::string, BaseFactory*> factoryMap_;
};
// ###############################
@@ -94,6 +95,7 @@
{
public:
virtual BaseObject* fabricate(BaseObject* creator) = 0;
+ virtual Identifier* createIdentifier(const std::string& name) = 0;
virtual ~BaseFactory() {};
};
}
Modified: code/branches/resource2/src/network/CMakeLists.txt
===================================================================
--- code/branches/resource2/src/network/CMakeLists.txt 2009-08-02 19:07:41 UTC (rev 5609)
+++ code/branches/resource2/src/network/CMakeLists.txt 2009-08-05 15:15:35 UTC (rev 5610)
@@ -34,11 +34,31 @@
ServerConnection.cc
TrafficControl.cc
)
+
+SET_SOURCE_FILES(NETWORK_HDR_FILES
+ ChatListener.h
+ Client.h
+ ClientConnection.h
+ ClientConnectionListener.h
+ ClientInformation.h
+ Connection.h
+ FunctionCallManager.h
+ GamestateClient.h
+ GamestateHandler.h
+ GamestateManager.h
+ Host.h
+ NetworkFunction.h
+ NetworkPrecompiledHeaders.h
+ NetworkPrereqs.h
+ Server.h
+ ServerConnection.h
+ TrafficControl.h
+)
+
ADD_SUBDIRECTORY(packet)
ADD_SUBDIRECTORY(synchronisable)
ORXONOX_ADD_LIBRARY(network
- FIND_HEADER_FILES
DEFINE_SYMBOL
"NETWORK_SHARED_BUILD"
PCH_FILE
@@ -50,5 +70,5 @@
util
core
SOURCE_FILES
- ${NETWORK_SRC_FILES}
+ ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES}
)
Modified: code/branches/resource2/src/network/packet/CMakeLists.txt
===================================================================
--- code/branches/resource2/src/network/packet/CMakeLists.txt 2009-08-02 19:07:41 UTC (rev 5609)
+++ code/branches/resource2/src/network/packet/CMakeLists.txt 2009-08-05 15:15:35 UTC (rev 5610)
@@ -1,5 +1,4 @@
ADD_SOURCE_FILES(NETWORK_SRC_FILES
- Packet.cc
Acknowledgement.cc
Chat.cc
ClassID.cc
@@ -7,5 +6,19 @@
FunctionIDs.cc
FunctionCalls.cc
Gamestate.cc
+ Packet.cc
Welcome.cc
)
+
+ADD_SOURCE_FILES(NETWORK_HDR_FILES
+ Acknowledgement.h
+ Chat.cc
+ Chat.h
+ ClassID.h
+ DeleteObjects.h
+ FunctionCalls.h
+ FunctionIDs.h
+ Gamestate.h
+ Packet.h
+ Welcome.h
+)
Modified: code/branches/resource2/src/network/synchronisable/CMakeLists.txt
===================================================================
--- code/branches/resource2/src/network/synchronisable/CMakeLists.txt 2009-08-02 19:07:41 UTC (rev 5609)
+++ code/branches/resource2/src/network/synchronisable/CMakeLists.txt 2009-08-05 15:15:35 UTC (rev 5610)
@@ -4,3 +4,10 @@
SynchronisableSpecialisations.cc
SynchronisableVariable.cc
)
+
+ADD_SOURCE_FILES(NETWORK_HDR_FILES
+ NetworkCallback.h
+ NetworkCallbackManager.h
+ Synchronisable.h
+ SynchronisableVariable.h
+)
Modified: code/branches/resource2/src/util/CMakeLists.txt
===================================================================
--- code/branches/resource2/src/util/CMakeLists.txt 2009-08-02 19:07:41 UTC (rev 5609)
+++ code/branches/resource2/src/util/CMakeLists.txt 2009-08-05 15:15:35 UTC (rev 5610)
@@ -32,17 +32,47 @@
SubString.cc
)
+SET_SOURCE_FILES(UTIL_HDR_FILES
+ CRC32.h
+ Clipboard.h
+ Convert.h
+ Debug.h
+ Exception.h
+ ExprParser.h
+ Math.h
+ MathConvert.h
+ mbool.h
+ MultiType.h
+ MultiTypeValue.h
+ OgreForwardRefs.h
+ OrxAssert.h
+ OrxEnum.h
+ OutputBuffer.h
+ OutputHandler.h
+ RefToValue.h
+ ScopeGuard.h
+ Serialise.h
+ SignalHandler.h
+ Singleton.h
+ Sleep.h
+ StringUtils.h
+ SubString.h
+ TemplateUtils.h
+ TypeTraits.h
+ UTFStringConversions.h
+ UtilPrereqs.h
+)
+
IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
# Get around displaying a few hundred lines of warning code
SET_SOURCE_FILES_PROPERTIES(MultiType.cc PROPERTIES COMPILE_FLAGS "-w")
ENDIF()
ORXONOX_ADD_LIBRARY(util
- FIND_HEADER_FILES
DEFINE_SYMBOL
"UTIL_SHARED_BUILD"
LINK_LIBRARIES
${OGRE_LIBRARY}
SOURCE_FILES
- ${UTIL_SRC_FILES}
+ ${UTIL_SRC_FILES} ${UTIL_HDR_FILES}
)
More information about the Orxonox-commit
mailing list