Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2009, 8:20:07 PM (15 years ago)
Author:
rgrieder
Message:

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

Location:
code/trunk
Files:
1 deleted
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/util/CMakeLists.txt

    r5781 r5929  
    1919
    2020SET_SOURCE_FILES(UTIL_SRC_FILES
    21   Clipboard.cc
    22   CRC32.cc
    2321  Exception.cc
    24   ExprParser.cc
    2522  Math.cc
    2623  MultiType.cc
     24  Scope.cc
     25  StringUtils.cc
     26COMPILATION_BEGIN StableCompilation.cc
     27  Clipboard.cc
     28  Clock.cc
     29  CRC32.cc
     30  ExprParser.cc
    2731  OutputBuffer.cc
    2832  OutputHandler.cc
    29   Scope.cc
    3033  SignalHandler.cc
    3134  Sleep.cc
    32   StringUtils.cc
    3335  SubString.cc
     36COMPILATION_END
    3437)
    3538
  • code/trunk/src/libraries/util/Scope.h

    r5738 r5929  
    3131
    3232#include "UtilPrereqs.h"
     33
    3334#include <cassert>
     35#include <map>
    3436#include <set>
    35 #include <map>
     37
    3638#include "Debug.h"
     39#include "ScopeGuard.h"
    3740
    3841namespace orxonox
    3942{
    40     namespace ScopeID
    41     {
    42         /**
    43             @brief A list of available scopes for the Scope template.
    44         */
    45         enum Value
    46         {
    47             GSRoot,
    48             GSGraphics,
    49             GSLevel
    50         };
    51     }
    52 
    53     class ScopeListener; // Forward declaration
    54 
    5543    /**
    5644        @brief The ScopeManager stores the variables of the scope templates in a statically linked context.
     
    7765        protected:
    7866            //! Constructor: Registers the instance.
    79             ScopeListener(ScopeID::Value scope) : scope_(scope)
     67            ScopeListener(ScopeID::Value scope) : scope_(scope), bActivated_(false)
    8068                { ScopeManager::listeners_s[this->scope_].insert(this); }
    8169            //! Destructor: Unregisters the instance.
     
    9078        private:
    9179            ScopeID::Value scope_; //!< Store the scope to unregister on destruction
     80            bool bActivated_;
    9281    };
    9382
     
    10594            Scope()
    10695            {
    107                 ScopeManager::instanceCounts_s[scope]++;
    108                 assert(ScopeManager::instanceCounts_s[scope] > 0);
    109                 if (ScopeManager::instanceCounts_s[scope] == 1)
     96                try
    11097                {
    111                     for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
    112                         (*(it++))->activated();
     98                    ScopeManager::instanceCounts_s[scope]++;
     99                    assert(ScopeManager::instanceCounts_s[scope] > 0);
     100                    if (ScopeManager::instanceCounts_s[scope] == 1)
     101                    {
     102                        Loki::ScopeGuard deactivator = Loki::MakeObjGuard(*this, &Scope::deactivateListeners);
     103                        for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
     104                        {
     105                            (*it)->activated();
     106                            (*(it++))->bActivated_ = true;
     107                        }
     108                        deactivator.Dismiss();
     109                    }
     110                }
     111                catch (...)
     112                {
     113                    ScopeManager::instanceCounts_s[scope]--;
     114                    throw;
    113115                }
    114116            }
     
    125127
    126128                if (ScopeManager::instanceCounts_s[scope] == 0)
     129                    this->deactivateListeners();
     130            }
     131
     132            void deactivateListeners()
     133            {
     134                for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
    127135                {
    128                     for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
    129                         (*(it++))->deactivated();
     136                    if ((*it)->bActivated_)
     137                    {
     138                        try
     139                            { (*it)->deactivated(); }
     140                        catch (...)
     141                            { COUT(0) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << std::endl; }
     142                        (*(it++))->bActivated_ = false;
     143                    }
     144                    else
     145                        ++it;
    130146                }
    131147            }
  • code/trunk/src/libraries/util/Singleton.h

    r5738 r5929  
    5555        }
    5656
     57        //! Update method called by ClassSingletonManager (if used)
     58        void updateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->update(time); }
     59        //! Empty update method for the static polymorphism
     60        void update(const Clock& time) { }
     61
    5762    protected:
    5863        //! Constructor sets the singleton instance pointer
  • code/trunk/src/libraries/util/UtilPrereqs.h

    r5738 r5929  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the util library
    3233*/
    3334
     
    4041// Shared library settings
    4142//-----------------------------------------------------------------------
     43
    4244#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( UTIL_STATIC_BUILD )
    4345#  ifdef UTIL_SHARED_BUILD
     
    5658#endif
    5759
     60//-----------------------------------------------------------------------
     61// Enums
     62//-----------------------------------------------------------------------
     63
     64namespace orxonox
     65{
     66    namespace ScopeID
     67    {
     68        //!A list of available scopes for the Scope template.
     69        enum Value
     70        {
     71            Root,
     72            Graphics
     73        };
     74    }
     75}
    5876
    5977//-----------------------------------------------------------------------
     
    6381namespace orxonox
    6482{
     83    class Clock;
    6584    class Exception;
    6685    class ExprParser;
     
    7190    class OutputBufferListener;
    7291    class OutputHandler;
     92    template <ScopeID::Value>
     93    class Scope;
     94    template <class, ScopeID::Value>
     95    class ScopedSingleton;
     96    class ScopeListener;
    7397    class SignalHandler;
     98    template <class T>
     99    class Singleton;
    74100    class SubString;
    75101}
Note: See TracChangeset for help on using the changeset viewer.