MADARA  3.4.1
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:
39 
44 
49 
51  virtual madara::knowledge::KnowledgeRecord item(void) const;
52 
57 
59  int set(
60  double value, const madara::knowledge::KnowledgeUpdateSettings& settings =
62 
64  int set(const madara::knowledge::KnowledgeRecord& value,
67 
71  virtual madara::knowledge::KnowledgeRecord prune(bool& can_change);
72 
77 
81  std::string expand_key(void) const;
82 
84  const std::string& key(void) const;
85 
87  virtual void accept(Visitor& visitor) const;
88 
95  {
96  if (ref_.is_valid())
97  return ref_.get_record_unsafe();
98  else
99  return context_.get_record(expand_key());
100  }
101 
102 private:
104 
107 
109 
112 
113  std::vector<std::string> splitters_;
114  std::vector<std::string> tokens_;
115  std::vector<std::string> pivot_list_;
116 
118 };
119 }
120 }
121 
122 #endif // _MADARA_NO_KARL_
123 
124 #endif /* _MADARA_COMPOSITE_ARRAY_REFERENCE_ */
An abstract base class defines a simple abstract implementation of an expression tree node.
Definition: ComponentNode.h:37
Defines a terminal node of that references the current value stored in a variable.
std::string key_
Key for retrieving value of this variable.
std::string expand_key(void) const
Expands the key (if necessary).
const std::string & key(void) const
Return the variable key.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the node and its children.
madara::knowledge::KnowledgeRecord * get_record(void)
Retrieves the underlying knowledge::KnowledgeRecord in the context (useful for system calls).
CompositeArrayReference(const std::string &key, ComponentNode *index, madara::knowledge::ThreadSafeContext &context)
Constructor.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prune the tree of unnecessary nodes.
knowledge::KnowledgeRecord inc(const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Sets the value stored in the node.
madara::knowledge::ThreadSafeContext & context_
virtual void accept(Visitor &visitor) const
Define the accept() operation used for the Visitor pattern.
int set(const madara::knowledge::KnowledgeRecord::Integer &value, const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Sets the value stored in the node.
virtual madara::knowledge::KnowledgeRecord item(void) const
Return the item stored in the node.
madara::knowledge::VariableReference ref_
knowledge::KnowledgeRecord dec(const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Sets the value stored in the node.
Encapsulates a single expression tree.
Abstract base class for all visitors to all classes that derive from ComponentNode.
Definition: Visitor.h:93
This class encapsulates an entry in a KnowledgeBase.
Settings for applying knowledge updates.
This class stores variables and their values for use by any entity needing state information in a thr...
KnowledgeRecord * get_record(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Retrieves a knowledge record from the key.
Optimized reference to a variable within the knowledge base.
bool is_valid(void) const
Checks to see if the variable reference has been initialized.
KnowledgeRecord * get_record_unsafe(void) const
Returns a pointer to the variable's KnowledgeRecord Do not use this pointer unless you've locked the ...
constexpr string_t string
Copyright(c) 2020 Galois.