SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
config.cpp
Go to the documentation of this file.
1 /*
2 SeComLib
3 Copyright 2012-2013 TU Delft, Information Security & Privacy Lab (http://isplab.tudelft.nl/)
4 
5 Contributors:
6 Inald Lagendijk (R.L.Lagendijk@TUDelft.nl)
7 Mihai Todor (todormihai@gmail.com)
8 Thijs Veugen (P.J.M.Veugen@tudelft.nl)
9 Zekeriya Erkin (z.erkin@tudelft.nl)
10 
11 Licensed under the Apache License, Version 2.0 (the "License");
12 you may not use this file except in compliance with the License.
13 You may obtain a copy of the License at
14 
15 http://www.apache.org/licenses/LICENSE-2.0
16 
17 Unless required by applicable law or agreed to in writing, software
18 distributed under the License is distributed on an "AS IS" BASIS,
19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 See the License for the specific language governing permissions and
21 limitations under the License.
22 */
30 #include "config.h"
31 
32 namespace SeComLib {
33 namespace Utils {
35  std::string Config::configFile ("config.xml");
36 
40  const std::string Config::xmlRootElementName ("config");
41 
49  static Config instance;
50  return instance;
51  }
52 
56  void Config::SetConfigFile(const std::string &configFile) {
58  }
59 
68  try {
69  boost::property_tree::xml_parser::read_xml(Config::configFile, this->propertyTree);
70  }
71  catch (const boost::property_tree::xml_parser_error &exception) {
73  throw std::runtime_error(exception.what());
74  }
75  }
76 
77 }//namespace Utils
78 }//namespace SeComLib
boost::property_tree::ptree propertyTree
The internal mapping of the XML configuration file.
Definition: config.h:67
static Config & GetInstance()
Returns a reference to the singleton.
Definition: config.cpp:48
Definition of class Config.
static const std::string xmlRootElementName
The name of the root node in the configuration XML file.
Definition: config.h:73
static std::string configFile
The location of the configuration file.
Definition: config.h:70
Utilitary class for parsing the configuration file.
Definition: config.h:49
static void SetConfigFile(const std::string &configFile)
Sets the location and name of the configuration file.
Definition: config.cpp:56