MADARA  3.4.1
madara::expression::SystemCallGeneric Class Reference

General purpose system call KaRL node. More...

#include <SystemCallGeneric.h>

Inheritance diagram for madara::expression::SystemCallGeneric:
madara::expression::SystemCallNode madara::expression::CompositeTernaryNode madara::expression::ComponentNode

Public Types

using fn_signature = madara::knowledge::KnowledgeRecord(std::vector< madara::knowledge::KnowledgeRecord >)
 
using fn_type = std::function< fn_signature >
 

Public Member Functions

 SystemCallGeneric (madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes, const char *name, fn_type fn)
 Constructor. More...
 
virtual void accept (Visitor &visitor) const
 Accepts a visitor subclassed from the Visitor class. More...
 
virtual madara::knowledge::KnowledgeRecord evaluate (const madara::knowledge::KnowledgeUpdateSettings &settings)
 Evaluates the expression tree. More...
 
virtual madara::knowledge::KnowledgeRecord item (void) const
 Returns the value of the node. More...
 
virtual ComponentNodeleft (void) const
 Returns the left expression. More...
 
const char * name () const
 
virtual madara::knowledge::KnowledgeRecord prune (bool &can_change)
 Prunes the expression tree of unnecessary nodes. More...
 
virtual ComponentNoderight (void) const
 Returns the right expression. More...
 
void set_logger (logger::Logger &logger)
 Sets the logger for printing errors and debugging info. More...
 

Protected Attributes

madara::knowledge::ThreadSafeContextcontext_
 
logger::Loggerlogger_
 handle the context More...
 
ComponentNodes nodes_
 

Private Attributes

fn_type fn_
 
const char * name_
 

Detailed Description

General purpose system call KaRL node.

Construct with the function name, and a callable (that accepts std::vector<KnowledgeRecord>, and returns KnowledgeRecord).

Does not do pruning, as it cannot know what the callable does. If your system call can make good use of prune, you should write a custom node instead.

Definition at line 26 of file SystemCallGeneric.h.

Member Typedef Documentation

◆ fn_signature

◆ fn_type

Definition at line 32 of file SystemCallGeneric.h.

Constructor & Destructor Documentation

◆ SystemCallGeneric()

madara::expression::SystemCallGeneric::SystemCallGeneric ( madara::knowledge::ThreadSafeContext context,
const ComponentNodes nodes,
const char *  name,
fn_type  fn 
)
inline

Constructor.

Definition at line 37 of file SystemCallGeneric.h.

Member Function Documentation

◆ accept()

virtual void madara::expression::SystemCallGeneric::accept ( Visitor visitor) const
inlinevirtual

Accepts a visitor subclassed from the Visitor class.

Parameters
visitorvisitor instance to use

Reimplemented from madara::expression::SystemCallNode.

Definition at line 85 of file SystemCallGeneric.h.

◆ evaluate()

virtual madara::knowledge::KnowledgeRecord madara::expression::SystemCallGeneric::evaluate ( const madara::knowledge::KnowledgeUpdateSettings settings)
inlinevirtual

Evaluates the expression tree.

Returns
value of current contained expression tree

Implements madara::expression::SystemCallNode.

Definition at line 69 of file SystemCallGeneric.h.

◆ item()

virtual madara::knowledge::KnowledgeRecord madara::expression::SystemCallGeneric::item ( void  ) const
inlinevirtual

Returns the value of the node.

Returns
value of the node

Reimplemented from madara::expression::SystemCallNode.

Definition at line 47 of file SystemCallGeneric.h.

◆ left()

madara::expression::ComponentNode * madara::expression::ComponentNode::left ( void  ) const
virtualinherited

Returns the left expression.

Returns
a pointer to the left expression

Reimplemented in madara::expression::CompositeBinaryNode.

Definition at line 29 of file ComponentNode.cpp.

◆ name()

const char* madara::expression::SystemCallGeneric::name ( ) const
inline

Definition at line 90 of file SystemCallGeneric.h.

◆ prune()

virtual madara::knowledge::KnowledgeRecord madara::expression::SystemCallGeneric::prune ( bool &  can_change)
inlinevirtual

Prunes the expression tree of unnecessary nodes.

This implementation assumes it can always change, so does not prune.

Parameters
can_changeset to true if variable nodes are contained
Returns
value of current contained expression tree

Implements madara::expression::SystemCallNode.

Definition at line 59 of file SystemCallGeneric.h.

◆ right()

madara::expression::ComponentNode * madara::expression::ComponentNode::right ( void  ) const
virtualinherited

Returns the right expression.

Returns
a pointer to the right expression

Reimplemented in madara::expression::CompositeUnaryNode.

Definition at line 36 of file ComponentNode.cpp.

◆ set_logger()

void madara::expression::ComponentNode::set_logger ( logger::Logger logger)
inherited

Sets the logger for printing errors and debugging info.

Parameters
loggerthe logger to use

Definition at line 48 of file ComponentNode.cpp.

Member Data Documentation

◆ context_

madara::knowledge::ThreadSafeContext& madara::expression::SystemCallNode::context_
protectedinherited

Definition at line 70 of file SystemCallNode.h.

◆ fn_

fn_type madara::expression::SystemCallGeneric::fn_
private

Definition at line 97 of file SystemCallGeneric.h.

◆ logger_

logger::Logger* madara::expression::ComponentNode::logger_
protectedinherited

handle the context

Definition at line 96 of file ComponentNode.h.

◆ name_

const char* madara::expression::SystemCallGeneric::name_
private

Definition at line 96 of file SystemCallGeneric.h.

◆ nodes_

ComponentNodes madara::expression::CompositeTernaryNode::nodes_
protectedinherited

Definition at line 74 of file CompositeTernaryNode.h.


The documentation for this class was generated from the following file: