MADARA
3.1.8
|
Manages a Read-Compute-Write cycle for registered variables. More...
#include <Transaction.h>
Classes | |
class | Builder |
Builder object returned by build() More... | |
class | InitHandler |
Helper type to enable initialization using initializer_list Fallback implementation for types which do not support initializer_list. More... | |
class | InitHandler< B, I, T, typename std::enable_if< supports_get_value< T >::value &&supports_indexed_get_value< T >::value &&supports_size< T >::value >::type > |
Helper type to enable initialization using initializer_list Specialization for types which do support initializer_list. More... | |
Public Types | |
typedef std::unique_ptr< BaseTracker > | tracker_ptr |
Public Member Functions | |
Transaction (KnowledgeBase kb) | |
The constructor. More... | |
template<class T > | |
void | add (const Builder< T, const char * > &b) |
Add a mapping from a Builder object. More... | |
template<class T , class K > | |
void | add (K &&key, T &val) const |
Add a new default mapping for MADARA variable and reference . More... | |
template<class T , class K > | |
void | add_init (K &&key, T &val) |
Add a new mapping for MADARA variable and reference . More... | |
template<class T , class K > | |
void | add_prefix (K &&prefix, T &val) const |
Add a new prefix-based mapping for MADARA variable and ref . More... | |
template<class T , class K > | |
void | add_prefix_init (K &&prefix, T &val) |
Add a new prefix-based mapping for MADARA variable and ref . More... | |
void | add_tracker (tracker_ptr t) const |
Add a tracker object directly. More... | |
template<class T , class K > | |
Builder< T, const char * > | build (K &&key, T &val) |
Create a new mapping, using the Builder interface. More... | |
void | pull (void) |
Call to update values of registered variables from the knowledge base. More... | |
void | push (void) |
Call to push all values of registered variables into the knowledge base. More... | |
bool | remove (const char *name) const |
Remove a mapping by name. More... | |
bool | remove (const std::string &name) const |
Remove a mapping by name. More... | |
template<class T > | |
bool | remove (const T *var) const |
Remove a mapping by pointer to the mapped object. More... | |
Private Types | |
typedef trackers_vec::iterator | iter_type |
typedef std::vector< tracker_ptr > | trackers_vec |
Type of a vector which stores trackers. More... | |
Private Member Functions | |
void | swap_remove (iter_type i) const |
Private Attributes | |
KnowledgeBase | kb_ |
The knowledge base to push to and pull from. More... | |
trackers_vec | trackers_ |
Stores all registered trackers. More... | |
Friends | |
template<class T , class K , bool Const, bool RD, bool WR, bool Prefix, bool Init> | |
class | Builder |
Manages a Read-Compute-Write cycle for registered variables.
See https://sourceforge.net/p/madara/wiki/ReadComputeWrite/ for details.
Definition at line 43 of file Transaction.h.
|
private |
Definition at line 366 of file Transaction.h.
typedef std::unique_ptr<BaseTracker> madara::knowledge::rcw::Transaction::tracker_ptr |
Definition at line 46 of file Transaction.h.
|
private |
Type of a vector which stores trackers.
Definition at line 52 of file Transaction.h.
|
inline |
The constructor.
Note that this keeps a copy of the KnowledgeBase given, thus extending the lifetime of the underlying knowledge base.
kb | the knowledge base to read and modify |
Definition at line 96 of file Transaction.h.
void madara::knowledge::rcw::Transaction::add | ( | const Builder< T, const char * > & | b | ) |
|
inline |
Add a new default mapping for MADARA variable and reference .
key | the MADARA variable name to use. If it doesn't exist, it will be created. |
val | reference to the object to push/pull to/from |
Definition at line 281 of file Transaction.h.
|
inline |
Add a new mapping for MADARA variable and reference .
This will immediately update with the value of
key | the MADARA variable name to use. If it doesn't exist, it will be created. |
val | reference to the object to push/pull to/from |
Definition at line 292 of file Transaction.h.
|
inline |
Add a new prefix-based mapping for MADARA variable and ref .
key | the MADARA variable name to use. If it doesn't exist, it will be created. |
val | reference to the object to push/pull to/from |
Definition at line 302 of file Transaction.h.
|
inline |
Add a new prefix-based mapping for MADARA variable and ref .
This will immediately update with the value of
key | the MADARA variable name to use. If it doesn't exist, it will be created. |
val | reference to the object to push/pull to/from |
Definition at line 313 of file Transaction.h.
|
inline |
Add a tracker object directly.
For advanced users only.
t | the tracker to add |
Definition at line 224 of file Transaction.h.
|
inline |
Create a new mapping, using the Builder interface.
IMPORTANT: the variable given must not outlive the Transaction.
key | the name of the underlying MADARA variable |
val | a reference to the variable to manage |
Definition at line 209 of file Transaction.h.
|
inline |
Call to update values of registered variables from the knowledge base.
Definition at line 108 of file Transaction.h.
|
inline |
Call to push all values of registered variables into the knowledge base.
Definition at line 99 of file Transaction.h.
|
inline |
Remove a mapping by name.
If multiple exist for the given name, only one will be removed. Which one is arbitrary.
name | name of the MADARA variable in the mapping |
Definition at line 323 of file Transaction.h.
|
inline |
Remove a mapping by name.
If multiple exist for the given name, only one will be removed. Which one is arbitrary.
name | name of the MADARA variable in the mapping |
Definition at line 341 of file Transaction.h.
|
inline |
Remove a mapping by pointer to the mapped object.
If multiple exist for the given variable, only one will be removed. Which one is arbitrary.
var | pointer to the variable mapped |
Definition at line 352 of file Transaction.h.
|
inlineprivate |
Definition at line 367 of file Transaction.h.
|
friend |
Definition at line 199 of file Transaction.h.
|
mutableprivate |
The knowledge base to push to and pull from.
Definition at line 59 of file Transaction.h.
|
mutableprivate |
Stores all registered trackers.
Definition at line 62 of file Transaction.h.