Samchon Framework for CPP  1.0.0
NTParameter.cpp
1 #include <samchon/namtree/NTParameter.hpp>
2 # include <samchon/namtree/NTParameterDetermined.hpp>
3 
4 #include <samchon/library/XML.hpp>
5 
6 using namespace std;
7 
8 using namespace samchon;
9 using namespace samchon::library;
10 using namespace samchon::protocol;
11 using namespace samchon::namtree;
12 
13 auto NTParameter::TAG() const -> string { return "parameter"; }
14 auto NTParameter::CHILD_TAG() const -> string { return "parameterDetermined"; }
15 
16 NTParameter::NTParameter()
17  : super(), INTExplore()
18 {
19  initialValue = INT_MIN;
20 }
21 void NTParameter::construct(shared_ptr<XML> xml)
22 {
23  super::construct(xml);
25 
26  name = xml->getProperty("name");
27  if (xml->hasProperty("initialValue"))
28  initialValue = xml->getProperty<double>("initialValue");
29  else
30  initialValue = INT_MIN;
31 }
33 {
34  return new NTParameterDetermined();
35 }
36 
37 auto NTParameter::key() const -> string
38 {
39  return name;
40 }
41 auto NTParameter::getName() const -> string
42 {
43  return name;
44 }
45 auto NTParameter::getInitialValue() const -> double
46 {
47  return initialValue;
48 }
49 
50 auto NTParameter::toXML() const -> shared_ptr<XML>
51 {
52  shared_ptr<XML> &xml = super::toXML();
53  xml->addAllProperty(INTExplore::toXML());
54 
55  xml->setProperty("name", name);
56  if (initialValue != INT_MIN)
57  xml->setProperty("initialValue", initialValue);
58 
59  return xml;
60 }
An entity, a standard data class.
Definition: Entity.hpp:48
double initialValue
An initial, default value.
Definition: NTParameter.hpp:42
std::string name
Name of a paremeter.
Definition: NTParameter.hpp:37
virtual auto key() const -> std::string override
Get a key that can identify the Entity uniquely.
Definition: NTParameter.cpp:37
virtual void construct(std::shared_ptr< library::XML >)
Construct data of the Entity from an XML object.
Definition: INTExplore.cpp:20
Definition: RWMutex.hpp:4
Package of libraries.
Definition: library.hpp:84
An interface for exploration.
Definition: INTExplore.hpp:25
virtual auto toXML() const -> std::shared_ptr< library::XML >
Get an XML object represents the Entity.
Definition: INTExplore.cpp:54
virtual void construct(std::shared_ptr< library::XML >) override
Construct data of the Entity from an XML object.
Definition: NTParameter.cpp:21
virtual auto toXML() const -> std::shared_ptr< library::XML >
Get an XML object represents the EntityGroup.
Package of network protocol and libraries.
Definition: protocol.hpp:185
auto getInitialValue() const -> double
Get initial, default vlaue.
Definition: NTParameter.cpp:45
Package of Nam-Tree.
Definition: namtree.hpp:93
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the Entity.
Definition: NTParameter.cpp:50
auto getName() const -> std::string
Get name.
Definition: NTParameter.cpp:41
virtual auto createChild(std::shared_ptr< library::XML >) -> NTParameterDetermined *override
Factory method of a child Entity.
Definition: NTParameter.cpp:32
XML is a class representing xml object.
Definition: XML.hpp:72
A pre-determined value of a parameter.
virtual void construct(std::shared_ptr< library::XML > xml)
Construct data of the Entity from an XML object.
Definition: EntityGroup.hpp:90
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7