MADARA  3.2.3
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 
45 
50 
52  virtual madara::knowledge::KnowledgeRecord item (void) const;
53 
55  int set (const madara::knowledge::KnowledgeRecord::Integer & value,
58 
60  int set (double value,
63 
65  int set (const madara::knowledge::KnowledgeRecord & value,
68 
72  virtual madara::knowledge::KnowledgeRecord prune (bool & can_change);
73 
78 
82  std::string expand_key (void) const;
83 
85  const std::string & key (void) const;
86 
88  virtual void accept (Visitor &visitor) const;
89 
95  inline
97  {
98  if (ref_.is_valid())
99  return ref_.get_record_unsafe();
100  else
101  return context_.get_record (expand_key ());
102  }
103 
104  private:
106 
109 
111 
114 
115  std::vector< std::string> splitters_;
116  std::vector< std::string> tokens_;
117  std::vector< std::string> pivot_list_;
118 
120  };
121  }
122 }
123 
124 #endif // _MADARA_NO_KARL_
125 
126 #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.
KnowledgeRecord * get_record_unsafe(void) const
Returns a pointer to the variable&#39;s KnowledgeRecord Do not use this pointer unless you&#39;ve locked the ...
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...
Optimized reference to a variable within the knowledge base.
bool is_valid(void) const
Checks to see if the variable reference has been initialized.
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.
static struct madara::knowledge::tags::string_t string
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:36
Abstract base class for all visitors to all classes that derive from ComponentNode.
Definition: Visitor.h:91
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.
madara::knowledge::ThreadSafeContext & context_
KnowledgeRecord * get_record(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Retrieves a knowledge record from the key.
Settings for applying knowledge updates.
Encapsulates a single expression tree.
Copyright (c) 2015 Carnegie Mellon University.
std::string key_
Key for retrieving value of this variable.
madara::knowledge::VariableReference ref_
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.