Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Parameters Class Reference

Provides the input data and references to input files used in OREApp. More...

#include <orea/app/parameters.hpp>

+ Inheritance diagram for Parameters:
+ Collaboration diagram for Parameters:

Public Member Functions

 Parameters ()
 
void clear ()
 
void fromFile (const string &)
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
bool hasGroup (const string &groupName) const
 
bool has (const string &groupName, const string &paramName) const
 
string get (const string &groupName, const string &paramName, bool fail=true) const
 
const map< string, string > & data (const string &groupName) const
 
const map< string, string > & markets () const
 
void log ()
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const=0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 
std::string toXMLString () const
 

Private Attributes

map< string, map< string, string > > data_
 

Detailed Description

Provides the input data and references to input files used in OREApp.

Definition at line 40 of file parameters.hpp.

Constructor & Destructor Documentation

◆ Parameters()

Definition at line 42 of file parameters.hpp.

42{}

Member Function Documentation

◆ clear()

void clear ( )

Definition at line 73 of file parameters.cpp.

73{ data_.clear(); }
map< string, map< string, string > > data_
Definition: parameters.hpp:58
+ Here is the caller graph for this function:

◆ fromFile()

void fromFile ( const string &  fileName)

Definition at line 65 of file parameters.cpp.

65 {
66 LOG("load ORE configuration from " << fileName);
67 clear();
68 XMLDocument doc(fileName);
69 fromXML(doc.getFirstNode("ORE"));
70 LOG("load ORE configuration from " << fileName << " done.");
71}
virtual void fromXML(XMLNode *node) override
Definition: parameters.cpp:75
#define LOG(text)
+ Here is the call graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 75 of file parameters.cpp.

75 {
76 XMLUtils::checkNode(node, "ORE");
77
78 XMLNode* setupNode = XMLUtils::getChildNode(node, "Setup");
79 QL_REQUIRE(setupNode, "node Setup not found in parameter file");
80 map<string, string> setupMap;
81 for (XMLNode* child = XMLUtils::getChildNode(setupNode); child; child = XMLUtils::getNextSibling(child)) {
82 string key = XMLUtils::getAttribute(child, "name");
83 string value = XMLUtils::getNodeValue(child);
84 setupMap[key] = value;
85 }
86 data_["setup"] = setupMap;
87
88 XMLNode* loggingNode = XMLUtils::getChildNode(node, "Logging");
89 if (loggingNode) {
90 map<string, string> loggingMap;
91 for (XMLNode* child = XMLUtils::getChildNode(loggingNode); child; child = XMLUtils::getNextSibling(child)) {
92 string key = XMLUtils::getAttribute(child, "name");
93 string value = XMLUtils::getNodeValue(child);
94 loggingMap[key] = value;
95 }
96 data_["logging"] = loggingMap;
97 }
98
99 XMLNode* marketsNode = XMLUtils::getChildNode(node, "Markets");
100 if (marketsNode) {
101 map<string, string> marketsMap;
102 for (XMLNode* child = XMLUtils::getChildNode(marketsNode); child; child = XMLUtils::getNextSibling(child)) {
103 string key = XMLUtils::getAttribute(child, "name");
104 string value = XMLUtils::getNodeValue(child);
105 marketsMap[key] = value;
106 }
107 data_["markets"] = marketsMap;
108 }
109
110 XMLNode* analyticsNode = XMLUtils::getChildNode(node, "Analytics");
111 if (analyticsNode) {
112 for (XMLNode* child = XMLUtils::getChildNode(analyticsNode); child; child = XMLUtils::getNextSibling(child)) {
113 string groupName = XMLUtils::getAttribute(child, "type");
114 map<string, string> analyticsMap;
115 for (XMLNode* paramNode = XMLUtils::getChildNode(child); paramNode;
116 paramNode = XMLUtils::getNextSibling(paramNode)) {
117 string key = XMLUtils::getAttribute(paramNode, "name");
118 string value = XMLUtils::getNodeValue(paramNode);
119 analyticsMap[key] = value;
120 }
121 data_[groupName] = analyticsMap;
122 }
123 }
124}
static string getAttribute(XMLNode *node, const string &attrName)
static void checkNode(XMLNode *n, const string &expectedName)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
SafeStack< ValueType > value
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 126 of file parameters.cpp.

126 {
127 XMLNode* node = doc.allocNode("ORE");
128 QL_FAIL("Parameters::toXML not implemented yet");
129 return node;
130}
+ Here is the call graph for this function:

◆ hasGroup()

bool hasGroup ( const string &  groupName) const

Definition at line 32 of file parameters.cpp.

32{ return (data_.find(groupName) != data_.end()); }
+ Here is the caller graph for this function:

◆ has()

bool has ( const string &  groupName,
const string &  paramName 
) const

Definition at line 34 of file parameters.cpp.

34 {
35 QL_REQUIRE(hasGroup(groupName), "param group '" << groupName << "' not found");
36 auto it = data_.find(groupName);
37 return (it->second.find(paramName) != it->second.end());
38}
bool hasGroup(const string &groupName) const
Definition: parameters.cpp:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

string get ( const string &  groupName,
const string &  paramName,
bool  fail = true 
) const

Definition at line 40 of file parameters.cpp.

40 {
41 if (fail) {
42 QL_REQUIRE(has(groupName, paramName), "parameter " << paramName << " not found in param group " << groupName);
43 auto it = data_.find(groupName);
44 return it->second.find(paramName)->second;
45 } else {
46 if (!hasGroup(groupName) || !has(groupName,paramName))
47 return "";
48 else {
49 auto it = data_.find(groupName);
50 return it->second.find(paramName)->second;
51 }
52 }
53}
bool has(const string &groupName, const string &paramName) const
Definition: parameters.cpp:34
+ Here is the call graph for this function:

◆ data()

const map< string, string > & data ( const string &  groupName) const

Definition at line 55 of file parameters.cpp.

55 {
56 auto it = data_.find(groupName);
57 QL_REQUIRE(it != data_.end(), "param group '" << groupName << "' not found");
58 return it->second;
59}
+ Here is the caller graph for this function:

◆ markets()

const map< string, string > & markets ( ) const

Definition at line 61 of file parameters.cpp.

61 {
62 return data("markets");
63}
const map< string, string > & data(const string &groupName) const
Definition: parameters.cpp:55
+ Here is the call graph for this function:

◆ log()

void log ( )

Definition at line 132 of file parameters.cpp.

132 {
133 LOG("Parameters:");
134 for (auto p : data_)
135 for (auto pp : p.second)
136 LOG("group = " << p.first << " : " << pp.first << " = " << pp.second);
137}

Member Data Documentation

◆ data_

map<string, map<string, string> > data_
private

Definition at line 58 of file parameters.hpp.