| 1 |
/* |
| 2 |
Copyright (C) 2002 Kai Sterker <[email protected]> |
| 3 |
Part of the Adonthell Project <http://adonthell.nongnu.org> |
| 4 |
|
| 5 |
Dlgedit is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 2 of the License, or |
| 8 |
(at your option) any later version. |
| 9 |
|
| 10 |
Dlgedit is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with Dlgedit. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* @file cfg_data.h |
| 21 |
* |
| 22 |
* @author Kai Sterker |
| 23 |
* @brief dlgedit configuration data |
| 24 |
*/ |
| 25 |
|
| 26 |
#ifndef CFG_DATA_H |
| 27 |
#define CFG_DATA_H |
| 28 |
|
| 29 |
#include <vector> |
| 30 |
#include <list> |
| 31 |
#include "cfg_project.h" |
| 32 |
|
| 33 |
/** |
| 34 |
* This class keeps track of the actual configuration settings. |
| 35 |
* It also checks those settings for correctness as far as that |
| 36 |
* is possible. |
| 37 |
* |
| 38 |
* Settings will be added or changed in two ways: at program |
| 39 |
* startup through reading ~/.adonthell/dlgeditrc and at run-time |
| 40 |
* through changes made by the user. |
| 41 |
*/ |
| 42 |
class CfgData |
| 43 |
{ |
| 44 |
public: |
| 45 |
/** |
| 46 |
* Constructor. Initialize global CfgData::data pointer. |
| 47 |
*/ |
| 48 |
CfgData (); |
| 49 |
/** |
| 50 |
* Destructor. Delete all Project entries. |
| 51 |
*/ |
| 52 |
~CfgData (); |
| 53 |
|
| 54 |
/** |
| 55 |
* Adds a project to the list of projects and loads all project |
| 56 |
* specific data. The number of projects isn't limited. |
| 57 |
* @param project name of the project to add. |
| 58 |
*/ |
| 59 |
void addProject (const std::string & project); |
| 60 |
/** |
| 61 |
* Return the names of all projects in the current data directory. |
| 62 |
* This list also includes the default project 'none', so it is |
| 63 |
* non-empty even if the data directory contains no projects yet. |
| 64 |
*/ |
| 65 |
std::vector<std::string> projectsFromDatadir (); |
| 66 |
|
| 67 |
/** |
| 68 |
* Assign a (new) base directory to the given project. If no |
| 69 |
* such project exists yet, it will be created. |
| 70 |
* @param project name of the project to modify/create. |
| 71 |
* @param basedir directory to assign to this project. |
| 72 |
*/ |
| 73 |
void setBasedir (const std::string & project, const std::string & basedir); |
| 74 |
/** |
| 75 |
* Return the base directory associated with a given project. |
| 76 |
* In case there is no such project, or no basedir assigned, |
| 77 |
* return "" (the empty string). |
| 78 |
*/ |
| 79 |
std::string getBasedir (const std::string & project); |
| 80 |
|
| 81 |
/** |
| 82 |
* Save data to disk. |
| 83 |
* @param file file to save data to. |
| 84 |
*/ |
| 85 |
void save (std::ofstream & file); |
| 86 |
|
| 87 |
/** |
| 88 |
* Global access to the dlgedit configuration |
| 89 |
*/ |
| 90 |
static CfgData *data; |
| 91 |
|
| 92 |
private: |
| 93 |
std::vector <CfgProject*> Projects; // list of defined projects |
| 94 |
}; |
| 95 |
|
| 96 |
#endif // CFG_DATA_H |