Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 15, 2008, 12:53:05 AM (16 years ago)
Author:
rgrieder
Message:

Merged physics_merge back to presentation branch.

Location:
code/branches/presentation
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/core/RootGameState.cc

    r2103 r2459  
    130130    void RootGameState::start()
    131131    {
    132 #ifdef NDEBUG
     132        // Don't catch errors when having a debugger in msvc
     133#if ORXONOX_COMPILER != ORXONOX_COMPILER_MSVC || defined(NDEBUG)
    133134        try
    134135        {
     
    156157
    157158            this->deactivate();
    158 #ifdef NDEBUG
     159#if ORXONOX_COMPILER != ORXONOX_COMPILER_MSVC || defined(NDEBUG)
    159160        }
    160161        // Note: These are all unhandled exceptions that should not have made its way here!
     
    162163        catch (std::exception& ex)
    163164        {
    164             COUT(1) << ex.what() << std::endl;
    165             COUT(1) << "Program aborted." << std::endl;
     165            COUT(0) << ex.what() << std::endl;
     166            COUT(0) << "Program aborted." << std::endl;
     167            abort();
    166168        }
    167169        // anything that doesn't inherit from std::exception
    168170        catch (...)
    169171        {
    170             COUT(1) << "An unidentifiable exception has occured. Program aborted." << std::endl;
     172            COUT(0) << "An unidentifiable exception has occured. Program aborted." << std::endl;
     173            abort();
    171174        }
    172175#endif
  • code/branches/presentation/src/core/Template.cc

  • code/branches/presentation/src/core/Template.h

  • code/branches/presentation/src/core/XMLFile.h

  • code/branches/presentation/src/core/XMLIncludes.h

  • code/branches/presentation/src/core/XMLPort.h

    r2171 r2459  
    7474    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
    7575    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
     76
     77/**
     78    @brief Declares an XML attribute with a name, which will be set through a variable.
     79    @param classname The name of the class owning this param
     80    @param paramname The name of the attribute
     81    @param variable Name of the variable used to save and load the value
     82    @param xmlelement The XMLElement, you get this from the XMLPort function
     83    @param mode The mode (load or save), you get this from the XMLPort function
     84
     85    In the XML file, a param or attribute will be set like this:
     86    <classname paramname="value" />
     87
     88    The macro will then store "value" in the variable or read it when saving.
     89*/
     90#define XMLPortParamVariable(classname, paramname, variable, xmlelement, mode) \
     91    static XMLPortVariableHelperClass xmlcontainer##variable##dummy((void*)&variable); \
     92    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##loadexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader")); \
     93    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##saveexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" )); \
     94    XMLPortParamGeneric(xmlcontainer##variable, classname, orxonox::XMLPortVariableHelperClass, &xmlcontainer##variable##dummy, paramname, xmlcontainer##variable##loadexecutor, xmlcontainer##variable##saveexecutor, xmlelement, mode)
     95
     96/**
     97    @brief Declares an XML attribute with a name, which will be set through a variable and gotten from a function.
     98    @param classname The name of the class owning this param
     99    @param paramname The name of the attribute
     100    @param variable Name of the variable used to save the value
     101    @param savefunction A function to get the value of the param from the object (~a get-function)
     102    @param xmlelement The XMLElement, you get this from the XMLPort function
     103    @param mode The mode (load or save), you get this from the XMLPort function
     104
     105    In the XML file, a param or attribute will be set like this:
     106    <classname paramname="value" />
     107
     108    The macro will then store "value" in the variable or read it when saving.
     109*/
     110#define XMLPortParamVariableOnLoad(classname, paramname, variable, savefunction, xmlelement, mode) \
     111    static XMLPortVariableHelperClass xmlcontainer##variable##dummy((void*)&variable); \
     112    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##loadexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(&(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader"))); \
     113    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     114    XMLPortParamGeneric(xmlcontainer##variable, classname, orxonox::XMLPortVariableHelperClass, &xmlcontainer##variable##dummy, paramname, xmlcontainer##variable##loadexecutor, xmlcontainer##variable##saveexecutor, xmlelement, mode)
     115
    76116/**
    77117    @brief This is the same as XMLPortParam, but you can set the template arguments needed to store the loadfunction.
     
    175215    @param xmlelement The XMLElement (recieved through the XMLPort function)
    176216    @param mode The mode (load/save) (received through the XMLPort function)
    177     @param bApplyLoaderMask If this is true, an added sub-object only gets loaded if it's class is included in the Loaders ClassTreeMask (this is usually false)
    178     @param bLoadBefore If this is true, the sub-cobject gets loaded (through XMLPort) BEFORE it gets added to the main class (this is usually true)
     217    @param bApplyLoaderMask If this is true, an added sub-object gets loaded only if it's class is included in the Loaders ClassTreeMask (this is usually false)
     218    @param bLoadBefore If this is true, the sub-object gets loaded (through XMLPort) BEFORE it gets added to the main class (this is usually true)
    179219
    180220    bApplyLoaderMask is usually false for the following reason:
     
    183223    Of course, if there are "standalone" weapons in the level, they wont be loaded.
    184224
    185     If bLoadBefore, an added object already has all attributes set (like it's name). This is most
     225    If bLoadBefore is true, an added object already has all attributes set (like it's name). This is most
    186226    likely the best option, so this is usually true.
    187227
     
    222262    Note that "weapons" is the subsection. This allows you to add more types of sub-objects. In our example,
    223263    you could add pilots, blinking lights or other stuff. If you don't want a subsection, just use "" (an
    224     empty string). The you can add sub-objects directly into the mainclass.
     264    empty string). Then you can add sub-objects directly into the mainclass.
    225265*/
    226266#define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
     
    588628            ExecutorMember<T>* saveexecutor_;
    589629    };
     630
     631
     632    // ####################################
     633    // ###  XMLPortVariableHelperClass  ###
     634    // ####################################
     635    /**
     636    @brief
     637        Helper class to load and save simple variables with XMLPort.
     638
     639        getLoader and getSaver were necessary to get the type T with
     640        the help of template function type deduction (const T& is unused).
     641        These functions return the adress of save<T> or load<T>.
     642    */
     643    class XMLPortVariableHelperClass
     644    {
     645        public:
     646            XMLPortVariableHelperClass(void* var)
     647                : variable_(var)
     648                { }
     649
     650            template <class T>
     651            void load(const T& value)
     652                { *((T*)this->variable_) = value; }
     653
     654            template <class T>
     655            const T& save()
     656                { return *((T*)this->variable_); }
     657
     658            template <class T>
     659            static void (XMLPortVariableHelperClass::*getLoader(const T& var))(const T& value)
     660                { return &XMLPortVariableHelperClass::load<T>; }
     661
     662            template <class T>
     663            static const T& (XMLPortVariableHelperClass::*getSaver(const T& var))()
     664                { return &XMLPortVariableHelperClass::save<T>; }
     665
     666        private:
     667            void* variable_;
     668    };
    590669}
    591670
Note: See TracChangeset for help on using the changeset viewer.