MADARA  3.2.3
VariableReference.h
Go to the documentation of this file.
1 #ifndef _MADARA_VARIABLE_REFERENCE_H_
2 #define _MADARA_VARIABLE_REFERENCE_H_
3 
4 
13 #include <string>
14 #include <cstring>
15 #include "madara/MadaraExport.h"
18 
19 namespace madara
20 {
21  namespace knowledge
22  {
23  class ThreadSafeContext;
24  class KnolwedgeBaseImpl;
25  class Variables;
26 
27  namespace rcw
28  {
29  class BaseTracker;
30  }
31 
36  class MADARA_EXPORT VariableReference
37  {
38  public:
39  friend class ThreadSafeContext;
40  friend class KnowledgeBaseImpl;
41  friend class Variables;
42  friend class rcw::BaseTracker;
43 
44  using pair_ptr = KnowledgeMap::value_type *;
45 
49  VariableReference () = default;
50 
55 
60  bool is_valid (void) const;
61 
66  bool operator== (const VariableReference & rhs) const;
67 
72  bool operator!= (const VariableReference & rhs) const;
73 
80  const char * get_name (void) const;
81 
89  KnowledgeRecord *get_record_unsafe (void) const;
90 
94  void assign (pair_ptr entry);
95 
96  private:
97  pair_ptr entry_ = nullptr;
98  };
99 
101  typedef std::vector <VariableReference> VariableReferences;
102 
104  {
105  bool operator()(const char *l, const char *r) const {
106  return std::strcmp(l, r) < 0;
107  }
108  };
109 
111  typedef std::map <const char *, VariableReference,
113  }
114 }
115 
116 #include "VariableReference.inl"
117 
118 #endif // _MADARA_VARIABLE_REFERENCE_H_
This class encapsulates an entry in a KnowledgeBase.
bool operator()(const char *l, const char *r) const
This class provides a distributed knowledge base implementation.
Base type for Trackers.
Definition: BaseTracker.h:63
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.
auto operator==(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()==rhs.get())
Definition: Tracked.h:244
std::map< const char *, VariableReference, VariableReferenceMapCompare > VariableReferenceMap
a map of variable references
std::vector< VariableReference > VariableReferences
a vector of variable references
auto operator!=(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()!=rhs.get())
Definition: Tracked.h:245
KnowledgeMap::value_type * pair_ptr
Provides functions and classes for the distributed knowledge base.
Copyright (c) 2015 Carnegie Mellon University.
Provides an interface for external functions into the MADARA KaRL variable settings.