|
MADARA
3.4.1
|
This container stores a thread-safe, personalized consumer for CircularBuffer instances. More...
#include <CircularBufferConsumer.h>
Public Member Functions | |
| CircularBufferConsumer () | |
| Default constructor. More... | |
| CircularBufferConsumer (const std::string &name, KnowledgeBase &knowledge) | |
| Constructor. More... | |
| CircularBufferConsumer (const std::string &name, Variables &knowledge) | |
| Constructor. More... | |
| virtual | ~CircularBufferConsumer ()=default |
| Destructor. More... | |
| KnowledgeRecord | consume (size_t &dropped) const |
| Consumes the record at the local index (not the producer index) More... | |
| template<typename T > | |
| void | consume (T &value) const |
| Consumes the record at the local index (not the producer index) More... | |
| template<typename T > | |
| void | consume (T &value, size_t &dropped) const |
| Consumes the record at the local index (not the producer index) More... | |
| KnowledgeRecord | consume (void) const |
| Consumes the record at the local index (not the producer index) More... | |
| std::vector< KnowledgeRecord > | consume_earliest (size_t count) const |
| Consumes earliest records from the local index in the buffer. More... | |
| std::vector< KnowledgeRecord > | consume_earliest (size_t count, size_t &dropped) const |
| Consumes earliest records from the local index in the buffer. More... | |
| template<typename T > | |
| void | consume_earliest (size_t count, std::vector< T > &values) const |
| Consumes earliest records from the local index in the buffer. More... | |
| template<typename T > | |
| void | consume_earliest (size_t count, std::vector< T > &values, size_t &dropped) const |
| Consumes earliest records from the local index in the buffer. More... | |
| std::vector< KnowledgeRecord > | consume_latest (size_t count) const |
| Consumes the record at the local index (not the producer index) More... | |
| std::vector< KnowledgeRecord > | consume_latest (size_t count, size_t &dropped) const |
| Consumes latest records added by the producer and updates the local index to the producer index. More... | |
| template<typename T > | |
| void | consume_latest (size_t count, std::vector< T > &values) const |
| Consumes latest records added by the producer and updates the local index to the producer index. More... | |
| template<typename T > | |
| void | consume_latest (size_t count, std::vector< T > &values, size_t &dropped) const |
| Consumes latest records added by the producer and updates the local index to the producer index. More... | |
| size_t | count (void) const |
| Returns the number of records in the CircularBufferConsumer. More... | |
| size_t | get_dropped (void) const |
| Returns the number of known drops since last consume. 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 local index. More... | |
| std::vector< KnowledgeRecord > | inspect (KnowledgeRecord::Integer position, size_t count) const |
| Retrieves a vector of records at a position relative to local index. 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 local index. More... | |
| template<typename T > | |
| void | inspect (KnowledgeRecord::Integer position, T &value) const |
| Retrieves a record at a position relative to local index. More... | |
| bool | operator!= (const CircularBufferConsumer &value) const |
| Checks for inequality. More... | |
| bool | operator== (const CircularBufferConsumer &value) const |
| Checks for equality. More... | |
| std::vector< KnowledgeRecord > | peek_latest (size_t count) const |
| Peeks at the most recently added records. More... | |
| template<typename T > | |
| void | peek_latest (size_t count, std::vector< T > &values) const |
| Peeks at the most recently added records. More... | |
| template<typename T > | |
| void | peek_latest (T &value) const |
| Peeks at the most recently added value. More... | |
| knowledge::KnowledgeRecord | peek_latest (void) const |
| Peeks at the most recently added record. More... | |
| size_t | remaining (void) const |
| Returns the number of records remaining that have not been consumed with get_latest, get, or get_earliest. More... | |
| void | resize (void) |
| Resizes the buffer size to the producer's buffer size. More... | |
| void | resync (void) |
| Sets the local index to the current buffer index. More... | |
| void | set_index (KnowledgeRecord::Integer index) |
| Sets the local index 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... | |
| size_t | size (void) const |
| Returns the maximum size of the CircularBufferConsumer. 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... | |
| KnowledgeRecord::Integer | local_index_ |
| Index for latest item read by. More... | |
| std::string | name_ |
| Prefix of variable. More... | |
This container stores a thread-safe, personalized consumer for CircularBuffer instances.
Unlike functions in CircularBuffer, almost all operations in CircularBufferConsumer use a local index into the CircularBuffer and encourage one-time access of buffer elements.
Definition at line 34 of file CircularBufferConsumer.h.
|
inline |
Default constructor.
Definition at line 20 of file CircularBufferConsumer.inl.
|
inline |
Constructor.
| name | name of the integer in the knowledge base |
| knowledge | the knowledge base that will contain the vector |
| exceptions::NameException | bad name ("") |
Definition at line 79 of file CircularBufferConsumer.inl.
|
inline |
Constructor.
| name | the name of the map within the variable context |
| knowledge | the variable context |
| exceptions::NameException | bad name ("") |
Definition at line 89 of file CircularBufferConsumer.inl.
|
virtualdefault |
Destructor.
|
inlineprivate |
Definition at line 44 of file CircularBufferConsumer.inl.
|
inlineprivate |
Definition at line 34 of file CircularBufferConsumer.inl.
|
inlineprivate |
Definition at line 25 of file CircularBufferConsumer.inl.
|
inline |
Consumes the record at the local index (not the producer index)
| dropped | the number of dropped packets. Drops can occur when the producer produces faster than the consumer can consume. This value is essentially index_ - local_index - size (). |
| exceptions::IndexException | buffer has zero size |
Definition at line 159 of file CircularBufferConsumer.inl.
| void madara::knowledge::containers::CircularBufferConsumer::consume | ( | T & | value | ) | const |
Consumes the record at the local index (not the producer index)
| value | the last added value. |
| exceptions::IndexException | if no data to consume |
| void madara::knowledge::containers::CircularBufferConsumer::consume | ( | T & | value, |
| size_t & | dropped | ||
| ) | const |
Consumes the record at the local index (not the producer index)
| value | the last added value. |
| dropped | the number of dropped packets. Drops can occur when the producer produces faster than the consumer can consume. This value is essentially index_ - local_index - size (). |
| exceptions::IndexException | if no data to consume |
|
inline |
Consumes the record at the local index (not the producer index)
| exceptions::IndexException | buffer has zero size |
Definition at line 134 of file CircularBufferConsumer.inl.
|
inline |
Consumes earliest records from the local index in the buffer.
| count | the maximum number of records to return |
| exceptions::IndexException | if index is unreachable |
Definition at line 415 of file CircularBufferConsumer.inl.
|
inline |
Consumes earliest records from the local index in the buffer.
| count | the maximum number of records to return |
| dropped | the number of dropped packets. Drops can occur when the producer produces faster than the consumer can consume. This value is essentially index_ - local_index - size (). |
| exceptions::IndexException | if index is unreachable |
Definition at line 450 of file CircularBufferConsumer.inl.
| void madara::knowledge::containers::CircularBufferConsumer::consume_earliest | ( | size_t | count, |
| std::vector< T > & | values | ||
| ) | const |
Consumes earliest records from the local index in the buffer.
| count | the maximum number of records to return |
| values | the last added records |
| exceptions::IndexException | if index is unreachable |
| void madara::knowledge::containers::CircularBufferConsumer::consume_earliest | ( | size_t | count, |
| std::vector< T > & | values, | ||
| size_t & | dropped | ||
| ) | const |
Consumes earliest records from the local index in the buffer.
| count | the maximum number of records to return |
| values | the last added records |
| dropped | the number of dropped packets. Drops can occur when the producer produces faster than the consumer can consume. This value is essentially index_ - local_index - size (). |
| exceptions::IndexException | if index is unreachable |
|
inline |
Consumes the record at the local index (not the producer index)
| count | the maximum number of records to return |
| exceptions::IndexException | if index is unreachable |
Definition at line 365 of file CircularBufferConsumer.inl.
|
inline |
Consumes latest records added by the producer and updates the local index to the producer index.
| count | the maximum number of records to return |
| dropped | the number of dropped packets. Drops can occur when the producer produces faster than the consumer can consume. This value is essentially index_ - local_index - size (). |
| exceptions::IndexException | if index is unreachable |
Definition at line 389 of file CircularBufferConsumer.inl.
| void madara::knowledge::containers::CircularBufferConsumer::consume_latest | ( | size_t | count, |
| std::vector< T > & | values | ||
| ) | const |
Consumes latest records added by the producer and updates the local index to the producer index.
| count | the maximum number of records to return |
| values | the last added records |
| exceptions::IndexException | if index is unreachable |
| void madara::knowledge::containers::CircularBufferConsumer::consume_latest | ( | size_t | count, |
| std::vector< T > & | values, | ||
| size_t & | dropped | ||
| ) | const |
Consumes latest records added by the producer and updates the local index to the producer index.
| count | the maximum number of records to return |
| values | the last added records |
| dropped | the number of dropped packets. Drops can occur when the producer produces faster than the consumer can consume. This value is essentially index_ - local_index - size (). |
| exceptions::IndexException | if index is unreachable |
|
inline |
Returns the number of records in the CircularBufferConsumer.
| exceptions::ContextException | if name or context haven't been set appropriately |
Definition at line 286 of file CircularBufferConsumer.inl.
|
inline |
Returns the number of known drops since last consume.
Definition at line 480 of file CircularBufferConsumer.inl.
|
inline |
Returns the name of the variable.
Definition at line 267 of file CircularBufferConsumer.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 112 of file CircularBufferConsumer.inl.
|
inline |
Retrieves a record at a position relative to local index.
| 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 186 of file CircularBufferConsumer.inl.
|
inline |
Retrieves a vector of records at a position relative to local index.
| 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 223 of file CircularBufferConsumer.inl.
| void madara::knowledge::containers::CircularBufferConsumer::inspect | ( | KnowledgeRecord::Integer | position, |
| size_t | count, | ||
| std::vector< T > & | values | ||
| ) | const |
Retrieves a vector of records at a position relative to local index.
| 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::CircularBufferConsumer::inspect | ( | KnowledgeRecord::Integer | position, |
| T & | value | ||
| ) | const |
Retrieves a record at a position relative to local index.
| position | the relative position of the requested record from the latest added record. Can be negative |
| value | the record 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 |
|
inline |
Checks for inequality.
| value | the value to compare to |
Definition at line 105 of file CircularBufferConsumer.inl.
|
inline |
Checks for equality.
| value | the value to compare to |
Definition at line 99 of file CircularBufferConsumer.inl.
|
inline |
Peeks at the most recently added records.
This does not use or modify the local index. It instead references what the producer most recently added.
| count | the maximum number of items to look for |
| exceptions::IndexException | if index is out of range/invalid |
Definition at line 499 of file CircularBufferConsumer.inl.
| void madara::knowledge::containers::CircularBufferConsumer::peek_latest | ( | size_t | count, |
| std::vector< T > & | values | ||
| ) | const |
Peeks at the most recently added records.
This does not use or modify the local index. It instead references what the producer most recently added.
| count | the maximum number of items to look for |
| values | the last added records up to a certain count |
| exceptions::IndexException | if index is out of range/invalid |
| void madara::knowledge::containers::CircularBufferConsumer::peek_latest | ( | T & | value | ) | const |
Peeks at the most recently added value.
This does not use or modify the local index. It instead references what the producer most recently added.
| value | the last added value. exists() will return false if the record is invalid |
| exceptions::IndexException | if index is out of range/invalid |
|
inline |
Peeks at the most recently added record.
This does not use or modify the local index. It instead references what the producer most recently added.
| exceptions::IndexException | if index is out of range/invalid |
Definition at line 520 of file CircularBufferConsumer.inl.
|
inline |
Returns the number of records remaining that have not been consumed with get_latest, get, or get_earliest.
| exceptions::ContextException | if name or context haven't been set appropriately |
Definition at line 277 of file CircularBufferConsumer.inl.
|
inline |
Resizes the buffer size to the producer's buffer size.
Definition at line 295 of file CircularBufferConsumer.inl.
|
inline |
Sets the local index to the current buffer index.
Definition at line 304 of file CircularBufferConsumer.inl.
|
inline |
Sets the local index to an arbitrary position.
| index | the new index to use |
Definition at line 358 of file CircularBufferConsumer.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 320 of file CircularBufferConsumer.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 339 of file CircularBufferConsumer.inl.
|
inline |
Returns the maximum size of the CircularBufferConsumer.
Definition at line 272 of file CircularBufferConsumer.inl.
|
private |
Underlying array of records.
Definition at line 402 of file CircularBufferConsumer.h.
|
mutableprivate |
guard for access and changes
Variable context that we are modifying
Definition at line 382 of file CircularBufferConsumer.h.
|
private |
Index for latest item in circular buffer.
Definition at line 392 of file CircularBufferConsumer.h.
|
mutableprivate |
Index for latest item read by.
Definition at line 397 of file CircularBufferConsumer.h.
|
private |
Prefix of variable.
Definition at line 387 of file CircularBufferConsumer.h.