Orxonox  0.0.5 Codename: Arcturus
ScopeManager.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
35 #ifndef __ScopeManager_H__
36 #define __ScopeManager_H__
37 
38 #include "core/CorePrereqs.h"
39 
40 #include <map>
41 #include <set>
42 
43 #include "util/Singleton.h"
44 
45 namespace orxonox
46 {
56  class _CoreExport ScopeManager : public Singleton<ScopeManager>
57  {
58  friend class Singleton<ScopeManager>;
59 
60  public:
62  void addScope(ScopeID::Value scope);
64  void removeScope(ScopeID::Value scope);
66  bool isActive(ScopeID::Value scope);
67 
69  void addListener(ScopeListener* listener, ScopeID::Value scope);
71  void removeListener(ScopeListener* listener, ScopeID::Value scope);
72 
74  const std::set<ScopeListener*>& getListeners(ScopeID::Value scope)
75  { return this->listeners_[scope]; }
76 
77  private:
78  void activateListenersForScope(ScopeID::Value scope);
79  void deactivateListenersForScope(ScopeID::Value scope);
80 
81  void activateListener(ScopeListener* listener);
82  void deactivateListener(ScopeListener* listener);
83 
84  std::set<ScopeID::Value> activeScopes_;
85  std::map<ScopeID::Value, std::set<ScopeListener*>> listeners_;
86 
88  };
89 }
90 
91 #endif /* __ScopeManager_H__ */
ScopeListeners register themselves in the corresponding Scope and wait for notifications.
Definition: Scope.h:68
Shared library macros, enums, constants and forward declarations for the core library ...
Base for singleton classes.
Definition: Singleton.h:114
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
std::set< ScopeID::Value > activeScopes_
Definition: ScopeManager.h:84
#define _CoreExport
Definition: CorePrereqs.h:61
static ScopeManager * singletonPtr_s
Definition: ScopeManager.h:87
std::map< ScopeID::Value, std::set< ScopeListener * > > listeners_
Stores all listeners for a scope.
Definition: ScopeManager.h:85
Definition of the Singleton template that is used as base class for classes that allow only one insta...
The ScopeManager stores the variables of the Scope templates in a statically linked context...
Definition: ScopeManager.h:56
const std::set< ScopeListener * > & getListeners(ScopeID::Value scope)
Returns all registered listeners for a given scope.
Definition: ScopeManager.h:74
int Value
Definition: CorePrereqs.h:82