Wolframe, 0.0.3

appConfig.hpp
Go to the documentation of this file.
1 /************************************************************************
2 
3  Copyright (C) 2011 - 2014 Project Wolframe.
4  All rights reserved.
5 
6  This file is part of Project Wolframe.
7 
8  Commercial Usage
9  Licensees holding valid Project Wolframe Commercial licenses may
10  use this file in accordance with the Project Wolframe
11  Commercial License Agreement provided with the Software or,
12  alternatively, in accordance with the terms contained
13  in a written agreement between the licensee and Project Wolframe.
14 
15  GNU General Public License Usage
16  Alternatively, you can redistribute this file and/or modify it
17  under the terms of the GNU General Public License as published by
18  the Free Software Foundation, either version 3 of the License, or
19  (at your option) any later version.
20 
21  Wolframe is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  GNU General Public License for more details.
25 
26  You should have received a copy of the GNU General Public License
27  along with Wolframe. If not, see <http://www.gnu.org/licenses/>.
28 
29  If you have questions regarding the use of this file, please contact
30  Project Wolframe.
31 
32 ************************************************************************/
35 
36 #ifndef _APP_CONFIG_HPP_INCLUDED
37 #define _APP_CONFIG_HPP_INCLUDED
38 
40 #include <cstddef>
41 #include <string>
42 #include <map>
43 #include <vector>
44 
45 namespace _Wolframe {
46 
47 // forward declarations for configuration elements
48 namespace net { struct Configuration; }
49 namespace log { struct LoggerConfiguration; }
50 struct HandlerConfiguration;
51 
52 
53 namespace config {
54 
56 struct LoggerConfiguration;
57 struct CmdLineConfig; // forward declaration for the command line structure
58 
61  std::string configFile;
62  // from command line
63  bool foreground;
64 
65  // daemon / service configuration
67  // network server configuration
69  // logger configuration
71  // the thing that does the job
72  HandlerConfiguration *handlerCfg;
73 
74 public:
79  };
80 
83 
84  static ConfigFileType fileType( const char *filename, ConfigFileType type );
85 
86  bool parseModules( const char *filename, ConfigFileType type );
87  const std::list< std::string >& moduleList() const
88  { return m_modFiles; }
89  const std::string& moduleFolder() const { return m_modFolder; }
90 
91  void addModules( const module::ModulesDirectory* modules )
92  { m_modDir = modules; }
93  bool parse( const char *filename, ConfigFileType type );
95  void finalize( const CmdLineConfig& cmdLine );
97  void finalize();
98 
99  bool check() const;
100  bool test() const;
101  void print( std::ostream& os ) const;
102 
103  static const char* chooseFile( const char *globalFile,
104  const char *userFile,
105  const char *localFile );
106 private:
108  std::vector< ConfigurationBase* > m_conf;
109  std::map< std::string, std::size_t > m_section;
110  std::string m_modFolder;
111  std::list< std::string > m_modFiles;
112 
114 public:
115  bool addConfig( const std::string& nodeName, ConfigurationBase* conf );
116 };
117 
118 } // namespace config
119 } // namespace _Wolframe
120 
121 #endif // _APP_CONFIG_HPP_INCLUDED
std::map< std::string, std::size_t > m_section
Definition: appConfig.hpp:109
bool parseModules(const char *filename, ConfigFileType type)
application configuration structure
Definition: appConfig.hpp:60
std::list< std::string > m_modFiles
Definition: appConfig.hpp:111
Base class for the configuration structures.
Definition: configurationBase.hpp:54
const std::string & moduleFolder() const
Definition: appConfig.hpp:89
bool addConfig(const std::string &nodeName, ConfigurationBase *conf)
const std::list< std::string > & moduleList() const
Definition: appConfig.hpp:87
The modules directory used by the constructors of the providers to build themselves.
Definition: moduleDirectory.hpp:48
void finalize()
Finalize configuration for simple program (tests, wolfilter) running in foreground.
void addModules(const module::ModulesDirectory *modules)
Definition: appConfig.hpp:91
ConfigFileType
Definition: appConfig.hpp:75
ServiceConfiguration * serviceCfg
Definition: appConfig.hpp:66
ConfigFileType m_type
Definition: appConfig.hpp:107
net::Configuration * serverCfg
Definition: appConfig.hpp:68
bool parse(const char *filename, ConfigFileType type)
const module::ModulesDirectory * m_modDir
Definition: appConfig.hpp:113
std::string configFile
Definition: appConfig.hpp:61
Base classes for the configuration structures.
daemon / service configuration
Definition: standardConfigs.hpp:127
std::string m_modFolder
Definition: appConfig.hpp:110
void print(std::ostream &os) const
log::LoggerConfiguration * loggerCfg
Definition: appConfig.hpp:70
network server configuration
Definition: standardConfigs.hpp:52
std::vector< ConfigurationBase * > m_conf
Definition: appConfig.hpp:108
logger configuration
Definition: standardConfigs.hpp:84
HandlerConfiguration * handlerCfg
Definition: appConfig.hpp:72
bool foreground
Definition: appConfig.hpp:63
static ConfigFileType fileType(const char *filename, ConfigFileType type)
static const char * chooseFile(const char *globalFile, const char *userFile, const char *localFile)