|
MADARA
3.4.1
|
This container stores a thread-safe circular buffer with O(1) access times. More...
#include <CircularBuffer.h>
Public Member Functions | |
| CircularBuffer (const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings()) | |
| Default constructor. More... | |
| CircularBuffer (const std::string &name, KnowledgeBase &knowledge, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings()) | |
| Constructor. More... | |
| CircularBuffer (const std::string &name, KnowledgeBase &knowledge, int size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings()) | |
| Default constructor. More... | |
| CircularBuffer (const std::string &name, Variables &knowledge, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings()) | |
| Constructor. More... | |
| CircularBuffer (const std::string &name, Variables &knowledge, int size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings()) | |
| Default constructor. More... | |
| virtual | ~CircularBuffer ()=default |
| Destructor. More... | |
| void | add (const knowledge::KnowledgeRecord &record) |
| Adds a record to the end of the CircularBuffer. More... | |
| void | add (const std::vector< KnowledgeRecord > &records) |
| Adds a list of records to the end of the CircularBuffer. More... | |
| template<typename T > | |
| void | add (const std::vector< T > &values) |
| Adds a list of user values to the end of the CircularBuffer. More... | |
| template<typename T > | |
| void | add (const T &value) |
| Adds a value to the end of the CircularBuffer. More... | |
| void | clear (void) |
| Clears the CircularBuffer. More... | |
| size_t | count (void) const |
| Returns the number of records in the CircularBuffer. More... | |
| template<typename T > | |
| void | get (T &value) const |
| Gets the most recently added user value. More... | |
| knowledge::KnowledgeRecord | get (void) const |
| Gets the most recently added record. More... | |
| std::vector< KnowledgeRecord > | get_earliest (size_t count) const |
| Gets the oldest added records up to a specified count. More... | |
| template<typename T > | |
| void | get_earliest (size_t count, std::vector< T > &values) const |
| Gets the oldest added values up to a specified count. More... | |
| std::vector< KnowledgeRecord > | get_latest (size_t count) const |
| Gets the most recently added records up to a specified count. More... | |
| template<typename T > | |
| void | get_latest (size_t count, std::vector< T > &values) const |
| Gets the most recently added values up to a specified count. More... | |
| std::string | get_name (void) const |
| Returns the name of the variable. More... | |
| knowledge::KnowledgeRecord | inspect (KnowledgeRecord::Integer position) const |
| Retrieves a record at a position relative to last added. More... | |
| std::vector< KnowledgeRecord > | inspect (KnowledgeRecord::Integer position, size_t count) const |
| Retrieves a vector of records at a position relative to last added. More... | |
| template<typename T > | |
| 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. More... | |
| template<typename T > | |
| void | inspect (KnowledgeRecord::Integer position, T &value) const |
| Retrieves a record at a position relative to last added. More... | |
| bool | operator!= (const CircularBuffer &value) const |
| Checks for inequality. More... | |
| bool | operator== (const CircularBuffer &value) const |
| Checks for equality. More... | |
| void | resize (int size=-1) |
| Resizes the CircularBuffer. More... | |
| void | set_index (KnowledgeRecord::Integer index) |
| Sets the index into the circular buffer to an arbitrary position. More... | |
| void | set_name (const std::string &name, KnowledgeBase &knowledge) |
| Sets the variable name that this refers to. More... | |
| void | set_name (const std::string &name, Variables &knowledge) |
| Sets the variable name that this refers to. More... | |
| void | set_quality (uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false)) |
| Sets the quality of writing to the counter variables. More... | |
| KnowledgeUpdateSettings | set_settings (const KnowledgeUpdateSettings &settings) |
| Sets the update settings for the variable. More... | |
| size_t | size (void) const |
| Returns the maximum size of the CircularBuffer. More... | |
Private Member Functions | |
| void | check_all (const char *func) const |
| void | check_context (const char *func) const |
| void | check_name (const char *func) const |
| KnowledgeRecord::Integer | increment (KnowledgeRecord::Integer base, KnowledgeRecord::Integer value) const |
| Increments the base by the value, using size as a boundary. More... | |
Private Attributes | |
| Vector | buffer_ |
| Underlying array of records. More... | |
| ThreadSafeContext * | context_ |
| guard for access and changes More... | |
| Integer | index_ |
| Index for latest item in circular buffer. More... | |
| std::string | name_ |
| Prefix of variable. More... | |
| KnowledgeUpdateSettings | settings_ |
| Settings for modifications. More... | |
| VariableReference | size_ref_ |
| Reference to the size field of the vector space. More... | |
This container stores a thread-safe circular buffer with O(1) access times.
Definition at line 33 of file CircularBuffer.h.
|
inline |
Default constructor.
Definition at line 20 of file CircularBuffer.inl.
|
inline |
Constructor.
| name | name of the integer in the knowledge base |
| knowledge | the knowledge base that will contain the vector |
| settings | settings for evaluating the vector |
| exceptions::NameException | bad name ("") |
Definition at line 79 of file CircularBuffer.inl.
|
inline |
Constructor.
| name | the name of the map within the variable context |
| knowledge | the variable context |
| settings | settings to apply by default |
| exceptions::NameException | bad name ("") |
Definition at line 89 of file CircularBuffer.inl.
|
inline |
Default constructor.
| name | name of the integer in the knowledge base |
| knowledge | the knowledge base that will contain the vector |
| size | the size of the CircularBuffer |
| settings | settings for evaluating the vector |
| exceptions::NameException | bad name ("") |
Definition at line 99 of file CircularBuffer.inl.
|
inline |
Default constructor.
| name | name of the integer in the knowledge base |
| knowledge | the knowledge base that will contain the vector |
| size | the size of the CircularBuffer |
| settings | settings for evaluating the vector |
| exceptions::NameException | bad name ("") |
Definition at line 113 of file CircularBuffer.inl.
|
virtualdefault |
Destructor.
|
inline |
Adds a record to the end of the CircularBuffer.
| record | the value to add |
| exceptions::IndexException | if index is out of range/invalid |
Definition at line 169 of file CircularBuffer.inl.
|
inline |
Adds a list of records to the end of the CircularBuffer.
| records | the values to add |
| exceptions::IndexException | if index is out of range/invalid |
Definition at line 184 of file CircularBuffer.inl.
| void madara::knowledge::containers::CircularBuffer::add | ( | const std::vector< T > & | values | ) |
Adds a list of user values to the end of the CircularBuffer.
| values | the values to add |
| exceptions::IndexException | if index is out of range/invalid |
| void madara::knowledge::containers::CircularBuffer::add | ( | const T & | value | ) |
Adds a value to the end of the CircularBuffer.
| value | the value to add |
| exceptions::IndexException | if index is out of range/invalid |
|
inlineprivate |
Definition at line 44 of file CircularBuffer.inl.
|
inlineprivate |
Definition at line 34 of file CircularBuffer.inl.
|
inlineprivate |
Definition at line 25 of file CircularBuffer.inl.
|
inline |
Clears the CircularBuffer.
| exceptions::ContextException | if name or context haven't been set appropriately |
Definition at line 137 of file CircularBuffer.inl.
|
inline |
Returns the number of records in the CircularBuffer.
| exceptions::ContextException | if name or context haven't been set appropriately |
Definition at line 291 of file CircularBuffer.inl.
| void madara::knowledge::containers::CircularBuffer::get | ( | T & | value | ) | const |
Gets the most recently added user value.
| exceptions::IndexException | if index is out of range/invalid |
|
inline |
Gets the most recently added record.
| exceptions::IndexException | if index is out of range/invalid |
Definition at line 204 of file CircularBuffer.inl.
|
inline |
Gets the oldest added records up to a specified count.
| count | the maximum number of records to return |
| exceptions::IndexException | if index is unreachable |
Definition at line 403 of file CircularBuffer.inl.
| void madara::knowledge::containers::CircularBuffer::get_earliest | ( | size_t | count, |
| std::vector< T > & | values | ||
| ) | const |
Gets the oldest added values up to a specified count.
| count | the maximum number of records to return |
| values | the added values |
| exceptions::IndexException | if index is unreachable |
|
inline |
Gets the most recently added records up to a specified count.
| count | the maximum number of records to return |
| exceptions::IndexException | if index is unreachable |
Definition at line 382 of file CircularBuffer.inl.
| void madara::knowledge::containers::CircularBuffer::get_latest | ( | size_t | count, |
| std::vector< T > & | values | ||
| ) | const |
Gets the most recently added values up to a specified count.
| count | the maximum number of records to return |
| values | the resulting values |
| exceptions::IndexException | if index is unreachable |
|
inline |
Returns the name of the variable.
Definition at line 281 of file CircularBuffer.inl.
|
inlineprivate |
Increments the base by the value, using size as a boundary.
| base | the base value to increment |
| value | the value to increment base by |
Definition at line 147 of file CircularBuffer.inl.
|
inline |
Retrieves a record at a position relative to last added.
| position | the relative position of the requested record from the latest added record. Can be negative |
| exceptions::ContextException | if name or context haven't been set appropriately |
| exceptions::IndexException | if index is out of range/invalid |
Definition at line 219 of file CircularBuffer.inl.
|
inline |
Retrieves a vector of records at a position relative to last added.
| position | the relative position of the requested record from the latest added record. Can be negative |
| count | the maximum number of records to return |
| exceptions::ContextException | if name or context haven't been set appropriately |
| exceptions::IndexException | if index is out of range/invalid |
Definition at line 246 of file CircularBuffer.inl.
| void madara::knowledge::containers::CircularBuffer::inspect | ( | KnowledgeRecord::Integer | position, |
| size_t | count, | ||
| std::vector< T > & | values | ||
| ) | const |
Retrieves a vector of records at a position relative to last added.
| position | the relative position of the requested record from the latest added record. Can be negative |
| count | the maximum number of records to return |
| values | the values at the position in the CircularBufferConsumer |
| exceptions::ContextException | if name or context haven't been set appropriately |
| exceptions::IndexException | if index is out of range/invalid |
| void madara::knowledge::containers::CircularBuffer::inspect | ( | KnowledgeRecord::Integer | position, |
| T & | value | ||
| ) | const |
Retrieves a record at a position relative to last added.
| position | the relative position of the requested record from the latest added record. Can be negative |
| value | the value at the position in the CircularBuffer |
| exceptions::ContextException | if name or context haven't been set appropriately |
| exceptions::IndexException | if index is out of range/invalid |
|
inline |
Checks for inequality.
| value | the value to compare to |
Definition at line 132 of file CircularBuffer.inl.
|
inline |
Checks for equality.
| value | the value to compare to |
Definition at line 127 of file CircularBuffer.inl.
|
inline |
Resizes the CircularBuffer.
| size | the size of the CircularBuffer. -1 means use the size that exists in the knowledge base already. |
Definition at line 300 of file CircularBuffer.inl.
|
inline |
Sets the index into the circular buffer to an arbitrary position.
| index | the new index to use |
Definition at line 376 of file CircularBuffer.inl.
|
inline |
Sets the variable name that this refers to.
| name | the name of the variable in the knowledge base |
| knowledge | the knowledge base the variable is housed in |
| exceptions::NameException | bad name ("") |
Definition at line 330 of file CircularBuffer.inl.
|
inline |
Sets the variable name that this refers to.
| name | the name of the variable in the knowledge base |
| knowledge | the knowledge base the variable is housed in |
| exceptions::NameException | bad name ("") |
Definition at line 353 of file CircularBuffer.inl.
|
inline |
Sets the quality of writing to the counter variables.
| quality | quality of writing to this location |
| settings | settings for referring to knowledge variables |
Definition at line 321 of file CircularBuffer.inl.
|
inline |
Sets the update settings for the variable.
| settings | the new settings to use |
Definition at line 311 of file CircularBuffer.inl.
|
inline |
Returns the maximum size of the CircularBuffer.
Definition at line 286 of file CircularBuffer.inl.
|
private |
Underlying array of records.
Definition at line 335 of file CircularBuffer.h.
|
mutableprivate |
guard for access and changes
Variable context that we are modifying
Definition at line 320 of file CircularBuffer.h.
|
private |
Index for latest item in circular buffer.
Definition at line 330 of file CircularBuffer.h.
|
private |
Prefix of variable.
Definition at line 325 of file CircularBuffer.h.
|
private |
Settings for modifications.
Definition at line 345 of file CircularBuffer.h.
|
private |
Reference to the size field of the vector space.
Definition at line 340 of file CircularBuffer.h.