1 #ifndef _MADARA_VARIABLE_REFERENCE_H_
2 #define _MADARA_VARIABLE_REFERENCE_H_
14 #include "madara/MadaraExport.h"
24 class ThreadSafeContext;
25 class KnolwedgeBaseImpl;
55 bool is_valid(
void)
const;
75 const char* get_name(
void)
const;
99 typedef std::map<const char*, VariableReference, utility::ComparisonLessThan>
134 bool history =
false, uint64_t min_toi = 0)
145 using value_type = std::pair<const char*, const KnowledgeRecord*>;
161 return {
miter_->first,
miter_->second.get_record_unsafe()};
172 auto rec =
miter_->second.get_record_unsafe();
173 auto cbuf = rec->share_circular_buffer();
174 if (cbuf && *
biter_ != cbuf->cend())
205 return !(*
this == o);
230 auto ret = cbuf->cbegin();
236 return lhs < rhs.toi();
240 if (ret == cbuf->cend())
299 return {*
this,
map_.end()};
This class provides a distributed knowledge base implementation.
This class encapsulates an entry in a KnowledgeBase.
bool has_history() const
Return true if this record has a circular buffer history.
std::shared_ptr< CircBuf > share_circular_buffer() const
Get a shared_ptr to the history buffer inside this record.
This class stores variables and their values for use by any entity needing state information in a thr...
Constant Input Iterator over values in the map.
miter_type miter_
Iterator over map members.
std::input_iterator_tag iterator_category
bool operator!=(const const_iterator &o) const
const_iterator(const_iterator &&o)=default
bool operator==(const const_iterator &o) const
VariableReferenceMap::const_iterator miter_type
value_type operator*() const
Gives a pair value (note, not a reference).
const VariableReferenceMapReader * reader_
Reader the iterator belongs to.
const_iterator & operator=(const_iterator &&o)=default
const_iterator(const VariableReferenceMapReader &f)
std::pair< const char *, const KnowledgeRecord * > value_type
const_iterator & operator++()
Increments iterator, to move onto the next record in the map.
const_iterator operator++(int)
Post-Increments iterator, to move onto the next record in the map.
biter_uptr biter_
Iterator over history of current map member, if any exists.
const_iterator(const const_iterator &o)
std::unique_ptr< biter_type > biter_uptr
const_iterator & operator=(const const_iterator &o)
const_iterator(const VariableReferenceMapReader &f, miter_type miter)
Helper class for iterating over VariableReferenceMaps, optionally including history of changed record...
bool history_
True if iteration should include history.
const_iterator end() const
const_iterator begin() const
VariableReferenceMapReader(const VariableReferenceMap &map, bool history=false, uint64_t min_toi=0)
Primary constructor.
const VariableReferenceMap & map_
Map to iterate over.
uint64_t min_toi_
Only iterate updates with TOI > this value.
Optimized reference to a variable within the knowledge base.
VariableReference()=default
Default constructor.
KnowledgeMap::value_type * pair_ptr
Provides an interface for external functions into the MADARA KaRL variable settings.
Const input iterator for elements of a CircularBuffer. Usual semantics.
Provides functions and classes for the distributed knowledge base.
auto operator==(const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l)==r)
std::map< const char *, VariableReference, utility::ComparisonLessThan > VariableReferenceMap
a map of variable references
auto operator!=(const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l) !=r)
std::vector< VariableReference > VariableReferences
a vector of variable references
std::unique_ptr< decay_< T > > into_unique(T &&val)
Converts a typed value into a unique_ptr of a decayed type.
Copyright(c) 2020 Galois.