Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 1, 2009, 11:44:53 AM (15 years ago)
Author:
rgrieder
Message:

Moved the singleton creation/destruction mess to the Core class by using just two possible Scopes:

  • ScopeID::Root for singletons that may always persists
  • ScopeID::Graphics for singletons that only work when graphics was loaded
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/util/Scope.h

    r5738 r5850  
    3131
    3232#include "UtilPrereqs.h"
     33
    3334#include <cassert>
     35#include <map>
    3436#include <set>
    35 #include <map>
    3637#include "Debug.h"
    3738
     
    4546        enum Value
    4647        {
    47             GSRoot,
    48             GSGraphics,
    49             GSLevel
     48            Root,
     49            Graphics
    5050        };
    5151    }
    5252
    53     class ScopeListener; // Forward declaration
     53    // Forward declarations
     54    class ScopeListener;
     55    class Clock;
    5456
    5557    /**
     
    8789            //! Gets called if the scope is deactivated
    8890            virtual void deactivated() = 0;
     91            //! Gets called if the scope is updated
     92            virtual void updated(const Clock& time) = 0;
    8993
    9094        private:
     
    136140                return (ScopeManager::instanceCounts_s[scope] > 0);
    137141            }
     142
     143            //! Update method for the ScopeListeners (to implement singleton updates)
     144            static void update(const Clock& time)
     145            {
     146                if (isActive())
     147                {
     148                    for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
     149                        (*(it++))->updated(time);
     150                }
     151            }
    138152    };
    139153}
Note: See TracChangeset for help on using the changeset viewer.