Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/libs/src/libraries/core/config/SettingsConfigFile.h @ 10045

Last change on this file since 10045 was 9559, checked in by landauf, 12 years ago

split ConfigFileManager.h/cc into multiple files, one for each class. why did I ever put them all into the same file?

  • 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 "ConfigFile.h"
40#include "util/Singleton.h"
41
42namespace orxonox // tolua_export
43{ // tolua_export
44
45    ////////////////////////
46    // SettingsConfigFile //
47    ////////////////////////
48    /**
49        @brief Child class of ConfigFile, used to store the settings of the game.
50
51        In addition to ConfigFile, this class provides an interface to manipulate the settings
52        with console commands and to cache entries in instances of ConfigValueContainer.
53
54        SettingsConfigFile is a Singleton, meaning there's only one instance of this class
55        (and thus only one config file that stores settings).
56    */
57    class _CoreExport SettingsConfigFile // tolua_export
58        : public ConfigFile, public Singleton<SettingsConfigFile>
59    { // tolua_export
60        friend class Singleton<SettingsConfigFile>;
61
62        public:
63            typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*> > ContainerMap;
64
65            SettingsConfigFile(const std::string& filename);
66            ~SettingsConfigFile();
67
68            void load(); // tolua_export
69            void setFilename(const std::string& filename); // tolua_export
70            void clean(bool bCleanComments = false); // tolua_export
71
72            void config(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
73            void tconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
74            std::string getConfig(const std::string& section, const std::string& entry); // tolua_export
75
76            void addConfigValueContainer(ConfigValueContainer* container);
77            void removeConfigValueContainer(ConfigValueContainer* container);
78
79            /// Returns a set containing the names of all sections in this config file.
80            inline const std::set<std::string>& getSectionNames()
81                { return this->sectionNames_; }
82            /// Returns the lower-bound-iterator of the @ref ConfigValueContainer "config value containers" for the given section.
83            inline ContainerMap::const_iterator getContainerLowerBound(const std::string section)
84                { return this->containers_.lower_bound(section); }
85            /// Returns the upper-bound-iterator of the @ref ConfigValueContainer "config value containers" for the given section.
86            inline ContainerMap::const_iterator getContainerUpperBound(const std::string section)
87                { return this->containers_.upper_bound(section); }
88
89            static SettingsConfigFile& getInstance() { return Singleton<SettingsConfigFile>::getInstance(); } // tolua_export
90
91        private:
92            void updateConfigValues();
93            bool configImpl(const std::string& section, const std::string& entry, const std::string& value, bool (ConfigValueContainer::*function)(const MultiType&));
94
95            ContainerMap containers_;                   ///< Stores all @ref ConfigValueContainer "config value containers"
96            std::set<std::string> sectionNames_;        ///< Stores all section names
97            static SettingsConfigFile* singletonPtr_s;  ///< The singleton pointer
98    }; // tolua_export
99} // tolua_export
100
101#endif /* _SettingsConfigFile_H__ */
Note: See TracBrowser for help on using the repository browser.