MADARA
3.4.1
|
This class encapsulates an entry in a KnowledgeBase. More...
#include <KnowledgeRecord.h>
Public Types | |
enum | { UNCREATED = 0 , MODIFIED = 1 } |
enum | { OWNED = 0 , SHARED = 1 } |
using | CircBuf = utility::CircularBuffer< KnowledgeRecord > |
typedef int64_t | Integer |
enum | ValueTypes : uint32_t { EMPTY = 0 , INTEGER = 1 , STRING = 2 , DOUBLE = 4 , FLOAT = 4 , UNKNOWN_FILE_TYPE = 8 , XML = 16 , TEXT_FILE = 32 , INTEGER_ARRAY = 64 , DOUBLE_ARRAY = 128 , IMAGE_JPEG = 256 , ALL_ARRAYS = INTEGER_ARRAY | DOUBLE_ARRAY , ALL_INTEGERS = INTEGER | INTEGER_ARRAY , ALL_DOUBLES = DOUBLE | DOUBLE_ARRAY , ALL_PRIMITIVE_TYPES , ALL_FILE_TYPES = UNKNOWN_FILE_TYPE | XML | TEXT_FILE | IMAGE_JPEG , ALL_IMAGES = IMAGE_JPEG , ALL_TEXT_FORMATS = XML | TEXT_FILE | STRING , ALL_TYPES = ALL_PRIMITIVE_TYPES | ALL_FILE_TYPES , ALL_CLEARABLES = ALL_ARRAYS | ALL_TEXT_FORMATS | ALL_FILE_TYPES , BUFFER = (1UL << 31) } |
Public Member Functions | |
KnowledgeRecord () noexcept | |
KnowledgeRecord (CircBuf &&buffer, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
Construct using CircularBuffer directly. More... | |
KnowledgeRecord (const char *value, logger::Logger &logger= *logger::global_logger.get()) | |
KnowledgeRecord (const CircBuf &buffer, logger::Logger &logger= *logger::global_logger.get()) | |
Construct using CircularBuffer directly. More... | |
KnowledgeRecord (const KnowledgeRecord &rhs) | |
copy constructor More... | |
KnowledgeRecord (const std::string &value, logger::Logger &logger= *logger::global_logger.get()) | |
KnowledgeRecord (const std::vector< double > &value, logger::Logger &logger= *logger::global_logger.get()) | |
KnowledgeRecord (const std::vector< Integer > &value, logger::Logger &logger= *logger::global_logger.get()) | |
KnowledgeRecord (KnowledgeRecord &&rhs) noexcept | |
move constructor More... | |
KnowledgeRecord (logger::Logger &logger) noexcept | |
KnowledgeRecord (std::string &&value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::unique_ptr< std::string > value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::unique_ptr< std::vector< double >> value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::unique_ptr< std::vector< Integer >> value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::unique_ptr< std::vector< unsigned char >> value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::vector< double > &&value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::vector< Integer > &&value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
template<typename T , utility::enable_if_< utility::is_int_numeric< T >(), int > = 0> | |
KnowledgeRecord (T value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type = nullptr> | |
KnowledgeRecord (T value, logger::Logger &logger= *logger::global_logger.get()) noexcept | |
template<typename... Args> | |
KnowledgeRecord (tags::binary_t, Args &&... args) | |
Forwarding constructor for binary files (blobs) Each argument past the first will be forwarded to construct a std::vector<unsigned char> in-place within the new record. More... | |
template<typename... Args> | |
KnowledgeRecord (tags::doubles_t, Args &&... args) | |
Forwarding constructor for double arrays Each argument past the first will be forwarded to construct a std::vector<double> in-place within the new record. More... | |
template<typename... Args> | |
KnowledgeRecord (tags::integers_t, Args &&... args) | |
Forwarding constructor for integer arrays Each argument past the first will be forwarded to construct a std::vector<Integer> in-place within the new record. More... | |
template<typename... Args> | |
KnowledgeRecord (tags::string_t, Args &&... args) | |
Forwarding constructor for strings Each argument past the first will be forwarded to construct a std::string in-place within the new record. More... | |
~KnowledgeRecord () noexcept | |
int | apply (madara::knowledge::ThreadSafeContext &context, const std::string &key, unsigned int quality, uint64_t clock, bool perform_lock) |
Apply the knowledge record to a context, given some quality and clock. More... | |
void | clear_history () |
Clear all history for this record, keeping the current value. More... | |
void | clear_value (void) noexcept |
clears any dynamic values. More... | |
KnowledgeRecord * | clone (void) const |
clones the record. More... | |
void | copy_metadata (const KnowledgeRecord &new_value) |
Set metadata of this record equal to that of new_value, but doesn't change value. More... | |
KnowledgeRecord | dec_index (size_t index) |
decrements the value at the index to the specified value. More... | |
KnowledgeRecord | deep_copy () const |
Creates a deep copy of this knowledge record. More... | |
void | deep_copy (const KnowledgeRecord &source) |
Creates a deep copy of the knowledge record. More... | |
template<typename... Args> | |
void | emplace (tags::binary_t, Args &&... args) |
Construct a binary (vector of unsigned char) within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace (tags::doubles_t, Args &&... args) |
Construct a vector of doubles within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace (tags::integers_t, Args &&... args) |
Construct a vector of integers within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace (tags::string_t, Args &&... args) |
Construct a string within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace_doubles (Args &&... args) |
Construct a vector of doubles within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace_file (Args &&... args) |
Construct a file (vector of unsigned char) within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace_integers (Args &&... args) |
Construct a vector of integers within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace_string (Args &&... args) |
Construct a string within this KnowledgeRecord. More... | |
bool | exists (void) const |
Checks if record exists (i.e., is not uncreated) More... | |
template<typename Func > | |
size_t | for_history_range (Func &&func, size_t index, size_t count) const |
Execute a callable for each history element. More... | |
KnowledgeRecord | fragment (unsigned int first, unsigned int last) |
returns a record containing a fragment of the character buffer. More... | |
int64_t | get_encoded_size (const std::string &key) const |
Returns the encoded size of the record. More... | |
int64_t | get_encoded_size (void) const |
Returns the encoded size of the record. More... | |
std::vector< KnowledgeRecord > | get_history () const |
Get a copy of the entire stored history of this record. More... | |
template<typename T > | |
std::vector< T > | get_history () const |
Get a copy of the entire stored history of this record in a vector of the given element type, which must support knoweldge_cast<> from KnowledgeRecord. More... | |
template<typename OutputIterator > | |
auto | get_history (OutputIterator out) const -> decltype(*out, size_t{}) |
Copy the stored history of this record to the given output iterator, in order from oldest to newest. More... | |
template<typename OutputIterator > | |
size_t | get_history (OutputIterator out, ssize_t index, size_t count) const |
Copy the given range of history to the output iterator given. More... | |
KnowledgeRecord | get_history (size_t index) const |
Return the given entry in this record's history. More... | |
std::vector< KnowledgeRecord > | get_history (size_t index, size_t count) const |
Return a copy of the given range of history in a vector. More... | |
size_t | get_history_capacity () const |
Return the maximum amount of history this record can hold. More... | |
size_t | get_history_newest_index () const |
Gets the absolute index of the newest element in stored history. More... | |
size_t | get_history_oldest_index () const |
Gets the absolute index of the oldest element in stored history. More... | |
template<typename OutputIterator > | |
size_t | get_history_range (OutputIterator out, size_t index, size_t count) const |
Copy the given absolute range of history to the output iterator given. More... | |
size_t | get_history_size () const |
Return the amount of history this record holds. More... | |
KnowledgeRecord | get_newest () const |
Return the newest stored history entry of this record. More... | |
template<typename OutputIterator > | |
auto | get_newest (OutputIterator out) const -> decltype(*out, size_t{}) |
Copy the newest stored history entry of this record to the given output iterator. More... | |
template<typename OutputIterator > | |
size_t | get_newest (OutputIterator out, size_t count) const |
Copy the count newest stored history entries of this record to the given output iterator, in order from oldest to newest. More... | |
std::vector< KnowledgeRecord > | get_newest (size_t count) const |
Return the count newest stored history entries of this record in a vector. More... | |
template<typename T > | |
std::vector< T > | get_newest (size_t count) const |
Return the count newest stored history entries of this record in a vector of the given element type, which must support knoweldge_cast<> from KnowledgeRecord. More... | |
KnowledgeRecord | get_oldest () const |
Return the oldest stored history entry of this record. More... | |
template<typename OutputIterator > | |
auto | get_oldest (OutputIterator out) const -> decltype(*out, size_t{}) |
Copy the oldest stored history entry of this record to the given output iterator. More... | |
template<typename OutputIterator > | |
size_t | get_oldest (OutputIterator out, size_t count) const |
Copy the count oldest stored history entries of this record to the given output iterator, in order from oldest to newest. More... | |
std::vector< KnowledgeRecord > | get_oldest (size_t count) const |
Return the count oldest stored history entries of this record in a vector. More... | |
template<typename T > | |
std::vector< T > | get_oldest (size_t count) const |
Return the count oldest stored history entries of this record in a vector of the given element type, which must support knoweldge_cast<> from KnowledgeRecord. More... | |
bool | has_history () const |
Return true if this record has a circular buffer history. More... | |
KnowledgeRecord | inc_index (size_t index) |
increments the value at the index to the specified value. More... | |
bool | is_array_type (void) const |
returns if the record is an array type (DOUBLE_ARRAY, INTEGER_ARRAY) More... | |
bool | is_binary_file_type (void) const |
returns true if the knowledge record has a binary file type More... | |
bool | is_double_type (void) const |
returns if the record is a double type (DOUBLE, DOUBLE_ARRAY) More... | |
bool | is_false (void) const |
Checks to see if the record is false. More... | |
bool | is_file_type (void) const |
returns true if the knowledge record has a file type More... | |
bool | is_image_type (void) const |
returns true if the knowledge record has an image type More... | |
bool | is_integer_type (void) const |
returns if the record is a integer type (INTEGER, INTEGER_ARRAY) More... | |
bool | is_ref_counted (void) const |
returns if the record has a reference-counted type More... | |
bool | is_string_type (void) const |
returns true if the record is a string type (STRING, XML, TEXT_FILE) More... | |
bool | is_true (void) const |
Checks to see if the record is true. More... | |
bool | is_valid (void) const |
Checks to see if the record is valid. More... | |
operator bool (void) const | |
Explicit bool cast. More... | |
bool | operator! (void) const |
Logical not. More... | |
bool | operator!= (const KnowledgeRecord &rhs) const |
Unequal to. More... | |
KnowledgeRecord | operator% (const KnowledgeRecord &rhs) const |
Modulus operator. More... | |
KnowledgeRecord & | operator%= (const KnowledgeRecord &rhs) |
In-place modulus operator. More... | |
KnowledgeRecord | operator* (const KnowledgeRecord &rhs) const |
Times operator. More... | |
KnowledgeRecord & | operator*= (const KnowledgeRecord &rhs) |
In-place multiplication operator. More... | |
KnowledgeRecord | operator+ (const KnowledgeRecord &rhs) const |
Plus operator. More... | |
KnowledgeRecord & | operator++ (void) |
Preincrement operator. More... | |
KnowledgeRecord & | operator+= (const KnowledgeRecord &rhs) |
In-place addition operator. More... | |
KnowledgeRecord | operator- (const KnowledgeRecord &rhs) const |
Minus operator. More... | |
KnowledgeRecord | operator- (void) const |
Negate. More... | |
KnowledgeRecord & | operator-- (void) |
Predecrement operator. More... | |
KnowledgeRecord & | operator-= (const KnowledgeRecord &rhs) |
In-place subtraction operator. More... | |
KnowledgeRecord | operator/ (const KnowledgeRecord &rhs) const |
Divides operator. More... | |
KnowledgeRecord & | operator/= (const KnowledgeRecord &rhs) |
In-place division operator. More... | |
bool | operator< (const KnowledgeRecord &rhs) const |
Less than. More... | |
bool | operator<= (const KnowledgeRecord &rhs) const |
Less than or equal to. More... | |
KnowledgeRecord & | operator= (const KnowledgeRecord &rhs) |
Assignment. More... | |
KnowledgeRecord & | operator= (KnowledgeRecord &&rhs) noexcept |
Move Assignment. More... | |
template<typename T > | |
auto | operator= (T &&t) -> typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value, decltype(this->set_value(std::forward< T >(t)), *this)>::type |
Assigns a convertible value to the knowledge record. More... | |
bool | operator== (const KnowledgeRecord &rhs) const |
Equal to. More... | |
bool | operator> (const KnowledgeRecord &rhs) const |
Greater than. More... | |
bool | operator>= (const KnowledgeRecord &rhs) const |
Greater than or equal to. More... | |
void | overwrite (const KnowledgeRecord &new_value) |
Clears everything including history, but excluding metadata (e.g., toi, clock) and copies value from new_value into this recod. More... | |
void | overwrite (KnowledgeRecord &&new_value) |
Clears everything including history, but excluding metadata (e.g., toi, clock) and moves value from new_value into this recod. More... | |
template<typename... Args> | |
void | overwrite_circular_buffer (Args &&... args) |
Construct a CircularBuffer within this KnowledgeRecord directly. More... | |
const char * | read (const char *buffer, int64_t &buffer_remaining) |
Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining. More... | |
const char * | read (const char *buffer, std::string &key, int64_t &buffer_remaining) |
Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining. More... | |
const char * | read (const char *buffer, uint32_t &key_id, int64_t &buffer_remaining) |
Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining. More... | |
int | read_file (const std::string &filename, uint32_t read_as_type=0) |
reads a file and sets the type appropriately according to the extension More... | |
void | reset_value (void) noexcept |
resets the variable to an integer More... | |
void | resize (size_t new_size) |
resizes an array to a new size More... | |
KnowledgeRecord | retrieve_index (size_t index) const |
retrieves the value at an array index. More... | |
void | set_file (const std::vector< unsigned char > &new_value) |
sets the value to an unknown file type More... | |
void | set_file (const unsigned char *new_value, size_t size) |
sets the value to an unknown file type More... | |
void | set_file (std::unique_ptr< std::vector< unsigned char >> new_value) |
sets the value to an unknown file type, without copying More... | |
void | set_file (std::vector< unsigned char > &&new_value) |
sets the value to an unknown file type, without copying More... | |
void | set_full (const KnowledgeRecord &new_value) |
Sets the value and meta data from another KnowledgeRecord. More... | |
void | set_full (KnowledgeRecord &&new_value) |
Sets the value and meta data from another KnowledgeRecord. More... | |
void | set_history_capacity (size_t size) |
Set the capacity of this record's history circular buffer. More... | |
template<typename T , utility::enable_if_< utility::is_int_numeric< T >(), int > = 0> | |
void | set_index (size_t index, T value) |
sets the value at the index to the specified value. More... | |
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type = nullptr> | |
void | set_index (size_t index, T value) |
sets the value at the index to the specified value. More... | |
void | set_jpeg (const std::vector< unsigned char > &new_value) |
sets the value to a jpeg More... | |
void | set_jpeg (const unsigned char *new_value, size_t size) |
sets the value to a jpeg More... | |
void | set_jpeg (std::unique_ptr< std::vector< unsigned char >> new_value) |
sets the value to a jpeg, without copying More... | |
void | set_jpeg (std::vector< unsigned char > &&new_value) |
sets the value to a jpeg, without copying More... | |
void | set_modified (void) |
sets the status to modified More... | |
void | set_text (const char *new_value, size_t size) |
sets the value to a plaintext string More... | |
void | set_text (const std::string &new_value) |
sets the value to a plaintext string More... | |
void | set_text (std::string &&new_value) |
sets the value to a plaintext string More... | |
void | set_text (std::unique_ptr< std::string > new_value) |
sets the value to a plaintext string. More... | |
void | set_toi (uint64_t new_toi) |
bool | set_type (uint32_t type) |
Modify the type, but only if it's compatible with current type without changing any actual data stored. More... | |
void | set_value (const char *new_value, uint32_t size) |
sets the value to a string, from a buffer More... | |
void | set_value (const double *new_value, uint32_t size) |
sets the value to an array of doubles More... | |
void | set_value (const Integer *new_value, uint32_t size) |
sets the value to an array of integers More... | |
void | set_value (const KnowledgeRecord &new_value) |
Sets the value from another KnowledgeRecord, does not copy toi, clock, and write_quality. More... | |
void | set_value (const std::string &new_value) |
sets the value to a string More... | |
void | set_value (const std::vector< double > &new_value) |
sets the value to an array of doubles More... | |
void | set_value (const std::vector< Integer > &new_value) |
sets the value to an array of integers More... | |
void | set_value (double new_value) |
sets the value to a double More... | |
void | set_value (float new_value) |
sets the value to a float More... | |
void | set_value (int new_value) |
sets the value to an integer More... | |
void | set_value (Integer new_value) |
sets the value to an integer More... | |
void | set_value (KnowledgeRecord &&new_value) |
Sets the value from another KnowledgeRecord, does not copy toi, clock, and write_quality. More... | |
void | set_value (size_t new_value) |
sets the value to an integer More... | |
void | set_value (std::string &&new_value) |
sets the value to a string More... | |
void | set_value (std::unique_ptr< std::string > new_value) |
sets the value to a string. More... | |
void | set_value (std::unique_ptr< std::vector< double >> new_value) |
sets the value to an array of doubles, without copying More... | |
void | set_value (std::unique_ptr< std::vector< Integer >> new_value) |
sets the value to an array of integers, without copying More... | |
void | set_value (std::vector< double > &&new_value) |
sets the value to an array of doubles More... | |
void | set_value (std::vector< Integer > &&new_value) |
sets the value to an array of integers More... | |
void | set_xml (const char *new_value, size_t size) |
sets the value to an xml string More... | |
void | set_xml (const std::string &new_value) |
sets the value to an xml string More... | |
void | set_xml (std::string &&new_value) |
sets the value to an xml string More... | |
void | set_xml (std::unique_ptr< std::string > new_value) |
sets the value to an xml string. More... | |
std::shared_ptr< const std::vector< unsigned char > > | share_binary () const |
std::shared_ptr< CircBuf > | share_circular_buffer () const |
Get a shared_ptr to the history buffer inside this record. More... | |
std::shared_ptr< const std::vector< double > > | share_doubles () const |
std::shared_ptr< const std::vector< Integer > > | share_integers () const |
std::shared_ptr< const std::string > | share_string () const |
uint32_t | size (void) const |
returns the size of the value More... | |
int | status (void) const |
returns the status of the record. More... | |
double | to_double (void) const |
converts the value to a float/double. More... | |
std::vector< double > | to_doubles (void) const |
converts the value to a vector of doubles More... | |
ssize_t | to_file (const std::string &filename) const |
writes the value to a file More... | |
Integer | to_integer (void) const |
converts the value to an integer. More... | |
std::vector< Integer > | to_integers (void) const |
converts the value to a vector of integers More... | |
size_t | to_managed_buffer (char *buffer, size_t buf_size) const |
converts the value to a c string. More... | |
size_t | to_managed_string (char *buffer, size_t buf_size) const |
converts the value to a c string. More... | |
std::string | to_string (const std::string &delimiter=", ") const |
converts the value to a string. More... | |
unsigned char * | to_unmanaged_buffer (size_t &size) const |
returns an unmanaged buffer that the user will have to take care of (this is a copy of the internal value). More... | |
uint64_t | toi () const |
uint32_t | type (void) const |
returns the type of the value More... | |
void | unshare (void) |
If this record holds a shared_ptr, make a copy of the underlying value so it has an exclusive copy. More... | |
char * | write (char *buffer, const std::string &key, int64_t &buffer_remaining) const |
Writes a KnowledgeRecord instance to a buffer and updates the amount of buffer room remaining. More... | |
char * | write (char *buffer, int64_t &buffer_remaining) const |
Writes a KnowledgeRecord instance to a buffer and updates the amount of buffer room remaining. More... | |
char * | write (char *buffer, uint32_t key_id, int64_t &buffer_remaining) const |
Writes a KnowledgeRecord instance to a buffer and updates the amount of buffer room remaining. More... | |
Static Public Member Functions | |
static int | get_precision (void) |
Gets the current double precision for double to string conversion. More... | |
static bool | is_array_type (uint32_t type) |
returns if the record is a array type (DOUBLE_ARRAY, INTEGER_ARRAY) More... | |
static bool | is_binary_file_type (uint32_t type) |
returns true if the knowledge record has a binary file type More... | |
static bool | is_double_type (uint32_t type) |
returns if the record is a double type (DOUBLE, DOUBLE_ARRAY) More... | |
static bool | is_file_type (uint32_t type) |
returns true if the knowledge record has a file type More... | |
static bool | is_image_type (uint32_t type) |
returns true if the knowledge record has an image type More... | |
static bool | is_integer_type (uint32_t type) |
returns if the record is a integer type (INTEGER, INTEGER_ARRAY) More... | |
static bool | is_ref_counted (uint32_t type) |
returns if the record has a reference-counted type More... | |
static bool | is_string_type (uint32_t type) |
returns if the record is a string type (STRING, XML, TEXT_FILE) More... | |
static void | set_fixed (void) |
Sets the output format for doubles to std::fixed. More... | |
static void | set_precision (int new_precision) |
Sets the double precision of a double record when using to_string (). More... | |
static void | set_scientific (void) |
Sets the output format for doubles to std::scientific. More... | |
Public Attributes | |
uint64_t | clock = 0 |
last modification lamport clock time More... | |
uint32_t | quality = 0 |
priority of the update More... | |
uint32_t | write_quality = 0 |
write priority for any local updates More... | |
std::shared_ptr< CircBuf > | buf_ |
std::shared_ptr< std::vector< double > > | double_array_ |
double | double_value_ |
std::shared_ptr< std::vector< unsigned char > > | file_value_ |
std::shared_ptr< std::vector< Integer > > | int_array_ |
Integer | int_value_ = 0 |
std::shared_ptr< std::string > | str_value_ |
Private Types | |
template<typename T > | |
using | MemberType = std::shared_ptr< T > KnowledgeRecord::* |
Private Member Functions | |
size_t | absolute_index (ssize_t index) const |
void | clear_union (void) noexcept |
template<typename... Args> | |
KnowledgeRecord & | emplace_hist (Args &&... args) |
template<typename T , uint32_t Type, MemberType< T > Member, bool Overwrite = false, typename... Args> | |
std::shared_ptr< const T > | emplace_shared_val (Args &&... args) |
template<typename T , uint32_t Type, MemberType< std::vector< T >> Member, bool Overwrite = false, typename... Args> | |
std::shared_ptr< const std::vector< T > > | emplace_shared_vec (Args &&... args) |
template<typename T , uint32_t Type, MemberType< T > Member, bool Overwrite = false, typename... Args> | |
std::shared_ptr< const T > | emplace_val (Args &&... args) |
template<typename T , uint32_t Type, MemberType< std::vector< T >> Member, bool Overwrite = false, typename... Args> | |
std::shared_ptr< const std::vector< T > > | emplace_vec (Args &&... args) |
KnowledgeRecord & | ref_newest () |
const KnowledgeRecord & | ref_newest () const |
Private Attributes | |
union { | |
std::shared_ptr< CircBuf > buf_ | |
std::shared_ptr< std::vector< double > > double_array_ | |
double double_value_ | |
std::shared_ptr< std::vector< unsigned char > > file_value_ | |
std::shared_ptr< std::vector< Integer > > int_array_ | |
Integer int_value_ = 0 | |
std::shared_ptr< std::string > str_value_ | |
}; | |
Non-array versions of double/integer. More... | |
logger::Logger * | logger_ = logger::global_logger.get() |
the logger used for any internal debugging information More... | |
bool | shared_ = OWNED |
is this knowledge record's shared_ptr, if any, exposed to outside holders? More... | |
uint64_t | toi_ = 0 |
last modification system clock time More... | |
uint32_t | type_ = EMPTY |
type of variable (INTEGER, DOUBLE, STRING, FILE, IMAGE) More... | |
Friends | |
class | ThreadSafeContext |
This class encapsulates an entry in a KnowledgeBase.
Definition at line 87 of file KnowledgeRecord.h.
Definition at line 133 of file KnowledgeRecord.h.
typedef int64_t madara::knowledge::KnowledgeRecord::Integer |
Definition at line 131 of file KnowledgeRecord.h.
|
private |
Definition at line 1772 of file KnowledgeRecord.h.
anonymous enum |
Enumerator | |
---|---|
UNCREATED | |
MODIFIED |
Definition at line 93 of file KnowledgeRecord.h.
anonymous enum |
Enumerator | |
---|---|
OWNED | |
SHARED |
Definition at line 99 of file KnowledgeRecord.h.
enum madara::knowledge::KnowledgeRecord::ValueTypes : uint32_t |
Definition at line 105 of file KnowledgeRecord.h.
|
inlinenoexcept |
Definition at line 205 of file KnowledgeRecord.h.
|
inlineexplicitnoexcept |
Definition at line 25 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 32 of file KnowledgeRecord.inl.
|
explicitnoexcept |
|
inlineexplicit |
Definition at line 46 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 53 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 60 of file KnowledgeRecord.inl.
|
inlineexplicit |
Definition at line 68 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 75 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 82 of file KnowledgeRecord.inl.
|
inline |
Definition at line 89 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 96 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 103 of file KnowledgeRecord.inl.
|
inlineexplicit |
Definition at line 110 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 117 of file KnowledgeRecord.inl.
|
inlineexplicit |
Construct using CircularBuffer directly.
This buffer will be treated as the history of this record, and used as such going forward.
buffer | buffer that will be copied into this record |
logger | the logger to use for logging |
Definition at line 125 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Construct using CircularBuffer directly.
This buffer will be treated as the history of this record, and used as such going forward.
buffer | buffer that will be copied into this record |
logger | the logger to use for logging |
Definition at line 132 of file KnowledgeRecord.inl.
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 202 of file KnowledgeRecord.inl.
|
inline |
Forwarding constructor for integer arrays Each argument past the first will be forwarded to construct a std::vector<Integer> in-place within the new record.
Definition at line 414 of file KnowledgeRecord.h.
|
inline |
Forwarding constructor for double arrays Each argument past the first will be forwarded to construct a std::vector<double> in-place within the new record.
Definition at line 427 of file KnowledgeRecord.h.
|
inline |
Forwarding constructor for strings Each argument past the first will be forwarded to construct a std::string in-place within the new record.
For example: KnowledgeRecord rec (tags::string, "Hello World");
Definition at line 443 of file KnowledgeRecord.h.
|
inline |
Forwarding constructor for binary files (blobs) Each argument past the first will be forwarded to construct a std::vector<unsigned char> in-place within the new record.
Definition at line 455 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1460 of file KnowledgeRecord.h.
int madara::knowledge::KnowledgeRecord::apply | ( | madara::knowledge::ThreadSafeContext & | context, |
const std::string & | key, | ||
unsigned int | quality, | ||
uint64_t | clock, | ||
bool | perform_lock | ||
) |
Apply the knowledge record to a context, given some quality and clock.
Definition at line 1308 of file KnowledgeRecord.cpp.
|
inline |
Clear all history for this record, keeping the current value.
Definition at line 1454 of file KnowledgeRecord.h.
|
inlineprivatenoexcept |
Definition at line 966 of file KnowledgeRecord.inl.
|
inlinenoexcept |
clears any dynamic values.
This method does not attempt to set the value of the Knowledge Record, as clear does, and is consequently more efficient.
Definition at line 984 of file KnowledgeRecord.inl.
|
inline |
clones the record.
Caller must ensure returned pointer is deleted.
Definition at line 707 of file KnowledgeRecord.inl.
|
inline |
Set metadata of this record equal to that of new_value, but doesn't change value.
Metadata is toi, clock, quality, write_quality, and logger.
Definition at line 207 of file KnowledgeRecord.inl.
KnowledgeRecord madara::knowledge::KnowledgeRecord::dec_index | ( | size_t | index | ) |
decrements the value at the index to the specified value.
If the record was previously not an array or if the array is not large enough, a new array is created.
index | index of the value to set |
Definition at line 1188 of file KnowledgeRecord.cpp.
|
inline |
Creates a deep copy of this knowledge record.
Because each Knowledge Record may contain non-thread-safe ref counted values, user threads that reference knowledge records will want to use their own ref counts, which can be accomplished via this method.
Definition at line 722 of file KnowledgeRecord.inl.
|
inline |
Creates a deep copy of the knowledge record.
Because each Knowledge Record may contain non-thread-safe ref counted values, user threads that reference knowledge records will want to use their own ref counts, which can be accomplished via this method.
source | the Knowledge Record we wish to copy |
Definition at line 716 of file KnowledgeRecord.inl.
|
inline |
Construct a binary (vector of unsigned char) within this KnowledgeRecord.
args | arguments forwarded to the vector constructor |
Definition at line 388 of file KnowledgeRecord.h.
|
inline |
Construct a vector of doubles within this KnowledgeRecord.
args | arguments forwarded to the vector constructor |
Definition at line 342 of file KnowledgeRecord.h.
|
inline |
Construct a vector of integers within this KnowledgeRecord.
args | arguments forwarded to the vector constructor |
Definition at line 319 of file KnowledgeRecord.h.
|
inline |
Construct a string within this KnowledgeRecord.
args | arguments forwarded to the string constructor |
Definition at line 365 of file KnowledgeRecord.h.
|
inline |
Construct a vector of doubles within this KnowledgeRecord.
args | All arguments are forwarded to the vector constructor |
Definition at line 330 of file KnowledgeRecord.h.
|
inline |
Construct a file (vector of unsigned char) within this KnowledgeRecord.
args | All arguments are forwarded to the vector constructor |
Definition at line 376 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1765 of file KnowledgeRecord.h.
|
inline |
Construct a vector of integers within this KnowledgeRecord.
args | All arguments are forwarded to the vector constructor |
Definition at line 307 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1776 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1803 of file KnowledgeRecord.h.
|
inline |
Construct a string within this KnowledgeRecord.
args | All arguments are forwarded to the string constructor |
Definition at line 353 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1795 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1811 of file KnowledgeRecord.h.
|
inline |
Checks if record exists (i.e., is not uncreated)
Definition at line 729 of file KnowledgeRecord.inl.
|
inline |
Execute a callable for each history element.
Definition at line 1478 of file KnowledgeRecord.h.
KnowledgeRecord madara::knowledge::KnowledgeRecord::fragment | ( | unsigned int | first, |
unsigned int | last | ||
) |
returns a record containing a fragment of the character buffer.
For strings, this is equivalent to substring. For files, this is like an unsigned char * equivalent to substring. For other types, this will return host-specific byte values up to the size of the value.
first | first index (inclusive, >= 0) |
last | last index (inclusive, < size) |
Definition at line 586 of file KnowledgeRecord.cpp.
|
inline |
Returns the encoded size of the record.
This size is what is required to write the key_size, key, type, value size, and all associated information in the read () and write () methods.
Definition at line 840 of file KnowledgeRecord.inl.
|
inline |
Returns the encoded size of the record.
This size is what is required to write the type, value size, and all associated information in the read () and write () methods.
Definition at line 804 of file KnowledgeRecord.inl.
|
inline |
Get a copy of the entire stored history of this record.
Definition at line 1643 of file KnowledgeRecord.h.
|
inline |
Get a copy of the entire stored history of this record in a vector of the given element type, which must support knoweldge_cast<> from KnowledgeRecord.
Definition at line 1677 of file KnowledgeRecord.h.
|
inline |
Copy the stored history of this record to the given output iterator, in order from oldest to newest.
Definition at line 1666 of file KnowledgeRecord.h.
|
inline |
Copy the given range of history to the output iterator given.
Indexing starts from oldest history entry in the buffer at index 0. Negative indices count from newest entries (-1 is newest).
Definition at line 1656 of file KnowledgeRecord.h.
|
inline |
Return the given entry in this record's history.
Indexing starts from oldest history entry in the buffer at index 0. Negative indices count from newest entries (-1 is newest).
Definition at line 1701 of file KnowledgeRecord.h.
|
inline |
Return a copy of the given range of history in a vector.
Indexing starts from oldest history entry in the buffer at index 0. Negative indices count from newest entries (-1 is newest).
Definition at line 1689 of file KnowledgeRecord.h.
|
inline |
Return the maximum amount of history this record can hold.
Use set_history_capacity to adjust this.
Definition at line 1395 of file KnowledgeRecord.h.
|
inline |
Gets the absolute index of the newest element in stored history.
If this record doesn't have history capacity, throws IndexException
Definition at line 1712 of file KnowledgeRecord.h.
|
inline |
Gets the absolute index of the oldest element in stored history.
If this record doesn't have history capacity, throws IndexException
Definition at line 1727 of file KnowledgeRecord.h.
size_t madara::knowledge::KnowledgeRecord::get_history_range | ( | OutputIterator | out, |
size_t | index, | ||
size_t | count | ||
) | const |
Copy the given absolute range of history to the output iterator given.
Indexing is absolute, starting with the initial value of the record, not relative to the circular buffer contents. You likely want to use get_history instead.
Definition at line 526 of file KnowledgeCast.h.
|
inline |
Return the amount of history this record holds.
Definition at line 1376 of file KnowledgeRecord.h.
|
inline |
Return the newest stored history entry of this record.
Definition at line 1573 of file KnowledgeRecord.h.
|
inline |
Copy the newest stored history entry of this record to the given output iterator.
Definition at line 1555 of file KnowledgeRecord.h.
|
inline |
Copy the count newest stored history entries of this record to the given output iterator, in order from oldest to newest.
Definition at line 1545 of file KnowledgeRecord.h.
|
inline |
Return the count newest stored history entries of this record in a vector.
Definition at line 1620 of file KnowledgeRecord.h.
|
inline |
Return the count newest stored history entries of this record in a vector of the given element type, which must support knoweldge_cast<> from KnowledgeRecord.
Definition at line 1633 of file KnowledgeRecord.h.
|
inline |
Return the oldest stored history entry of this record.
Definition at line 1563 of file KnowledgeRecord.h.
|
inline |
Copy the oldest stored history entry of this record to the given output iterator.
Definition at line 1535 of file KnowledgeRecord.h.
|
inline |
Copy the count oldest stored history entries of this record to the given output iterator, in order from oldest to newest.
Definition at line 1525 of file KnowledgeRecord.h.
|
inline |
Return the count oldest stored history entries of this record in a vector.
Definition at line 1596 of file KnowledgeRecord.h.
|
inline |
Return the count oldest stored history entries of this record in a vector of the given element type, which must support knoweldge_cast<> from KnowledgeRecord.
Definition at line 1609 of file KnowledgeRecord.h.
|
static |
Gets the current double precision for double to string conversion.
Definition at line 27 of file KnowledgeRecord.cpp.
|
inline |
Return true if this record has a circular buffer history.
Use set_history_capacity to add a buffer
Definition at line 1368 of file KnowledgeRecord.h.
KnowledgeRecord madara::knowledge::KnowledgeRecord::inc_index | ( | size_t | index | ) |
increments the value at the index to the specified value.
If the record was previously not an array or if the array is not large enough, a new array is created.
index | index of the value to set |
Definition at line 1222 of file KnowledgeRecord.cpp.
|
inlinestatic |
returns if the record is a array type (DOUBLE_ARRAY, INTEGER_ARRAY)
type | the type to check |
Definition at line 898 of file KnowledgeRecord.inl.
|
inline |
returns if the record is an array type (DOUBLE_ARRAY, INTEGER_ARRAY)
Definition at line 893 of file KnowledgeRecord.inl.
|
inlinestatic |
returns true if the knowledge record has a binary file type
type | the type of the record |
Definition at line 929 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has a binary file type
Definition at line 924 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record is a double type (DOUBLE, DOUBLE_ARRAY)
type | the type to check |
Definition at line 878 of file KnowledgeRecord.inl.
|
inline |
returns if the record is a double type (DOUBLE, DOUBLE_ARRAY)
Definition at line 873 of file KnowledgeRecord.inl.
|
inline |
Checks to see if the record is false.
For integers and boules, false means the value is zero. For strings, it means the value is "".
Definition at line 640 of file KnowledgeRecord.inl.
|
inlinestatic |
returns true if the knowledge record has a file type
type | the type of the record |
Definition at line 918 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has a file type
Definition at line 913 of file KnowledgeRecord.inl.
|
inlinestatic |
returns true if the knowledge record has an image type
type | the type of the record |
Definition at line 908 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has an image type
Definition at line 903 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record is a integer type (INTEGER, INTEGER_ARRAY)
type | the type to check |
Definition at line 888 of file KnowledgeRecord.inl.
|
inline |
returns if the record is a integer type (INTEGER, INTEGER_ARRAY)
Definition at line 883 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record has a reference-counted type
type | the type to check |
Definition at line 858 of file KnowledgeRecord.inl.
|
inline |
returns if the record has a reference-counted type
Definition at line 853 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record is a string type (STRING, XML, TEXT_FILE)
type | the type to check |
Definition at line 868 of file KnowledgeRecord.inl.
|
inline |
returns true if the record is a string type (STRING, XML, TEXT_FILE)
Definition at line 863 of file KnowledgeRecord.inl.
bool madara::knowledge::KnowledgeRecord::is_true | ( | void | ) | const |
Checks to see if the record is true.
For integers and doubles, true means the value is non-zero. For strings, it means the value is non "";
Definition at line 1381 of file KnowledgeRecord.cpp.
|
inline |
Checks to see if the record is valid.
Valid records have a status that is not UNCREATED.
Definition at line 1345 of file KnowledgeRecord.h.
|
inlineexplicit |
Explicit bool cast.
Definition at line 1632 of file KnowledgeRecord.inl.
|
inline |
Logical not.
Definition at line 381 of file KnowledgeRecord.inl.
|
inline |
Unequal to.
Definition at line 372 of file KnowledgeRecord.inl.
|
inline |
Modulus operator.
Definition at line 619 of file KnowledgeRecord.inl.
|
inline |
In-place modulus operator.
Definition at line 571 of file KnowledgeRecord.inl.
|
inline |
Times operator.
Definition at line 595 of file KnowledgeRecord.inl.
|
inline |
In-place multiplication operator.
Definition at line 507 of file KnowledgeRecord.inl.
|
inline |
Plus operator.
Definition at line 631 of file KnowledgeRecord.inl.
|
inline |
|
inline |
In-place addition operator.
Definition at line 412 of file KnowledgeRecord.inl.
|
inline |
Minus operator.
Definition at line 665 of file KnowledgeRecord.inl.
|
inline |
Negate.
Definition at line 389 of file KnowledgeRecord.inl.
|
inline |
|
inline |
In-place subtraction operator.
Definition at line 485 of file KnowledgeRecord.inl.
|
inline |
Divides operator.
Definition at line 607 of file KnowledgeRecord.inl.
|
inline |
In-place division operator.
Definition at line 529 of file KnowledgeRecord.inl.
bool madara::knowledge::KnowledgeRecord::operator< | ( | const KnowledgeRecord & | rhs | ) | const |
Less than.
Definition at line 669 of file KnowledgeRecord.cpp.
bool madara::knowledge::KnowledgeRecord::operator<= | ( | const KnowledgeRecord & | rhs | ) | const |
Less than or equal to.
Definition at line 764 of file KnowledgeRecord.cpp.
|
inline |
Assignment.
Definition at line 350 of file KnowledgeRecord.inl.
|
inlinenoexcept |
Move Assignment.
Definition at line 361 of file KnowledgeRecord.inl.
|
inline |
Assigns a convertible value to the knowledge record.
Definition at line 1147 of file KnowledgeRecord.h.
bool madara::knowledge::KnowledgeRecord::operator== | ( | const KnowledgeRecord & | rhs | ) | const |
Equal to.
Definition at line 859 of file KnowledgeRecord.cpp.
bool madara::knowledge::KnowledgeRecord::operator> | ( | const KnowledgeRecord & | rhs | ) | const |
Greater than.
Definition at line 974 of file KnowledgeRecord.cpp.
bool madara::knowledge::KnowledgeRecord::operator>= | ( | const KnowledgeRecord & | rhs | ) | const |
Greater than or equal to.
Definition at line 1070 of file KnowledgeRecord.cpp.
|
inline |
Clears everything including history, but excluding metadata (e.g., toi, clock) and copies value from new_value into this recod.
Definition at line 281 of file KnowledgeRecord.inl.
|
inline |
Clears everything including history, but excluding metadata (e.g., toi, clock) and moves value from new_value into this recod.
Definition at line 314 of file KnowledgeRecord.inl.
|
inline |
Construct a CircularBuffer within this KnowledgeRecord directly.
This buffer will be treated as the history of this record, and used as such going forward.
args | arguments forwarded to the madara::utility::CircularBuffer constructor |
Definition at line 402 of file KnowledgeRecord.h.
|
inline |
Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining.
buffer | the readable buffer where data is stored |
buffer_remaining | the count of bytes remaining in the buffer to read |
Definition at line 991 of file KnowledgeRecord.inl.
|
inline |
Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining.
buffer | the readable buffer where data is stored |
key | the name of the variable |
buffer_remaining | the count of bytes remaining in the buffer to read |
Definition at line 1125 of file KnowledgeRecord.inl.
|
inline |
Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining.
buffer | the readable buffer where data is stored |
key_id | the keyed index for the name of a variable |
buffer_remaining | the count of bytes remaining in the buffer to read |
Definition at line 1164 of file KnowledgeRecord.inl.
int madara::knowledge::KnowledgeRecord::read_file | ( | const std::string & | filename, |
uint32_t | read_as_type = 0 |
||
) |
reads a file and sets the type appropriately according to the extension
filename | location of the file to read from |
read_as_type | force a type (XML, TEXT, IMAGE_JPEG, or UNKNOWN_FILE_TYPE) |
Definition at line 60 of file KnowledgeRecord.cpp.
|
inlineprivate |
Definition at line 1581 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1586 of file KnowledgeRecord.h.
|
inlinenoexcept |
resets the variable to an integer
Definition at line 1185 of file KnowledgeRecord.inl.
void madara::knowledge::KnowledgeRecord::resize | ( | size_t | new_size | ) |
resizes an array to a new size
new_size | new size of the array |
Definition at line 1256 of file KnowledgeRecord.cpp.
KnowledgeRecord madara::knowledge::KnowledgeRecord::retrieve_index | ( | size_t | index | ) | const |
retrieves the value at an array index.
If the knowledge record is not an array, false is returned.
index | index of the array item |
Definition at line 1166 of file KnowledgeRecord.cpp.
|
inline |
sets the value to an unknown file type
new_value | new value of the Knowledge Record |
Definition at line 1321 of file KnowledgeRecord.inl.
|
inline |
sets the value to an unknown file type
new_value | new value of the Knowledge Record |
size | size of the new_value buffer |
Definition at line 1308 of file KnowledgeRecord.inl.
|
inline |
sets the value to an unknown file type, without copying
new_value | new value of the Knowledge Record |
Definition at line 1328 of file KnowledgeRecord.inl.
|
inline |
sets the value to an unknown file type, without copying
new_value | new value of the Knowledge Record |
Definition at line 1315 of file KnowledgeRecord.inl.
|
static |
Sets the output format for doubles to std::fixed.
Definition at line 42 of file KnowledgeRecord.cpp.
|
inline |
Sets the value and meta data from another KnowledgeRecord.
new_value | new value of the Knowledge Record |
Definition at line 263 of file KnowledgeRecord.inl.
|
inline |
Sets the value and meta data from another KnowledgeRecord.
new_value | new value of the Knowledge Record |
Definition at line 272 of file KnowledgeRecord.inl.
|
inline |
Set the capacity of this record's history circular buffer.
Every modification to this record will write a new entry in this history. Once the capacity is met, the oldest entry will be discarded as new entries are added.
Note that this capacity includes current value of the record. A capacity of zero indicates that this record holds no buffer, whereas one indicates that this record has a buffer of size 1.
Definition at line 1417 of file KnowledgeRecord.h.
|
inline |
sets the value at the index to the specified value.
If the record was previously not an array or if the array is not large enough, a new array is created.
index | index of the value to set |
value | the value to set at the specified index |
If the record was previously not an array or if the array is not large enough, a new array is created.
Definition at line 1485 of file KnowledgeRecord.inl.
void madara::knowledge::KnowledgeRecord::set_index | ( | size_t | index, |
T | value | ||
) |
sets the value at the index to the specified value.
If the record was previously not an array or if the array is not large enough, a new array is created.
index | index of the value to set |
value | the value to set at the specified index |
|
inline |
sets the value to a jpeg
new_value | new value of the Knowledge Record |
Definition at line 1293 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg
new_value | new value of the Knowledge Record |
size | size of the new_value buffer |
Definition at line 1280 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg, without copying
new_value | new value of the Knowledge Record |
Definition at line 1300 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg, without copying
new_value | new value of the Knowledge Record |
Definition at line 1287 of file KnowledgeRecord.inl.
|
inline |
sets the status to modified
Definition at line 742 of file KnowledgeRecord.inl.
|
static |
Sets the double precision of a double record when using to_string ().
All doubles will have this fixed precision. To return to default precision, set new_precision to a negative number.
new_precision | new double precision to use |
Definition at line 32 of file KnowledgeRecord.cpp.
|
static |
Sets the output format for doubles to std::scientific.
Definition at line 51 of file KnowledgeRecord.cpp.
|
inline |
sets the value to a plaintext string
new_value | new value of the Knowledge Record |
size | size of the new_value buffer |
Definition at line 1252 of file KnowledgeRecord.inl.
|
inline |
sets the value to a plaintext string
new_value | new value of the Knowledge Record |
Definition at line 1266 of file KnowledgeRecord.inl.
|
inline |
sets the value to a plaintext string
new_value | new value of the Knowledge Record |
Definition at line 1259 of file KnowledgeRecord.inl.
|
inline |
sets the value to a plaintext string.
Does not copy the string.
new_value | new value of the Knowledge Record |
Definition at line 1273 of file KnowledgeRecord.inl.
|
inline |
Definition at line 156 of file KnowledgeRecord.h.
|
inline |
Modify the type, but only if it's compatible with current type without changing any actual data stored.
I.e., STRING, TEXT_FILE, and XML can be converted between each other, and UKNOWN_BINARY_FILE, IMAGE_JPEG can be converted between each other.
type | the new type |
Definition at line 784 of file KnowledgeRecord.inl.
|
inline |
sets the value to a string, from a buffer
new_value | new value of the Knowledge Record |
size | num elements in the buffer |
Definition at line 1217 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of doubles
new_value | new value of the Knowledge Record |
size | num elements in the array |
Definition at line 1454 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of integers
new_value | new value of the Knowledge Record |
size | num elements in the array |
Definition at line 1428 of file KnowledgeRecord.inl.
|
inline |
Sets the value from another KnowledgeRecord, does not copy toi, clock, and write_quality.
new_value | new value of the Knowledge Record |
Definition at line 216 of file KnowledgeRecord.inl.
|
inline |
sets the value to a string
new_value | new value of the Knowledge Record |
Definition at line 1203 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of doubles
new_value | new value of the Knowledge Record |
Definition at line 1466 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of integers
new_value | new value of the Knowledge Record |
Definition at line 1440 of file KnowledgeRecord.inl.
|
inline |
sets the value to a double
new_value | new value of the Knowledge Record |
Definition at line 1390 of file KnowledgeRecord.inl.
|
inline |
sets the value to a float
new_value | new value of the Knowledge Record |
Definition at line 1409 of file KnowledgeRecord.inl.
|
inline |
sets the value to an integer
new_value | new value of the Knowledge Record |
Definition at line 1353 of file KnowledgeRecord.inl.
|
inline |
sets the value to an integer
new_value | new value of the Knowledge Record |
Definition at line 1335 of file KnowledgeRecord.inl.
|
inline |
Sets the value from another KnowledgeRecord, does not copy toi, clock, and write_quality.
new_value | new value of the Knowledge Record |
Definition at line 236 of file KnowledgeRecord.inl.
|
inline |
sets the value to an integer
new_value | new value of the Knowledge Record |
Definition at line 1371 of file KnowledgeRecord.inl.
|
inline |
sets the value to a string
new_value | new value of the Knowledge Record |
Definition at line 1196 of file KnowledgeRecord.inl.
|
inline |
sets the value to a string.
Does not copy the string.
new_value | new value of the Knowledge Record |
Definition at line 1210 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of doubles, without copying
new_value | new value of the Knowledge Record |
Definition at line 1472 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of integers, without copying
new_value | new value of the Knowledge Record |
Definition at line 1446 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of doubles
new_value | new value of the Knowledge Record |
Definition at line 1460 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of integers
new_value | new value of the Knowledge Record |
Definition at line 1434 of file KnowledgeRecord.inl.
|
inline |
sets the value to an xml string
new_value | new value of the Knowledge Record |
size | size of the new_value buffer |
Definition at line 1224 of file KnowledgeRecord.inl.
|
inline |
sets the value to an xml string
new_value | new value of the Knowledge Record |
Definition at line 1238 of file KnowledgeRecord.inl.
|
inline |
sets the value to an xml string
new_value | new value of the Knowledge Record |
Definition at line 1231 of file KnowledgeRecord.inl.
|
inline |
sets the value to an xml string.
Does not copy the string.
new_value | new value of the Knowledge Record |
Definition at line 1245 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1607 of file KnowledgeRecord.inl.
|
inline |
Get a shared_ptr to the history buffer inside this record.
Returns nullptr if this record has no history capacity.
Definition at line 1622 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1592 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1577 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1562 of file KnowledgeRecord.inl.
|
inline |
returns the size of the value
Definition at line 750 of file KnowledgeRecord.inl.
|
inline |
returns the status of the record.
Definition at line 734 of file KnowledgeRecord.inl.
double madara::knowledge::KnowledgeRecord::to_double | ( | void | ) | const |
converts the value to a float/double.
This operation tries to convert as best as it can using reasonable conversions. For doubles and integers, it uses the scalar conversion to double. For int/double arrays, it will use the same scalar conversion of the first element. For strings, it will try to convert with a stringstream.
Definition at line 155 of file KnowledgeRecord.cpp.
std::vector< double > madara::knowledge::KnowledgeRecord::to_doubles | ( | void | ) | const |
converts the value to a vector of doubles
Definition at line 276 of file KnowledgeRecord.cpp.
ssize_t madara::knowledge::KnowledgeRecord::to_file | ( | const std::string & | filename | ) | const |
writes the value to a file
filename | file location to write to |
Definition at line 126 of file KnowledgeRecord.cpp.
KnowledgeRecord::Integer madara::knowledge::KnowledgeRecord::to_integer | ( | void | ) | const |
converts the value to an integer.
This operation tries to convert as best as it can using reasonable conversions. For doubles and integers, it uses the scalar conversion to integer (e.g., floor for double). For int/double arrays, it will use the same scalar conversion of the first element. For strings, it will try to convert with a stringstream.
Definition at line 188 of file KnowledgeRecord.cpp.
std::vector< KnowledgeRecord::Integer > madara::knowledge::KnowledgeRecord::to_integers | ( | void | ) | const |
converts the value to a vector of integers
Definition at line 221 of file KnowledgeRecord.cpp.
size_t madara::knowledge::KnowledgeRecord::to_managed_buffer | ( | char * | buffer, |
size_t | buf_size | ||
) | const |
converts the value to a c string.
Similar to unmanaged buffer except the user is expected to have malloc'd, new'd, etc. the buffer beforehand. Of note, this method is intended to provide an exact copy of a record's contents and not the string equivalent. In other words, this will not be a null-delimited string. This will be a raw string with no null ending unless a 0 was an actual element of the character buffer.
buffer | the user-managed character buffer to fill |
buf_size | the character buffer max size |
Definition at line 338 of file KnowledgeRecord.cpp.
size_t madara::knowledge::KnowledgeRecord::to_managed_string | ( | char * | buffer, |
size_t | buf_size | ||
) | const |
converts the value to a c string.
This is the equivalent to calling to_string and then copying it to the buffer. It just doesn't cause exceptions with STL errors (e.g., in Unreal Engine plugins)
buffer | the user-managed character buffer to fill |
buf_size | the character buffer max size |
Definition at line 329 of file KnowledgeRecord.cpp.
std::string madara::knowledge::KnowledgeRecord::to_string | ( | const std::string & | delimiter = ", " | ) | const |
converts the value to a string.
delimiter | characters to insert in between elements of an array |
Definition at line 401 of file KnowledgeRecord.cpp.
unsigned char * madara::knowledge::KnowledgeRecord::to_unmanaged_buffer | ( | size_t & | size | ) | const |
returns an unmanaged buffer that the user will have to take care of (this is a copy of the internal value).
If you use this function, you must explicitly delete the value returned. For instance:
char * my_value = record.to_unmanaged_buffer (); ... do some work on the buffer delete [] my_value;
Failure to do the above WILL result in a memory leak
size | size of the unmanaged buffer |
Definition at line 533 of file KnowledgeRecord.cpp.
|
inline |
Definition at line 152 of file KnowledgeRecord.h.
|
inline |
returns the type of the value
Definition at line 779 of file KnowledgeRecord.inl.
|
inline |
If this record holds a shared_ptr, make a copy of the underlying value so it has an exclusive copy.
Definition at line 674 of file KnowledgeRecord.inl.
|
inline |
Writes a KnowledgeRecord instance to a buffer and updates the amount of buffer room remaining.
Output Format:
[key_size | key | type | value_size | value]
key_size = 32 bit unsigned integer, length of the key
key = key_size characters, the ASCII key
type = 32 bit unsigned integer, the type of value
size = 32 bit unsigned integer, number of elements of the type
value = the stored value
buffer | the readable buffer where data is stored |
key | the name of the variable |
buffer_remaining | the count of bytes remaining in the buffer to read |
Definition at line 1802 of file KnowledgeRecord.inl.
|
inline |
Writes a KnowledgeRecord instance to a buffer and updates the amount of buffer room remaining.
Output Format:
[type | value_size | value]
type = 32 bit unsigned integer, the type of value
size = 32 bit unsigned integer, number of elements of the type
value = the stored value
buffer | the readable buffer where data is stored |
buffer_remaining | the count of bytes remaining in the buffer to read |
note that we once converted doubles into strings to attempt portability, but we are now just assuming that the floating point units in the architecture are the same endianness as the integers. This is true of ARM, Intel/AMD, and most architectures. We are essentially no longer supporting an architecture that mixes and matches. Persons using such architectures should perform their own conversions on the knowledge records before using them.
Definition at line 1637 of file KnowledgeRecord.inl.
|
inline |
Writes a KnowledgeRecord instance to a buffer and updates the amount of buffer room remaining.
This is a write method intended for keyed indexes for variables, generally for perfect hashes
Output Format:
[key_size | key | type | value_size | value]
key_size = 32 bit unsigned integer, length of the key
key = key_size characters, the ASCII key
type = 32 bit unsigned integer, the type of value
size = 32 bit unsigned integer, number of elements of the type
value = the stored value
buffer | the readable buffer where data is stored |
key_id | the id of the variable |
buffer_remaining | the count of bytes remaining in the buffer to read |
Definition at line 1856 of file KnowledgeRecord.inl.
|
friend |
Definition at line 91 of file KnowledgeRecord.h.
union { ... } |
Non-array versions of double/integer.
About 10x faster than using the ref-counted arrays
std::shared_ptr<CircBuf> madara::knowledge::KnowledgeRecord::buf_ |
Definition at line 189 of file KnowledgeRecord.h.
uint64_t madara::knowledge::KnowledgeRecord::clock = 0 |
last modification lamport clock time
Definition at line 143 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<double> > madara::knowledge::KnowledgeRecord::double_array_ |
Definition at line 185 of file KnowledgeRecord.h.
double madara::knowledge::KnowledgeRecord::double_value_ |
Definition at line 182 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<unsigned char> > madara::knowledge::KnowledgeRecord::file_value_ |
Definition at line 187 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<Integer> > madara::knowledge::KnowledgeRecord::int_array_ |
Definition at line 184 of file KnowledgeRecord.h.
Integer madara::knowledge::KnowledgeRecord::int_value_ = 0 |
Definition at line 181 of file KnowledgeRecord.h.
|
private |
the logger used for any internal debugging information
Definition at line 137 of file KnowledgeRecord.h.
uint32_t madara::knowledge::KnowledgeRecord::quality = 0 |
priority of the update
Definition at line 168 of file KnowledgeRecord.h.
|
mutableprivate |
is this knowledge record's shared_ptr, if any, exposed to outside holders?
Definition at line 201 of file KnowledgeRecord.h.
std::shared_ptr<std::string> madara::knowledge::KnowledgeRecord::str_value_ |
Definition at line 186 of file KnowledgeRecord.h.
|
private |
last modification system clock time
Definition at line 149 of file KnowledgeRecord.h.
|
private |
type of variable (INTEGER, DOUBLE, STRING, FILE, IMAGE)
Definition at line 195 of file KnowledgeRecord.h.
uint32_t madara::knowledge::KnowledgeRecord::write_quality = 0 |
write priority for any local updates
Definition at line 173 of file KnowledgeRecord.h.