Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5610


Ignore:
Timestamp:
Aug 5, 2009, 5:15:35 PM (15 years ago)
Author:
rgrieder
Message:

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).

Location:
code/branches/resource2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource2/cmake/ParseMacroArguments.cmake

    r3196 r5610  
    3636
    3737MACRO(PARSE_MACRO_ARGUMENTS _switches _list_names)
     38
     39  # Using LIST(FIND ...) speeds up the process
     40  SET(_keywords ${_switches} ${_list_names})
     41
    3842  # Parse all the arguments and set the corresponding variable
    3943  # If the option is just a switch, set the variable to its name for later use
    4044  FOREACH(_arg ${ARGN})
    41     SET(_arg_found FALSE)
    4245
    43     # Switches
    44     FOREACH(_switch ${_switches})
    45       IF(${_switch} STREQUAL ${_arg})
    46         SET(_arg_${_switch} ${_switch})
    47         SET(_arg_found TRUE)
    48         # Avoid interpreting arguments after this one as options args for the previous one
    49         SET(_storage_var)
    50         BREAK()
    51       ENDIF()
    52     ENDFOREACH(_switch)
     46    # Is the argument a keyword?
     47    LIST(FIND _keywords ${_arg} _keyword_index)
     48    IF(NOT _keyword_index EQUAL -1)
    5349
    54     # Input options
    55     IF(NOT _arg_found)
    56       FOREACH(_list_name ${_list_names})
    57         IF(${_list_name} STREQUAL ${_arg})
    58           SET(_storage_var _arg_${_list_name})
    59           SET(_arg_found TRUE)
     50      # Another optimisation
     51      SET(_arg_found FALSE)
     52      # Switches
     53      FOREACH(_switch ${_switches})
     54        IF(${_switch} STREQUAL ${_arg})
     55          SET(_arg_${_switch} ${_switch})
     56          SET(_arg_found TRUE)
     57          # Avoid interpreting arguments after this one as options args for the previous one
     58          SET(_storage_var)
    6059          BREAK()
    6160        ENDIF()
    62       ENDFOREACH(_list_name)
    63     ENDIF(NOT _arg_found)
     61      ENDFOREACH(_switch)
    6462
    65     # Arguments of an input option (like source files for SOURCE_FILES)
    66     IF(NOT _arg_found)
     63      # Input options
     64      IF(NOT _arg_found)
     65        FOREACH(_list_name ${_list_names})
     66          IF(${_list_name} STREQUAL ${_arg})
     67            SET(_storage_var _arg_${_list_name})
     68            BREAK()
     69          ENDIF()
     70        ENDFOREACH(_list_name)
     71      ENDIF(NOT _arg_found)
     72
     73    ELSE()
     74
     75      # Arguments of an input option (like source files for SOURCE_FILES)
    6776      IF(_storage_var)
    6877        # Store in variable define above in the foreach loop
     
    7180        MESSAGE(FATAL_ERROR "ORXONOX_ADD_${_target_type} was given a non compliant argument: ${_arg}")
    7281      ENDIF(_storage_var)
    73     ENDIF(NOT _arg_found)
     82
     83    ENDIF()
    7484
    7585  ENDFOREACH(_arg)
  • code/branches/resource2/src/core/ClassFactory.h

    r3196 r5610  
    5454    class ClassFactory : public BaseFactory
    5555    {
     56        friend class Factory;
     57
    5658        public:
    5759            static bool create(const std::string& name, bool bLoadable = true);
     
    5961
    6062        private:
    61             ClassFactory() {}                               // Don't create
    62             ClassFactory(const ClassFactory& factory) {}    // Don't copy
     63            ClassFactory(bool bLoadable) : bLoadable_(bLoadable) {}
     64            ClassFactory(const ClassFactory& factory)    // Don't copy
    6365            virtual ~ClassFactory() {}                      // Don't delete
    6466
    65             static T* createNewObject(BaseObject* creator);
     67            Identifier* createIdentifier(const std::string& name);
     68
     69            bool bLoadable_;
    6670    };
    6771
     
    7680    {
    7781        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));
    8183
    8284        return true;
     
    9092    inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
    9193    {
    92         return ClassFactory<T>::createNewObject(creator);
     94        return new T(creator);
    9395    }
    9496
    9597    /**
    96         @brief Creates and returns a new object of class T; this is a wrapper for the new operator.
    97         @return The new object
    9898    */
    9999    template <class T>
    100     inline T* ClassFactory<T>::createNewObject(BaseObject* creator)
     100    inline Identifier* ClassFactory<T>::createIdentifier(const std::string& name)
    101101    {
    102         return new T(creator);
     102        Identifier* identifier = ClassIdentifier<T>::getIdentifier(name);
     103        identifier->addFactory(this);
     104        identifier->setLoadable(this->bLoadable_);
     105        return identifier;
    103106    }
    104107}
  • code/branches/resource2/src/core/Factory.cc

    r3196 r5610  
    7373        @param identifier The identifier to add
    7474    */
    75     void Factory::add(const std::string& name, Identifier* identifier)
     75    void Factory::add(const std::string& name, BaseFactory* factory)
    7676    {
    77         getFactoryPointer()->identifierStringMap_[name] = identifier;
    78         getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
     77        getFactoryPointer()->factoryMap_[name] = factory;
    7978    }
    8079
     
    105104    {
    106105        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)
    111110        {
     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;
    112115            // 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);
    114117            delete temp;
    115118        }
    116         (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy();
     119        Identifier::stopCreatingHierarchy();
    117120        COUT(3) << "*** Factory: Finished class-hierarchy creation" << std::endl;
    118121    }
  • code/branches/resource2/src/core/Factory.h

    r2761 r5610  
    6161            static Identifier* getIdentifier(const std::string& name);
    6262            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);
    6464            static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);
    6565            static void cleanNetworkIDs();
     
    6969
    7070            /** @brief Returns the factory-map. */
    71             static const std::map<std::string, Identifier*>& getFacbtoryMap()
     71            static const std::map<std::string, Identifier*>& getFactoryMap()
    7272                { return Factory::getFactoryPointer()->identifierStringMap_; }
    7373            /** @brief Returns the begin-iterator of the factory-map. */
     
    8585            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
    8686            std::map<uint32_t, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
     87            std::map<std::string, BaseFactory*> factoryMap_;
    8788    };
    8889
     
    9596        public:
    9697            virtual BaseObject* fabricate(BaseObject* creator) = 0;
     98            virtual Identifier* createIdentifier(const std::string& name) = 0;
    9799            virtual ~BaseFactory() {};
    98100    };
  • code/branches/resource2/src/network/CMakeLists.txt

    r3304 r5610  
    3535  TrafficControl.cc
    3636)
     37
     38SET_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
    3758ADD_SUBDIRECTORY(packet)
    3859ADD_SUBDIRECTORY(synchronisable)
    3960
    4061ORXONOX_ADD_LIBRARY(network
    41   FIND_HEADER_FILES
    4262  DEFINE_SYMBOL
    4363    "NETWORK_SHARED_BUILD"
     
    5171    core
    5272  SOURCE_FILES
    53     ${NETWORK_SRC_FILES}
     73    ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES}
    5474)
  • code/branches/resource2/src/network/packet/CMakeLists.txt

    r3084 r5610  
    11ADD_SOURCE_FILES(NETWORK_SRC_FILES
    2   Packet.cc
    32  Acknowledgement.cc
    43  Chat.cc
     
    87  FunctionCalls.cc
    98  Gamestate.cc
     9  Packet.cc
    1010  Welcome.cc
    1111)
     12
     13ADD_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  
    55  SynchronisableVariable.cc
    66)
     7
     8ADD_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  
    3333)
    3434
     35SET_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
    3566IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
    3667  # Get around displaying a few hundred lines of warning code
     
    3970
    4071ORXONOX_ADD_LIBRARY(util
    41   FIND_HEADER_FILES
    4272  DEFINE_SYMBOL
    4373    "UTIL_SHARED_BUILD"
     
    4575    ${OGRE_LIBRARY}
    4676  SOURCE_FILES
    47     ${UTIL_SRC_FILES}
     77    ${UTIL_SRC_FILES} ${UTIL_HDR_FILES}
    4878)
Note: See TracChangeset for help on using the changeset viewer.