3 #ifndef INCL_MADARA_RCW_BASE_TRACKER_H 4 #define INCL_MADARA_RCW_BASE_TRACKER_H 18 #include <type_traits> 19 #include <initializer_list> 23 #include "madara/MADARA_export.h" 47 auto get_value(
const std::vector<T> &t,
size_t i) ->
54 template<
typename T,
typename V>
75 virtual void pull() = 0;
81 virtual const char *
get_name()
const = 0;
113 return set(kb,
ref_, std::forward<T>(val));
120 kb.get_context().set_unsafe(ref, std::forward<T>(val),
EvalSettings());
126 typename std::enable_if<std::is_integral<I>::value>::type
128 kb.get_context().set_index_unsafe_impl(ref_, idx, val,
EvalSettings());
134 typename std::enable_if<std::is_floating_point<I>::value>::type
136 kb.get_context().set_index_unsafe_impl(ref_, idx, val,
EvalSettings());
153 template<
class,
class,
bool,
bool,
class>
156 template<
class,
class,
bool,
bool,
class>
166 #define MADARA_MAKE_SUPPORT_TEST(name, var, expr) template <typename T> \ 167 struct supports_##name##_impl { \ 168 template<typename U> static auto test(U *var) -> decltype((expr), std::true_type()); \ 169 template<typename U> static auto test(...) -> std::false_type; \ 170 using type = decltype(test<T>(0)); \ 172 template <typename T> struct supports_##name : supports_##name##_impl<T>::type {} 202 std::declval<KnowledgeRecord>())));
210 #endif // INCL_MADARA_RCW_BASE_TRACKER_H This class encapsulates an entry in a KnowledgeBase.
utility::ScopedArray< const char > name_
potential string value of the node (size int)
auto set_index(KnowledgeBase &kb, size_t idx, I val) -> typename std::enable_if< std::is_integral< I >::value >::type
Set index in record points to. No locking, so be careful!
bool is_size_dirty(const Tracked< std::vector< T >> &t)
Return size changed dirty flag of Tracked vector.
Manages a Read-Compute-Write cycle for registered variables.
VariableReference ref_
Reference to tracked variable.
KnowledgeRecord & get_mut()
Get record points to. No locking, so be careful!
#define MADARA_MAKE_SUPPORT_TEST(name, var, expr)
Macro which generates feature testing traits, to allow enabling features based on what a given type s...
BaseTracker(VariableReference ref)
Constructor from a VariableReference.
auto set_index(KnowledgeBase &kb, size_t idx, I val) -> typename std::enable_if< std::is_floating_point< I >::value >::type
Set index in record points to. No locking, so be careful!
virtual void force_push(KnowledgeBase &kb)=0
As push, but ignore any modification status tracking.
Optimized reference to a variable within the knowledge base.
bool is_dirty(const Tracked< T > &t)
Returns dirty flag of Tracked types.
virtual const char * get_name() const =0
Get name of MADARA variable.
O knowledge_cast(const KnowledgeRecord &in)
By default, call constructor of target class; for other semantics, define specializations.
void post_set(KnowledgeBase &kb, const VariableReference &ref)
Call after setting to perform any necessary after-setting logic.
virtual const void * get_tracked() const =0
Get pointer to tracked object.
virtual void push(KnowledgeBase &kb)=0
Override to implement pushing logic (into ref_)
T * get_ptr(void)
get the underlying pointer
bool is_all_dirty(const Tracked< std::vector< T >> &t)
Return global dirty flag of Tracked vector.
void clear_dirty(Tracked< T > &t)
Clears dirty flag of Tracked types.
This class provides a distributed knowledge base to users.
Tracker which puts variable values into a single KnowledgeRecord.
Tracker that puts values into a multiple prefixed KnowledgeRecords.
const T & get_value(const T &t)
Fallback definition of get_value; simply passes through the value.
ThreadSafeContext & get_context(void)
Returns the ThreadSafeContext associated with this Knowledge Base.
Encapsulates settings for an evaluation statement.
Provides functions and classes for the distributed knowledge base.
static KnowledgeRecord & get_mut(const VariableReference &ref)
Get record points to. No locking, so be careful!
knowledge::KnowledgeRecord * record_
Reference to knowledge record.
void set_value(T &t, const T &v)
Fallback definition of set_value; simply passes through the value.
Copyright (c) 2015 Carnegie Mellon University.
virtual void pull()=0
Override to implement pulling logic (from ref_)
void mark_and_signal(const char *name, knowledge::KnowledgeRecord *record, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
method for marking a record modified and signaling changes
void post_set(KnowledgeBase &kb)
Call after setting to perform any necessary after-setting logic.