Orxonox  0.0.5 Codename: Arcturus
LevelManager.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  * Damian 'Mozork' Frick
26  *
27  */
28 
35 #ifndef _LevelManager_H__
36 #define _LevelManager_H__
37 
38 #include "OrxonoxPrereqs.h"
39 
40 #include <cassert>
41 #include <list>
42 #include <map>
43 #include <string>
44 
45 #include "LevelInfo.h"
46 
47 #include "util/Singleton.h"
49 
50 // tolua_begin
51 namespace orxonox
52 {
53 
68  // tolua_end
69  : public Singleton<LevelManager>, public Configurable
70  { // tolua_export
71  friend class Singleton<LevelManager>;
72  public:
73  LevelManager();
74  virtual ~LevelManager();
75 
76  void setConfigValues();
77 
78  void requestActivity(Level* level);
79  void releaseActivity(Level* level);
80  Level* getActiveLevel();
81 
82  // tolua_begin
83  void setDefaultLevel(const std::string& levelName);
84 
89  { return defaultLevelName_; }
90  unsigned int getNumberOfLevels(void);
91  LevelInfoItem* getAvailableLevelListItem(unsigned int index);
92 
93  void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission);
95  { return this->lastFinishedCampaignMission_; }
96 
97  inline unsigned int getNumberOfCampaignMissions()
98  { return this->campaignMissions_.size(); }
99  inline const std::string& getCampaignMission(unsigned int index)
100  { return this->campaignMissions_[index]; }
101 
108  // tolua_end
109 
110  private:
111  // non-copyable:
112  LevelManager(const LevelManager&) = delete;
113  LevelManager& operator=(const LevelManager&) = delete;
114 
115  void activateNextLevel();
116 
117  void compileAvailableLevelList(void);
118  void updateAvailableLevelList(void);
119 
120  std::list<Level*> levels_;
121  std::set<LevelInfoItem*, LevelInfoCompare> availableLevels_;
122 
123  // Helpers to allow fast access to the availableLevels list.
124  unsigned int nextIndex_;
125  std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_;
126 
127  // config values
130  std::vector<std::string> campaignMissions_;
131 
133  }; // tolua_export
134 } // tolua_export
135 
136 #endif /* _LevelManager_H__ */
std::string lastFinishedCampaignMission_
Definition: LevelManager.h:129
const std::string & getLastFinishedCampaignMission() const
Definition: LevelManager.h:94
std::set< LevelInfoItem *, LevelInfoCompare > availableLevels_
The set of available Levels sorted alphabetically according to the name of the Level.
Definition: LevelManager.h:121
::std::string string
Definition: gtest-port.h:756
Definition of the LevelInfo and LevelInfoItem class.
unsigned int nextIndex_
Definition: LevelManager.h:124
static LevelManager & getInstance()
Get the instance of the LevelManager.
Definition: LevelManager.h:106
This is the base class of all objects which may contain config values.
Definition: Configurable.h:47
unsigned int getNumberOfCampaignMissions()
Definition: LevelManager.h:97
Definition: Level.h:46
Base for singleton classes.
Definition: Singleton.h:114
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
static LevelManager * singletonPtr_s
Definition: LevelManager.h:132
const std::string & getDefaultLevel() const
Get the default level.
Definition: LevelManager.h:88
Shared library macros, enums, constants and forward declarations for the orxonox library ...
Declaration of Configurable, the base class of all objects which may contain config values...
std::string defaultLevelName_
The next expected Level to be accessed.
Definition: LevelManager.h:128
std::set< LevelInfoItem *, LevelInfoCompare >::iterator nextLevel_
The next expected index to be accessed.
Definition: LevelManager.h:125
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
Definition of the Singleton template that is used as base class for classes that allow only one insta...
const std::string & getCampaignMission(unsigned int index)
Definition: LevelManager.h:99
The LevelInfoItem class stores information regarding a Level and makes that information accessible th...
Definition: LevelInfo.h:62
static T & getInstance()
Returns a reference to the singleton instance.
Definition: Singleton.h:118
The LevelManager keeps track of Levels whose activity has been requested and activates the Levels in ...
Definition: LevelManager.h:67
std::list< Level * > levels_
A list of all the Levels whose activity has been requested, in the order in which they will become ac...
Definition: LevelManager.h:120
std::vector< std::string > campaignMissions_
Definition: LevelManager.h:130