[1505] | 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 | |
---|
[7401] | 29 | /** |
---|
| 30 | @file |
---|
[9559] | 31 | @brief Implementation of ConfigFileManager. |
---|
[7401] | 32 | */ |
---|
| 33 | |
---|
[1505] | 34 | #include "ConfigFileManager.h" |
---|
[2103] | 35 | |
---|
[9559] | 36 | #include "SettingsConfigFile.h" |
---|
[2710] | 37 | |
---|
[1505] | 38 | namespace orxonox |
---|
| 39 | { |
---|
| 40 | /////////////////////// |
---|
[6536] | 41 | // ConfigFileManager // |
---|
| 42 | /////////////////////// |
---|
| 43 | |
---|
| 44 | ConfigFileManager* ConfigFileManager::singletonPtr_s = 0; |
---|
| 45 | |
---|
[7401] | 46 | /// Constructor: Initializes the array of config files with NULL. |
---|
[6536] | 47 | ConfigFileManager::ConfigFileManager() |
---|
[1505] | 48 | { |
---|
[6536] | 49 | this->configFiles_.assign(NULL); |
---|
[1505] | 50 | } |
---|
| 51 | |
---|
[7401] | 52 | /// Destructor: Deletes the config files. |
---|
[6536] | 53 | ConfigFileManager::~ConfigFileManager() |
---|
[1505] | 54 | { |
---|
[6536] | 55 | for (boost::array<ConfigFile*, 3>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it) |
---|
| 56 | if (*it) |
---|
| 57 | delete (*it); |
---|
[1505] | 58 | } |
---|
| 59 | |
---|
[7401] | 60 | /// Defines the file-name for the config file of a given type (settings, calibration, etc.). |
---|
[6536] | 61 | void ConfigFileManager::setFilename(ConfigFileType::Value type, const std::string& filename) |
---|
[1505] | 62 | { |
---|
[6536] | 63 | if (this->getConfigFile(type)) |
---|
| 64 | delete this->configFiles_[type]; |
---|
| 65 | // Create and load config file |
---|
| 66 | switch (type) |
---|
[2103] | 67 | { |
---|
[6536] | 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; |
---|
[2103] | 75 | } |
---|
[6536] | 76 | this->configFiles_[type]->load(); |
---|
[1505] | 77 | } |
---|
| 78 | } |
---|