Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/config/SettingsConfigFile.h @ 9852

Last change on this file since 9852 was 9684, checked in by landauf, 11 years ago

added missing includes

  • Property svn:eol-style set to native
File size: 4.3 KB
Line 
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
29/**
30    @file
31    @ingroup Config ConfigFile
32*/
33
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
44namespace orxonox // tolua_export
45{ // tolua_export
46
47    ////////////////////////
48    // SettingsConfigFile //
49    ////////////////////////
50    /**
51        @brief Child class of ConfigFile, used to store the settings of the game.
52
53        In addition to ConfigFile, this class provides an interface to manipulate the settings
54        with console commands and to cache entries in instances of ConfigValueContainer.
55
56        SettingsConfigFile is a Singleton, meaning there's only one instance of this class
57        (and thus only one config file that stores settings).
58    */
59    class _CoreExport SettingsConfigFile // tolua_export
60        : public ConfigFile, public Singleton<SettingsConfigFile>
61    { // tolua_export
62        friend class Singleton<SettingsConfigFile>;
63
64        public:
65            typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*> > ContainerMap;
66
67            SettingsConfigFile(const std::string& filename);
68            ~SettingsConfigFile();
69
70            void load(); // 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
81            /// Returns a set containing the names of all sections in this config file.
82            inline const std::set<std::string>& getSectionNames()
83                { return this->sectionNames_; }
84            /// Returns the lower-bound-iterator of the @ref ConfigValueContainer "config value containers" for the given section.
85            inline ContainerMap::const_iterator getContainerLowerBound(const std::string section)
86                { return this->containers_.lower_bound(section); }
87            /// Returns the upper-bound-iterator of the @ref ConfigValueContainer "config value containers" for the given section.
88            inline ContainerMap::const_iterator getContainerUpperBound(const std::string section)
89                { return this->containers_.upper_bound(section); }
90
91            static SettingsConfigFile& getInstance() { return Singleton<SettingsConfigFile>::getInstance(); } // tolua_export
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_;                   ///< Stores all @ref ConfigValueContainer "config value containers"
98            std::set<std::string> sectionNames_;        ///< Stores all section names
99            static SettingsConfigFile* singletonPtr_s;  ///< The singleton pointer
100    }; // tolua_export
101} // tolua_export
102
103#endif /* _SettingsConfigFile_H__ */
Note: See TracBrowser for help on using the repository browser.