MADARA
3.1.8
Main Page
Namespaces
Classes
Files
File List
File Members
SystemCallGetTimeSeconds.cpp
Go to the documentation of this file.
1
2
#ifndef _MADARA_NO_KARL_
3
4
#include <time.h>
5
#include "
madara/expression/LeafNode.h
"
6
#include "
madara/expression/SystemCallGetTimeSeconds.h
"
7
#include "
madara/knowledge/ThreadSafeContext.h
"
8
#include "
madara/expression/Visitor.h
"
9
#include "
madara/utility/Utility.h
"
10
11
12
madara::expression::SystemCallGetTimeSeconds::SystemCallGetTimeSeconds
(
13
madara::knowledge::ThreadSafeContext
& context,
14
const
ComponentNodes
& nodes)
15
:
SystemCallNode
(context, nodes)
16
{
17
18
}
19
20
// Dtor
21
madara::expression::SystemCallGetTimeSeconds::~SystemCallGetTimeSeconds
(
void
)
22
{
23
}
24
25
madara::knowledge::KnowledgeRecord
26
madara::expression::SystemCallGetTimeSeconds::item
(
void
)
const
27
{
28
return
madara::knowledge::KnowledgeRecord
(
nodes_
.size ());
29
}
30
34
madara::knowledge::KnowledgeRecord
35
madara::expression::SystemCallGetTimeSeconds::prune
(
bool
& can_change)
36
{
37
// Time changes. No way to prune this node out.
38
can_change =
true
;
39
40
madara::knowledge::KnowledgeRecord
result;
41
42
if
(
nodes_
.size () > 0)
43
{
44
bool
arg_can_change =
false
;
45
result =
nodes_
[0]->prune (arg_can_change);
46
47
if
(!arg_can_change && dynamic_cast <LeafNode *> (
nodes_
[0]) == 0)
48
{
49
delete
nodes_
[0];
50
nodes_
[0] =
new
LeafNode
(*(this->
logger_
), result);
51
}
52
}
53
54
return
result;
55
}
56
59
madara::knowledge::KnowledgeRecord
60
madara::expression::SystemCallGetTimeSeconds::evaluate
(
61
const
madara::knowledge::KnowledgeUpdateSettings
&
/*settings*/
)
62
{
63
madara_logger_ptr_log
(
logger_
,
logger::LOG_MINOR
,
64
"System call get_time_seconds is returning the system clock\n"
);
65
66
return
madara::knowledge::KnowledgeRecord
(
67
time (NULL));
68
}
69
70
// accept a visitor
71
void
72
madara::expression::SystemCallGetTimeSeconds::accept
(
73
madara::expression::Visitor
&visitor)
const
74
{
75
visitor.
visit
(*
this
);
76
}
77
78
#endif // _MADARA_NO_KARL_
madara::knowledge::KnowledgeRecord
This class encapsulates an entry in a KnowledgeBase.
Definition:
KnowledgeRecord.h:60
madara::expression::SystemCallGetTimeSeconds::~SystemCallGetTimeSeconds
virtual ~SystemCallGetTimeSeconds(void)
Destructor.
Definition:
SystemCallGetTimeSeconds.cpp:21
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::expression::SystemCallGetTimeSeconds::accept
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
Definition:
SystemCallGetTimeSeconds.cpp:72
madara::expression::SystemCallGetTimeSeconds::item
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
Definition:
SystemCallGetTimeSeconds.cpp:26
madara::expression::ComponentNode::logger_
logger::Logger * logger_
handle the context
Definition:
ComponentNode.h:96
madara::expression::SystemCallGetTimeSeconds::prune
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
Definition:
SystemCallGetTimeSeconds.cpp:35
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::LeafNode
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value. ...
Definition:
LeafNode.h:23
SystemCallGetTimeSeconds.h
madara::expression::SystemCallGetTimeSeconds::evaluate
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
Definition:
SystemCallGetTimeSeconds.cpp:60
madara::expression::SystemCallGetTimeSeconds::SystemCallGetTimeSeconds
SystemCallGetTimeSeconds(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
Definition:
SystemCallGetTimeSeconds.cpp:12
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::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
include
madara
expression
SystemCallGetTimeSeconds.cpp
Generated on Wed May 9 2018 18:17:14 for MADARA by
1.8.11