Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/config/ConfigFileManager.cc @ 10410

Last change on this file since 10410 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: 2.4 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    @brief Implementation of ConfigFileManager.
32*/
33
34#include "ConfigFileManager.h"
35
36#include "SettingsConfigFile.h"
37
38namespace orxonox
39{
40    ///////////////////////
41    // ConfigFileManager //
42    ///////////////////////
43
44    ConfigFileManager* ConfigFileManager::singletonPtr_s = 0;
45
46    /// Constructor: Initializes the array of config files with NULL.
47    ConfigFileManager::ConfigFileManager()
48    {
49        this->configFiles_.assign(NULL);
50    }
51
52    /// Destructor: Deletes the config files.
53    ConfigFileManager::~ConfigFileManager()
54    {
55        for (boost::array<ConfigFile*, 3>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
56            if (*it)
57                delete (*it);
58    }
59
60    /// Defines the file-name for the config file of a given type (settings, calibration, etc.).
61    void ConfigFileManager::setFilename(ConfigFileType::Value type, const std::string& filename)
62    {
63        if (this->getConfigFile(type))
64            delete this->configFiles_[type];
65        // Create and load config file
66        switch (type)
67        {
68        case ConfigFileType::Settings:
69            this->configFiles_[type] = new SettingsConfigFile(filename);
70            break;
71        case ConfigFileType::JoyStickCalibration:
72        case ConfigFileType::CommandHistory:
73            this->configFiles_[type] = new ConfigFile(filename);
74            break;
75        }
76        this->configFiles_[type]->load();
77    }
78}
Note: See TracBrowser for help on using the repository browser.