MADARA  3.4.1
LeafNode.cpp
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef _LEAF_NODE_CPP_
3 #define _LEAF_NODE_CPP_
4 
5 #ifndef _MADARA_NO_KARL_
6 
7 #include <iostream>
8 
12 
13 // Ctor
16  : ComponentNode(logger), item_(item)
17 {
18 }
19 
20 // Ctor
24 {
26 }
27 
28 // Ctor
30  logger::Logger& logger, const std::string& item)
32 {
34 }
35 
36 // Ctor
39 {
41 }
42 
43 // Dtor
45 
46 // return the item
48  void) const
49 {
50  return item_;
51 }
52 
57  bool& can_change)
58 {
59  can_change = false;
60 
61  // we could call item(), but since it is virtual, it incurs unnecessary
62  // overhead.
63  return item_;
64 }
65 
70 {
71  // we could call item(), but since it is virtual, it incurs unnecessary
72  // overhead.
73  return item_;
74 }
75 
77 {
78  visitor.visit(*this);
79 }
80 
81 #endif // _MADARA_NO_KARL_
82 
83 #endif /* _LEAF_NODE_CPP_ */
An abstract base class defines a simple abstract implementation of an expression tree node.
Definition: ComponentNode.h:37
madara::knowledge::KnowledgeRecord item_
Integer value associated with the operand.
Definition: LeafNode.h:89
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the printable value of the node.
Definition: LeafNode.cpp:47
virtual ~LeafNode(void)
Destructor.
Definition: LeafNode.cpp:44
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
Definition: LeafNode.cpp:68
LeafNode(logger::Logger &logger, const knowledge::KnowledgeRecord &item)
Constructor.
Definition: LeafNode.cpp:14
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
Definition: LeafNode.cpp:56
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
Definition: LeafNode.cpp:76
Abstract base class for all visitors to all classes that derive from ComponentNode.
Definition: Visitor.h:93
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.
This class encapsulates an entry in a KnowledgeBase.
void set_value(const KnowledgeRecord &new_value)
Sets the value from another KnowledgeRecord, does not copy toi, clock, and write_quality.
Settings for applying knowledge updates.
A multi-threaded logger for logging to one or more destinations.
Definition: Logger.h:165
constexpr string_t string
Provides knowledge logging services to files and terminals.
Definition: GlobalLogger.h:12