Documentation fixes.
[tairon.git] / src / core / config.h
blob3543867f096294fd0f5191428097e63ed86dd597
1 /***************************************************************************
2 * *
3 * Copyright (C) 2006 David Brodsky *
4 * *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Library General Public *
7 * License as published by the Free Software Foundation and appearing *
8 * in the file LICENSE.LGPL included in the packaging of this file. *
9 * *
10 * This library 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 GNU *
13 * Library General Public License for more details. *
14 * *
15 ***************************************************************************/
17 #ifndef _tairon_core_config_h
18 #define _tairon_core_config_h
20 #include <map>
22 #include "string.h"
24 namespace Tairon
27 namespace Core
30 /** \brief Class that holds configuration.
32 * It loads a configuration file with simple key-value based structure and then
33 * provides loaded informations to the rest of the program. This class is a
34 * singleton.
36 class Config
38 public:
39 /** Loads a configuration file. It is an XML file with "config" as the
40 * root element's name. Names of root's direct children are used as
41 * keys and their texts are treated as values.
43 * \param filename Path to the configuration file. If it is pure
44 * filename without any directory then it is searched in following
45 * paths: . (current directory), /etc, /usr/etc and /usr/local/etc.
47 Config(const String &filename);
49 /** Standard destructor.
51 ~Config();
53 /** Returns the key's value. Default value is returned when the key
54 * doesn't exist.
56 const String &operator[](const String &key);
58 /** Returns pointer to the instance of this class.
60 static Config *self() {
61 return config;
64 private:
65 /** Loads the configuration file and stores data from it into the
66 * internal dictionary.
68 void loadConfigFile(const String &filename);
70 /** Holds pointer to the instance of this class.
72 static Config *config;
74 /** Dictionary holding configuration.
76 std::map<String, String> data;
79 }; // namespace Core
81 }; // namespace Tairon
83 #endif
85 // vim: ai sw=4 ts=4 noet fdm=marker