MADARA
3.1.8
Main Page
Namespaces
Classes
Files
File List
File Members
SystemCallGetTime.cpp
Go to the documentation of this file.
1
2
#ifndef _MADARA_NO_KARL_
3
4
5
#include "
madara/expression/LeafNode.h
"
6
#include "
madara/expression/SystemCallGetTime.h
"
7
#include "
madara/knowledge/ThreadSafeContext.h
"
8
#include "
madara/expression/Visitor.h
"
9
#include "
madara/utility/Utility.h
"
10
11
12
madara::expression::SystemCallGetTime::SystemCallGetTime
(
13
madara::knowledge::ThreadSafeContext
& context,
14
const
ComponentNodes
& nodes)
15
:
SystemCallNode
(context, nodes)
16
{
17
18
}
19
20
// Dtor
21
madara::expression::SystemCallGetTime::~SystemCallGetTime
(
void
)
22
{
23
}
24
25
madara::knowledge::KnowledgeRecord
26
madara::expression::SystemCallGetTime::item
(
void
)
const
27
{
28
return
madara::knowledge::KnowledgeRecord
(
nodes_
.size ());
29
}
30
34
madara::knowledge::KnowledgeRecord
35
madara::expression::SystemCallGetTime::prune
(
bool
& can_change)
36
{
37
// user can always change a function, and we have no control over
38
// what it does. Consequently, a function node cannot be pruned out
39
// under any situation
40
can_change =
true
;
41
42
madara::knowledge::KnowledgeRecord
result;
43
44
if
(
nodes_
.size () > 0)
45
{
46
bool
arg_can_change =
false
;
47
result =
nodes_
[0]->prune (arg_can_change);
48
49
if
(!arg_can_change && dynamic_cast <LeafNode *> (
nodes_
[0]) == 0)
50
{
51
delete
nodes_
[0];
52
nodes_
[0] =
new
LeafNode
(*(this->
logger_
), result);
53
}
54
}
55
56
return
result;
57
}
58
61
madara::knowledge::KnowledgeRecord
62
madara::expression::SystemCallGetTime::evaluate
(
63
const
madara::knowledge::KnowledgeUpdateSettings
&
/*settings*/
)
64
{
65
madara_logger_ptr_log
(
logger_
,
logger::LOG_MINOR
,
66
"System call get_time is returning the system clock\n"
);
67
68
return
madara::knowledge::KnowledgeRecord
(
69
madara::utility::get_time
());
70
}
71
72
// accept a visitor
73
void
74
madara::expression::SystemCallGetTime::accept
(
75
madara::expression::Visitor
&visitor)
const
76
{
77
visitor.
visit
(*
this
);
78
}
79
80
#endif // _MADARA_NO_KARL_
madara::knowledge::KnowledgeRecord
This class encapsulates an entry in a KnowledgeBase.
Definition:
KnowledgeRecord.h:60
SystemCallGetTime.h
KnowledgeRecord
madara::knowledge::KnowledgeRecord KnowledgeRecord
Definition:
VariableCompareNode.cpp:8
madara::expression::CompositeTernaryNode::nodes_
ComponentNodes nodes_
Definition:
CompositeTernaryNode.h:76
madara::expression::ComponentNodes
std::deque< ComponentNode * > ComponentNodes
a vector of Component Nodes
Definition:
ComponentNode.h:100
madara::utility::get_time
MADARA_Export int64_t get_time(void)
Returns a time of day in nanoseconds.
Definition:
Utility.cpp:805
madara::expression::ComponentNode::logger_
logger::Logger * logger_
handle the context
Definition:
ComponentNode.h:96
ThreadSafeContext.h
madara::knowledge::ThreadSafeContext
This class stores variables and their values for use by any entity needing state information in a thr...
Definition:
ThreadSafeContext.h:82
madara::expression::SystemCallGetTime::prune
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
Definition:
SystemCallGetTime.cpp:35
madara::expression::LeafNode
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value. ...
Definition:
LeafNode.h:23
madara::expression::SystemCallGetTime::evaluate
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
Definition:
SystemCallGetTime.cpp:62
madara::expression::SystemCallGetTime::~SystemCallGetTime
virtual ~SystemCallGetTime(void)
Destructor.
Definition:
SystemCallGetTime.cpp:21
madara_logger_ptr_log
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Definition:
Logger.h:32
madara::expression::Visitor
Abstract base class for all visitors to all classes that derive from ComponentNode.
Definition:
Visitor.h:90
LeafNode.h
madara::expression::SystemCallNode
Interface for a MADARA system call.
Definition:
SystemCallNode.h:25
madara::expression::SystemCallGetTime::SystemCallGetTime
SystemCallGetTime(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
Definition:
SystemCallGetTime.cpp:12
madara::logger::LOG_MINOR
Definition:
Logger.h:77
Visitor.h
madara::knowledge::KnowledgeUpdateSettings
Settings for applying knowledge updates.
Definition:
KnowledgeUpdateSettings.h:23
madara::expression::Visitor::visit
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.
Utility.h
madara::expression::SystemCallGetTime::accept
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
Definition:
SystemCallGetTime.cpp:74
madara::expression::SystemCallGetTime::item
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
Definition:
SystemCallGetTime.cpp:26
include
madara
expression
SystemCallGetTime.cpp
Generated on Wed May 9 2018 18:17:14 for MADARA by
1.8.11