MADARA  3.1.8
CompositeArrayReference.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef _MADARA_COMPOSITE_ARRAY_REFERENCE_
3 #define _MADARA_COMPOSITE_ARRAY_REFERENCE_
4 
5 #ifndef _MADARA_NO_KARL_
6 
7 #include <string>
8 #include <vector>
9 
14 
15 namespace madara
16 {
17  namespace expression
18  {
19  // Forward declarations.
20  class Visitor;
21 
29  {
30  public:
38  const std::string &key, ComponentNode * index,
40 
42  virtual ~CompositeArrayReference (void);
43 
48 
53 
55  virtual madara::knowledge::KnowledgeRecord item (void) const;
56 
58  int set (const madara::knowledge::KnowledgeRecord::Integer & value,
61 
63  int set (double value,
66 
68  int set (const madara::knowledge::KnowledgeRecord & value,
71 
75  virtual madara::knowledge::KnowledgeRecord prune (bool & can_change);
76 
81 
85  std::string expand_key (void) const;
86 
88  const std::string & key (void) const;
89 
91  virtual void accept (Visitor &visitor) const;
92 
98  inline
100  {
101  if (record_)
102  return record_;
103  else
104  return context_.get_record (expand_key ());
105  }
106 
107  private:
111 
113 
116 
117  std::vector< std::string> splitters_;
118  std::vector< std::string> tokens_;
119  std::vector< std::string> pivot_list_;
120 
122  };
123  }
124 }
125 
126 #endif // _MADARA_NO_KARL_
127 
128 #endif /* _MADARA_COMPOSITE_ARRAY_REFERENCE_ */
This class encapsulates an entry in a KnowledgeBase.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prune the tree of unnecessary nodes.
const std::string key_
Key for retrieving value of this variable.
knowledge::KnowledgeRecord inc(const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Sets the value stored in the node.
const std::string & key(void) const
Return the variable key.
This class stores variables and their values for use by any entity needing state information in a thr...
virtual void accept(Visitor &visitor) const
Define the accept() operation used for the Visitor pattern.
virtual madara::knowledge::KnowledgeRecord item(void) const
Return the item stored in the node.
madara::knowledge::KnowledgeRecord * record_
madara::knowledge::KnowledgeRecord * get_record(void)
Retrieves the underlying knowledge::KnowledgeRecord in the context (useful for system calls)...
An abstract base class defines a simple abstract implementation of an expression tree node...
Definition: ComponentNode.h:35
Abstract base class for all visitors to all classes that derive from ComponentNode.
Definition: Visitor.h:90
static constexpr struct madara::knowledge::tags::string_t string
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the node and its children.
CompositeArrayReference(const std::string &key, ComponentNode *index, madara::knowledge::ThreadSafeContext &context)
Constructor.
knowledge::KnowledgeRecord dec(const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Sets the value stored in the node.
KnowledgeRecord * get_record(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Retrieves a knowledge record from the key.
madara::knowledge::ThreadSafeContext & context_
Settings for applying knowledge updates.
Encapsulates a single expression tree.
Copyright (c) 2015 Carnegie Mellon University.
std::string expand_key(void) const
Expands the key (if necessary).
Defines a terminal node of that references the current value stored in a variable.