MADARA  3.4.1
SystemCallGetTimeSeconds.cpp
Go to the documentation of this file.
1 
2 #ifndef _MADARA_NO_KARL_
3 
4 #include <time.h>
10 
13  : SystemCallNode(context, nodes)
14 {
15 }
16 
17 // Dtor
19 
22 {
23  return madara::knowledge::KnowledgeRecord(nodes_.size());
24 }
25 
31 {
32  // Time changes. No way to prune this node out.
33  can_change = true;
34 
36 
37  if (nodes_.size() > 0)
38  {
39  bool arg_can_change = false;
40  result = nodes_[0]->prune(arg_can_change);
41 
42  if (!arg_can_change && dynamic_cast<LeafNode*>(nodes_[0]) == 0)
43  {
44  delete nodes_[0];
45  nodes_[0] = new LeafNode(*(this->logger_), result);
46  }
47  }
48 
49  return result;
50 }
51 
57 {
59  "madara::expression::SystemCallGetTimeSeconds:"
60  "System call get_time_seconds is returning the system clock\n");
61 
62  return madara::knowledge::KnowledgeRecord(time(NULL));
63 }
64 
65 // accept a visitor
67  madara::expression::Visitor& visitor) const
68 {
69  visitor.visit(*this);
70 }
71 
72 #endif // _MADARA_NO_KARL_
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Definition: Logger.h:41
madara::knowledge::KnowledgeRecord KnowledgeRecord
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value.
Definition: LeafNode.h:25
SystemCallGetTimeSeconds(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
Interface for a MADARA system call.
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.
Settings for applying knowledge updates.
This class stores variables and their values for use by any entity needing state information in a thr...
std::deque< ComponentNode * > ComponentNodes
a vector of Component Nodes