Orxonox  0.0.5 Codename: Arcturus
SettingsConfigFile.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 
34 #ifndef _SettingsConfigFile_H__
35 #define _SettingsConfigFile_H__
36 
37 #include "core/CorePrereqs.h"
38 
39 #include <set>
40 #include <map>
41 #include "ConfigFile.h"
42 #include "util/Singleton.h"
43 
44 namespace orxonox // tolua_export
45 { // tolua_export
46 
48  // SettingsConfigFile //
50 
59  class _CoreExport SettingsConfigFile // tolua_export
60  : public ConfigFile, public Singleton<SettingsConfigFile>
61  { // tolua_export
63 
64  public:
65  typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*>> ContainerMap;
66 
67  SettingsConfigFile(const std::string& filename);
69 
70  virtual void load() override; // tolua_export
71  void setFilename(const std::string& filename); // tolua_export
72  void clean(bool bCleanComments = false); // tolua_export
73 
74  void config(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
75  void tconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
76  std::string getConfig(const std::string& section, const std::string& entry); // tolua_export
77 
78  void addConfigValueContainer(ConfigValueContainer* container);
79  void removeConfigValueContainer(ConfigValueContainer* container);
80 
82  inline const std::set<std::string>& getSectionNames()
83  { return this->sectionNames_; }
85  inline ContainerMap::const_iterator getContainerLowerBound(const std::string section)
86  { return this->containers_.lower_bound(section); }
88  inline ContainerMap::const_iterator getContainerUpperBound(const std::string section)
89  { return this->containers_.upper_bound(section); }
90 
92 
93  private:
94  void updateConfigValues();
95  bool configImpl(const std::string& section, const std::string& entry, const std::string& value, bool (ConfigValueContainer::*function)(const MultiType&));
96 
97  ContainerMap containers_;
98  std::set<std::string> sectionNames_;
100  }; // tolua_export
101 } // tolua_export
102 
103 #endif /* _SettingsConfigFile_H__ */
The ConfigValuecontainer contains all needed information about a configurable variable.
Definition: ConfigValueContainer.h:98
static SettingsConfigFile & getInstance()
Definition: SettingsConfigFile.h:91
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
This class represents a config file, which is stored on the hard-disk and contains config values in d...
Definition: ConfigFile.h:51
ContainerMap containers_
Stores all config value containers.
Definition: SettingsConfigFile.h:97
std::multimap< std::string, std::pair< std::string, ConfigValueContainer * > > ContainerMap
Definition: SettingsConfigFile.h:65
Base for singleton classes.
Definition: Singleton.h:114
ContainerMap::const_iterator getContainerLowerBound(const std::string section)
Returns the lower-bound-iterator of the config value containers for the given section.
Definition: SettingsConfigFile.h:85
Child class of ConfigFile, used to store the settings of the game.
Definition: SettingsConfigFile.h:59
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
#define _CoreExport
Definition: CorePrereqs.h:61
The MultiType can hold a value of many possible types and convert them to other types.
Definition: MultiType.h:130
ContainerMap::const_iterator getContainerUpperBound(const std::string section)
Returns the upper-bound-iterator of the config value containers for the given section.
Definition: SettingsConfigFile.h:88
Definition of the Singleton template that is used as base class for classes that allow only one insta...
static SettingsConfigFile * singletonPtr_s
The singleton pointer.
Definition: SettingsConfigFile.h:99
static T & getInstance()
Returns a reference to the singleton instance.
Definition: Singleton.h:118
std::set< std::string > sectionNames_
Stores all section names.
Definition: SettingsConfigFile.h:98
const std::set< std::string > & getSectionNames()
Returns a set containing the names of all sections in this config file.
Definition: SettingsConfigFile.h:82