2 #ifndef _MADARA_KNOWLEDGE_CONTAINERS_CIRCULARBUFFER_H_
3 #define _MADARA_KNOWLEDGE_CONTAINERS_CIRCULARBUFFER_H_
7 #include "madara/MadaraExport.h"
8 #include "madara/LockType.h"
145 void add(
const std::vector<KnowledgeRecord>& records);
153 void add(
const std::vector<T>& values);
237 std::vector<KnowledgeRecord>
inspect(
252 std::vector<T>& values)
const;
267 size_t count(
void)
const;
273 size_t size(
void)
const;
This class provides a distributed knowledge base to users.
This class encapsulates an entry in a KnowledgeBase.
Settings for applying knowledge updates.
Settings for applying knowledge updates.
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.
Provides an interface for external functions into the MADARA KaRL variable settings.
This container stores a thread-safe circular buffer with O(1) access times.
void set_name(const std::string &name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
std::vector< KnowledgeRecord > get_earliest(size_t count) const
Gets the oldest added records up to a specified count.
KnowledgeRecord::Integer increment(KnowledgeRecord::Integer base, KnowledgeRecord::Integer value) const
Increments the base by the value, using size as a boundary.
ThreadSafeContext * context_
guard for access and changes
size_t size(void) const
Returns the maximum size of the CircularBuffer.
std::string name_
Prefix of variable.
Vector buffer_
Underlying array of records.
void check_context(const char *func) const
void add(const T &value)
Adds a value to the end of the CircularBuffer.
VariableReference size_ref_
Reference to the size field of the vector space.
void add(const std::vector< T > &values)
Adds a list of user values to the end of the CircularBuffer.
void inspect(KnowledgeRecord::Integer position, size_t count, std::vector< T > &values) const
Retrieves a vector of records at a position relative to last added.
void check_all(const char *func) const
KnowledgeUpdateSettings settings_
Settings for modifications.
bool operator!=(const CircularBuffer &value) const
Checks for inequality.
void clear(void)
Clears the CircularBuffer.
std::vector< KnowledgeRecord > get_latest(size_t count) const
Gets the most recently added records up to a specified count.
void inspect(KnowledgeRecord::Integer position, T &value) const
Retrieves a record at a position relative to last added.
virtual ~CircularBuffer()=default
Destructor.
void set_index(KnowledgeRecord::Integer index)
Sets the index into the circular buffer to an arbitrary position.
void get_earliest(size_t count, std::vector< T > &values) const
Gets the oldest added values up to a specified count.
void set_quality(uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Sets the quality of writing to the counter variables.
void resize(int size=-1)
Resizes the CircularBuffer.
CircularBuffer(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
void get_latest(size_t count, std::vector< T > &values) const
Gets the most recently added values up to a specified count.
void check_name(const char *func) const
Integer index_
Index for latest item in circular buffer.
std::string get_name(void) const
Returns the name of the variable.
KnowledgeUpdateSettings set_settings(const KnowledgeUpdateSettings &settings)
Sets the update settings for the variable.
void add(const knowledge::KnowledgeRecord &record)
Adds a record to the end of the CircularBuffer.
knowledge::KnowledgeRecord get(void) const
Gets the most recently added record.
bool operator==(const CircularBuffer &value) const
Checks for equality.
knowledge::KnowledgeRecord inspect(KnowledgeRecord::Integer position) const
Retrieves a record at a position relative to last added.
size_t count(void) const
Returns the number of records in the CircularBuffer.
void get(T &value) const
Gets the most recently added user value.
This class stores an integer within a variable context.
This class stores a vector of KaRL variables.
Provides container classes for fast knowledge base access and mutation.
Provides functions and classes for the distributed knowledge base.
Copyright(c) 2020 Galois.