1 #include <samchon/namtree/NTCriteria.hpp> 2 # include <samchon/namtree/NTSide.hpp> 4 #include <samchon/namtree/NTFactory.hpp> 5 #include <samchon/namtree/NTIterator.hpp> 7 #include <samchon/library/XML.hpp> 16 auto NTCriteria::TAG() const ->
string {
return "criteria"; }
17 auto NTCriteria::CHILD_TAG() const ->
string {
return "criteria"; }
22 this->factory = factory;
23 this->parent = parent;
25 leftSide =
new NTSide(factory);
26 rightSide =
new NTSide(factory);
28 NTCriteria::~NTCriteria()
34 void NTCriteria::construct(shared_ptr<XML> xml)
36 super::construct(xml);
38 leftSide->construct(xml->get(
"side")->at(0));
39 rightSide->construct(xml->get(
"side")->at(1));
41 operator_ = xml->getProperty<
int>(
"operator");
42 weight = xml->getProperty<
int>(
"weight");
44 auto NTCriteria::createChild(shared_ptr<XML> xml) ->
NTCriteria*
49 void NTCriteria::initRetrieve()
51 leftSide->initRetrieve();
52 rightSide->initRetrieve();
54 for (
size_t i = 0; i < size(); i++)
55 at(i)->initRetrieve();
57 auto NTCriteria::calcRetrieved(
NTIterator &iterator)
const ->
double 59 double left = leftSide->calcRetrieved(iterator);
60 double right = rightSide->calcRetrieved(iterator);
64 (operator_ <= LESS_EQUAL && left < right) ||
65 ((LESS_EQUAL <= operator_ && operator_ <= LARGER_EQUAL) && left == right) ||
66 (LARGER_EQUAL <= operator_)
70 auto NTCriteria::toXML() const -> shared_ptr<
XML>
72 shared_ptr<XML> &xml = super::toXML();
73 xml->push_back( leftSide->toXML() );
74 xml->push_back( rightSide->toXML() );
76 xml->setProperty(
"operator", operator_);
77 xml->setProperty(
"weight", weight);
A factory for Nam-Tree objects.
An Entity and a container of children Entity objects.
Iterator of historical data.
Package of network protocol and libraries.
virtual auto createCriteria(NTCriteria *, std::shared_ptr< library::XML >) -> NTCriteria *
Factory method of a NTCriteria.
XML is a class representing xml object.
Top level namespace of products built from samchon.
A side of a conditional expresson.
Criteria, a conditional expression with weight.