Samchon Framework for CPP  1.0.0
NTSide.cpp
1 #include <samchon/namtree/NTSide.hpp>
2 
3 #include <samchon/namtree/NTFactory.hpp>
4 #include <samchon/namtree/NTFile.hpp>
5 #include <samchon/namtree/NTIterator.hpp>
6 
7 #include <samchon/Map.hpp>
8 #include <samchon/library/XML.hpp>
9 
10 using namespace std;
11 
12 using namespace samchon;
13 using namespace samchon::library;
14 using namespace samchon::protocol;
15 using namespace samchon::namtree;
16 
17 auto NTSide::TAG() const -> string { return "side"; }
18 
19 NTSide::NTSide(NTFactory *factory)
20  : super()
21 {
22  this->factory = factory;
23  file = nullptr;
24 }
25 void NTSide::construct(shared_ptr<XML> xml)
26 {
27 
28  if (xml->hasProperty("parameterArray") == false)
29  return;
30 
31  shared_ptr<XMLList> &parameterList = xml->get("parameterArray");
32  for (auto it = parameterList->begin(); it != parameterList->end(); it++)
33  {
34  shared_ptr<XML> &parameter = *it;
35  string &name = parameter->getProperty("name");
36  string &strValue = parameter->getValue();
37 
38  parameters.push_back
39  (
40  strValue.empty() == false
41  ? stod(strValue)
42  : INT_MIN
43  );
44  }
45 }
46 
47 void NTSide::initRetrieve()
48 {
49 
50 }
51 auto NTSide::calcRetrieved(NTIterator &iterator) const -> double
52 {
53  return file->getFunction()(iterator, parameters);
54 }
55 
56 auto NTSide::toXML() const -> shared_ptr<XML>
57 {
58  shared_ptr<XML> &xml = super::toXML();
59  xml->setProperty("fileUID", file->key());
60 
61  shared_ptr<XML> parameterListXML(new XML());
62  parameterListXML->setTag("parameterArray");
63 
64  for (auto it = parameters.begin(); it != parameters.end(); it++)
65  {
66  shared_ptr<XML> parameter(new XML());
67  parameter->setTag("parameter");
68 
69  if (*it != INT_MIN)
70  continue;
71 
72  parameter->setValue( to_string(*it) );
73  parameterListXML->push_back(parameter);
74  }
75  xml->push_back(parameterListXML);
76 
77  return xml;
78 }
An entity, a standard data class.
Definition: Entity.hpp:48
A factory for Nam-Tree objects.
Definition: NTFactory.hpp:52
Definition: RWMutex.hpp:4
Package of libraries.
Definition: library.hpp:84
Iterator of historical data.
Definition: NTIterator.hpp:26
Package of network protocol and libraries.
Definition: protocol.hpp:185
Package of Nam-Tree.
Definition: namtree.hpp:93
XML is a class representing xml object.
Definition: XML.hpp:72
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7