MADARA
3.2.3
|
This class encapsulates an entry in a KnowledgeBase. More...
#include <KnowledgeRecord.h>
Public Types | |
enum | { UNCREATED = 0, MODIFIED = 1 } |
enum | { OWNED = 0, SHARED = 1 } |
typedef int64_t | Integer |
enum | ValueTypes { 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 } |
Public Member Functions | |
KnowledgeRecord () noexcept | |
KnowledgeRecord (logger::Logger &logger) noexcept | |
template<typename T , typename std::enable_if< std::is_integral< T >::value, void * >::type = nullptr> | |
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 | |
KnowledgeRecord (const std::vector< Integer > &value, logger::Logger &logger=*logger::global_logger.get()) | |
KnowledgeRecord (std::vector< Integer > &&value, logger::Logger &logger=*logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::shared_ptr< std::vector< Integer >> value, logger::Logger &logger=*logger::global_logger.get()) noexcept | |
KnowledgeRecord (const std::vector< double > &value, logger::Logger &logger=*logger::global_logger.get()) | |
KnowledgeRecord (std::vector< double > &&value, logger::Logger &logger=*logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::shared_ptr< std::vector< double >> value, logger::Logger &logger=*logger::global_logger.get()) noexcept | |
KnowledgeRecord (const std::string &value, logger::Logger &logger=*logger::global_logger.get()) | |
KnowledgeRecord (std::string &&value, logger::Logger &logger=*logger::global_logger.get()) noexcept | |
KnowledgeRecord (std::shared_ptr< std::string > value, logger::Logger &logger=*logger::global_logger.get()) noexcept | |
KnowledgeRecord (const char *value, logger::Logger &logger=*logger::global_logger.get()) | |
KnowledgeRecord (std::shared_ptr< std::vector< unsigned char >> value, logger::Logger &logger=*logger::global_logger.get()) noexcept | |
KnowledgeRecord (const KnowledgeRecord &rhs) | |
KnowledgeRecord (KnowledgeRecord &&rhs) noexcept | |
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::shared_t< tags::integers_t >, Args &&...args) | |
Forwarding constructor for integer arrays shared_ptr Each argument past the first will be forwarded to construct a std::shared_ptr<std::vector<Integer>> 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::shared_t< tags::doubles_t >, Args &&...args) | |
Forwarding constructor for double arrays shared_ptr Each argument past the first will be forwarded to construct a std::shared_ptr<std::vector<double>> 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... | |
template<typename... Args> | |
KnowledgeRecord (tags::shared_t< tags::string_t >, Args &&...args) | |
Forwarding constructor for double arrays shared_ptr Each argument past the first will be forwarded to construct a std::shared_ptr<std::string> in-place within the new record. More... | |
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::shared_t< tags::binary_t >, Args &&...args) | |
Forwarding constructor for binary file (blob) shared_ptr Each argument past the first will be forwarded to construct a std::shared_ptr<std::vector<unsigned char>> 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_value (void) noexcept |
clears any dynamic values. More... | |
KnowledgeRecord * | clone (void) const |
clones the record. More... | |
KnowledgeRecord | dec_index (size_t index) |
decrements the value at the index to the specified value. More... | |
void | deep_copy (const KnowledgeRecord &source) |
Creates a deep copy of the knowledge record. More... | |
KnowledgeRecord | deep_copy () const |
Creates a deep copy of this knowledge record. More... | |
template<typename... Args> | |
void | emplace (tags::shared_t< tags::integers_t >, Args &&...args) |
Construct a shared_ptr to vector of integers 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::shared_t< tags::doubles_t >, Args &&...args) |
Construct a shared_ptr to vector of doubles 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::shared_t< tags::string_t >, Args &&...args) |
Construct a shared_ptr to string 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 (tags::shared_t< tags::binary_t >, Args &&...args) |
Construct a shared_ptr to binary (vector of unsigned char) within this KnowledgeRecord. 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_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_shared_doubles (Args &&...args) |
Construct a shared_ptr to vector of doubles within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace_shared_file (Args &&...args) |
Construct a shared_ptr to a file (vector of unsigned char) within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace_shared_integers (Args &&...args) |
Construct a shared_ptr to vector of integers within this KnowledgeRecord. More... | |
template<typename... Args> | |
void | emplace_shared_string (Args &&...args) |
Construct a shared_ptr to a string 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... | |
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... | |
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- (void) const |
Negate. More... | |
KnowledgeRecord | operator- (const KnowledgeRecord &rhs) const |
Minus operator. 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... | |
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 |
KnowledgeRecord & | operator= (const KnowledgeRecord &rhs) |
Assignment. More... | |
KnowledgeRecord & | operator= (KnowledgeRecord &&rhs) noexcept |
Move Assignment. 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... | |
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 unsigned char *new_value, size_t size) |
sets the value to an unknown file type More... | |
void | set_file (std::vector< unsigned char > &&new_value) |
sets the value to an unknown file type, without copying More... | |
void | set_file (const std::vector< unsigned char > &new_value) |
sets the value to an unknown file type More... | |
void | set_file (std::shared_ptr< std::vector< unsigned char >> new_value) |
sets the value to an unknown file type, without copying More... | |
template<typename T , typename std::enable_if< std::is_integral< T >::value, void * >::type = nullptr> | |
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 unsigned char *new_value, size_t size) |
sets the value to a jpeg More... | |
void | set_jpeg (std::vector< unsigned char > &&new_value) |
sets the value to a jpeg, without copying More... | |
void | set_jpeg (const std::vector< unsigned char > &new_value) |
sets the value to a jpeg More... | |
void | set_jpeg (std::shared_ptr< 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 (std::string &&new_value) |
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::shared_ptr< std::string > new_value) |
sets the value to a plaintext string. More... | |
bool | set_type (int32_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 KnowledgeRecord &new_value) |
Sets the value from another KnowledgeRecord, does not copy clock and write_quality. More... | |
void | set_value (KnowledgeRecord &&new_value) |
Sets the value from another KnowledgeRecord, does not copy clock and write_quality. More... | |
template<typename T , typename std::enable_if< std::is_integral< T >::value, void * >::type = nullptr> | |
void | set_value (T new_value) |
sets the value to an integer More... | |
void | set_value (const Integer *new_value, uint32_t size) |
sets the value to an array of integers More... | |
void | set_value (std::vector< Integer > &&new_value) |
sets the value to an array of integers More... | |
void | set_value (const std::vector< Integer > &new_value) |
sets the value to an array of integers More... | |
void | set_value (std::shared_ptr< std::vector< Integer >> new_value) |
sets the value to an array of integers, without copying More... | |
void | set_value (const char *new_value, uint32_t size) |
sets the value to a string, from a buffer More... | |
void | set_value (std::string &&new_value) |
sets the value to a string More... | |
void | set_value (const std::string &new_value) |
sets the value to a string More... | |
void | set_value (std::shared_ptr< std::string > new_value) |
sets the value to a string. More... | |
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type = nullptr> | |
void | set_value (T new_value) |
sets the value to a floating point number More... | |
void | set_value (const double *new_value, uint32_t size) |
sets the value to an array of doubles More... | |
void | set_value (std::vector< double > &&new_value) |
sets the value to an array of doubles More... | |
void | set_value (const std::vector< double > &new_value) |
sets the value to an array of doubles More... | |
void | set_value (std::shared_ptr< std::vector< double >> new_value) |
sets the value to an array of doubles, without copying More... | |
void | set_xml (const char *new_value, size_t size) |
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 (const std::string &new_value) |
sets the value to an xml string More... | |
void | set_xml (std::shared_ptr< std::string > new_value) |
sets the value to an xml string. More... | |
std::shared_ptr< std::vector< unsigned char > > | share_binary () const |
std::shared_ptr< std::vector< double > > | share_doubles () const |
std::shared_ptr< std::vector< Integer > > | share_integers () const |
std::shared_ptr< 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... | |
std::shared_ptr< std::vector< unsigned char > > | take_binary () |
std::shared_ptr< std::vector< double > > | take_doubles () |
std::shared_ptr< std::vector< Integer > > | take_integers () |
std::shared_ptr< std::string > | take_string () |
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... | |
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... | |
int32_t | type (void) const |
returns the size 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, 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, 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, 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 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< 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 | |
void | clear_union (void) noexcept |
template<typename T , uint32_t Type, MemberType< T > Member, typename... Args> | |
std::shared_ptr< T > & | emplace_shared_val (Args &&...args) |
template<typename T , uint32_t Type, MemberType< std::vector< T >> Member, typename... Args> | |
std::shared_ptr< std::vector< T > > & | emplace_shared_vec (Args &&...args) |
template<typename T , uint32_t Type, MemberType< T > Member, typename... Args> | |
std::shared_ptr< T > & | emplace_val (Args &&...args) |
template<typename T , uint32_t Type, MemberType< std::vector< T >> Member, typename... Args> | |
std::shared_ptr< std::vector< T > > & | emplace_vec (Args &&...args) |
Private Attributes | |
union { | |
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... | |
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 59 of file KnowledgeRecord.h.
typedef int64_t madara::knowledge::KnowledgeRecord::Integer |
Definition at line 102 of file KnowledgeRecord.h.
|
private |
Definition at line 1447 of file KnowledgeRecord.h.
anonymous enum |
Enumerator | |
---|---|
UNCREATED | |
MODIFIED |
Definition at line 65 of file KnowledgeRecord.h.
anonymous enum |
Enumerator | |
---|---|
OWNED | |
SHARED |
Definition at line 71 of file KnowledgeRecord.h.
Definition at line 77 of file KnowledgeRecord.h.
|
inlinenoexcept |
Definition at line 153 of file KnowledgeRecord.h.
|
inlineexplicitnoexcept |
Definition at line 24 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 31 of file KnowledgeRecord.inl.
|
explicitnoexcept |
|
inlineexplicit |
Definition at line 37 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 44 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 51 of file KnowledgeRecord.inl.
|
inlineexplicit |
Definition at line 67 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 75 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 83 of file KnowledgeRecord.inl.
|
inlineexplicit |
Definition at line 91 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 98 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 105 of file KnowledgeRecord.inl.
|
inlineexplicit |
Definition at line 113 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 120 of file KnowledgeRecord.inl.
|
inline |
Definition at line 128 of file KnowledgeRecord.inl.
|
inlinenoexcept |
Definition at line 154 of file KnowledgeRecord.inl.
|
inlinenoexcept |
Definition at line 182 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 443 of file KnowledgeRecord.h.
|
inline |
Forwarding constructor for integer arrays shared_ptr Each argument past the first will be forwarded to construct a std::shared_ptr<std::vector<Integer>> in-place within the new record.
Definition at line 454 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 464 of file KnowledgeRecord.h.
|
inline |
Forwarding constructor for double arrays shared_ptr Each argument past the first will be forwarded to construct a std::shared_ptr<std::vector<double>> in-place within the new record.
Definition at line 475 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 488 of file KnowledgeRecord.h.
|
inline |
Forwarding constructor for double arrays shared_ptr Each argument past the first will be forwarded to construct a std::shared_ptr<std::string> in-place within the new record.
For example: KnowledgeRecord rec (tags::shared(tags::string), new std::string("Hello World"));
Definition at line 503 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 513 of file KnowledgeRecord.h.
|
inline |
Forwarding constructor for binary file (blob) shared_ptr Each argument past the first will be forwarded to construct a std::shared_ptr<std::vector<unsigned char>> in-place within the new record.
Definition at line 525 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 1097 of file KnowledgeRecord.cpp.
|
inlineprivatenoexcept |
Definition at line 865 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 882 of file KnowledgeRecord.inl.
|
inline |
clones the record.
Caller must ensure returned pointer is deleted.
Definition at line 605 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 1007 of file KnowledgeRecord.cpp.
|
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 615 of file KnowledgeRecord.inl.
|
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 622 of file KnowledgeRecord.inl.
|
inline |
Construct a shared_ptr to vector of integers within this KnowledgeRecord.
If the KnowledgeRecord would modify the resulting shared_ptr, a private copy will be made, and modified.
args | arguments forwarded to the shared_ptr constructor |
Definition at line 254 of file KnowledgeRecord.h.
|
inline |
Construct a vector of integers within this KnowledgeRecord.
args | arguments forwarded to the vector constructor |
Definition at line 276 of file KnowledgeRecord.h.
|
inline |
Construct a shared_ptr to vector of doubles within this KnowledgeRecord.
If the KnowledgeRecord would modify the resulting shared_ptr, a private copy will be made, and modified.
args | arguments forwarded to the shared_ptr constructor |
Definition at line 307 of file KnowledgeRecord.h.
|
inline |
Construct a vector of doubles within this KnowledgeRecord.
args | arguments forwarded to the vector constructor |
Definition at line 329 of file KnowledgeRecord.h.
|
inline |
Construct a shared_ptr to string within this KnowledgeRecord.
If the KnowledgeRecord would modify the resulting shared_ptr, a private copy will be made, and modified.
args | arguments forwarded to the shared_ptr constructor |
Definition at line 358 of file KnowledgeRecord.h.
|
inline |
Construct a string within this KnowledgeRecord.
args | arguments forwarded to the string constructor |
Definition at line 380 of file KnowledgeRecord.h.
|
inline |
Construct a shared_ptr to binary (vector of unsigned char) within this KnowledgeRecord.
If the KnowledgeRecord would modify the resulting shared_ptr, a private copy will be made, and modified.
args | arguments forwarded to the shared_ptr constructor |
Definition at line 411 of file KnowledgeRecord.h.
|
inline |
Construct a binary (vector of unsigned char) within this KnowledgeRecord.
args | arguments forwarded to the vector constructor |
Definition at line 433 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 317 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 421 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 264 of file KnowledgeRecord.h.
|
inline |
Construct a shared_ptr to vector of doubles within this KnowledgeRecord.
If the KnowledgeRecord would modify the resulting shared_ptr, a private copy will be made, and modified.
args | All arguments are forwarded to the shared_ptr constructor |
Definition at line 290 of file KnowledgeRecord.h.
|
inline |
Construct a shared_ptr to a file (vector of unsigned char) within this KnowledgeRecord.
If the KnowledgeRecord would modify the resulting shared_ptr, a private copy will be made, and modified.
args | All arguments are forwarded to the shared_ptr constructor |
Definition at line 394 of file KnowledgeRecord.h.
|
inline |
Construct a shared_ptr to vector of integers within this KnowledgeRecord.
If the KnowledgeRecord would modify the resulting shared_ptr, a private copy will be made, and modified.
args | All arguments are forwarded to the shared_ptr constructor |
Definition at line 237 of file KnowledgeRecord.h.
|
inline |
Construct a shared_ptr to a string within this KnowledgeRecord.
If the KnowledgeRecord would modify the resulting shared_ptr, a private copy will be made, and modified.
args | All arguments are forwarded to the shared_ptr constructor |
Definition at line 342 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1450 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1466 of file KnowledgeRecord.h.
|
inline |
Construct a string within this KnowledgeRecord.
args | All arguments are forwarded to the string constructor |
Definition at line 368 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1458 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 1473 of file KnowledgeRecord.h.
|
inline |
Checks if record exists (i.e., is not uncreated)
Definition at line 630 of file KnowledgeRecord.inl.
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 462 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 721 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 689 of file KnowledgeRecord.inl.
|
static |
Gets the current double precision for double to string conversion.
Definition at line 24 of file KnowledgeRecord.cpp.
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 1033 of file KnowledgeRecord.cpp.
|
inline |
returns if the record is an array type (DOUBLE_ARRAY, INTEGER_ARRAY)
Definition at line 783 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record is a array type (DOUBLE_ARRAY, INTEGER_ARRAY)
type | the type to check |
Definition at line 789 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has a binary file type
Definition at line 820 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 826 of file KnowledgeRecord.inl.
|
inline |
returns if the record is a double type (DOUBLE, DOUBLE_ARRAY)
Definition at line 758 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record is a double type (DOUBLE, DOUBLE_ARRAY)
type | the type to check |
Definition at line 764 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 547 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has a file type
Definition at line 807 of file KnowledgeRecord.inl.
|
inlinestatic |
returns true if the knowledge record has a file type
type | the type of the record |
Definition at line 813 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has an image type
Definition at line 795 of file KnowledgeRecord.inl.
|
inlinestatic |
returns true if the knowledge record has an image type
type | the type of the record |
Definition at line 801 of file KnowledgeRecord.inl.
|
inline |
returns if the record is a integer type (INTEGER, INTEGER_ARRAY)
Definition at line 770 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record is a integer type (INTEGER, INTEGER_ARRAY)
type | the type to check |
Definition at line 777 of file KnowledgeRecord.inl.
|
inline |
returns if the record has a reference-counted type
Definition at line 734 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record has a reference-counted type
type | the type to check |
Definition at line 740 of file KnowledgeRecord.inl.
|
inline |
returns true if the record is a string type (STRING, XML, TEXT_FILE)
Definition at line 746 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 752 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 1166 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 1426 of file KnowledgeRecord.h.
|
inlineexplicit |
Explicit bool cast.
Definition at line 1507 of file KnowledgeRecord.inl.
|
inline |
Logical not.
Definition at line 322 of file KnowledgeRecord.inl.
|
inline |
Unequal to.
Definition at line 313 of file KnowledgeRecord.inl.
|
inline |
Modulus operator.
Definition at line 526 of file KnowledgeRecord.inl.
|
inline |
In-place modulus operator.
Definition at line 481 of file KnowledgeRecord.inl.
|
inline |
Times operator.
Definition at line 502 of file KnowledgeRecord.inl.
|
inline |
In-place multiplication operator.
Definition at line 423 of file KnowledgeRecord.inl.
|
inline |
Plus operator.
Definition at line 538 of file KnowledgeRecord.inl.
|
inline |
|
inline |
In-place addition operator.
Definition at line 351 of file KnowledgeRecord.inl.
|
inline |
Negate.
Definition at line 331 of file KnowledgeRecord.inl.
|
inline |
Minus operator.
Definition at line 574 of file KnowledgeRecord.inl.
|
inline |
|
inline |
In-place subtraction operator.
Definition at line 404 of file KnowledgeRecord.inl.
|
inline |
Divides operator.
Definition at line 514 of file KnowledgeRecord.inl.
|
inline |
In-place division operator.
Definition at line 442 of file KnowledgeRecord.inl.
bool madara::knowledge::KnowledgeRecord::operator< | ( | const KnowledgeRecord & | rhs | ) | const |
Less than.
Definition at line 536 of file KnowledgeRecord.cpp.
bool madara::knowledge::KnowledgeRecord::operator<= | ( | const KnowledgeRecord & | rhs | ) | const |
Less than or equal to.
Definition at line 622 of file KnowledgeRecord.cpp.
|
inline |
Definition at line 824 of file KnowledgeRecord.h.
|
inline |
Assignment.
Definition at line 188 of file KnowledgeRecord.inl.
|
inlinenoexcept |
Move Assignment.
Definition at line 223 of file KnowledgeRecord.inl.
bool madara::knowledge::KnowledgeRecord::operator== | ( | const KnowledgeRecord & | rhs | ) | const |
Equal to.
Definition at line 708 of file KnowledgeRecord.cpp.
bool madara::knowledge::KnowledgeRecord::operator> | ( | const KnowledgeRecord & | rhs | ) | const |
Greater than.
Definition at line 813 of file KnowledgeRecord.cpp.
bool madara::knowledge::KnowledgeRecord::operator>= | ( | const KnowledgeRecord & | rhs | ) | const |
Greater than or equal to.
Definition at line 900 of file KnowledgeRecord.cpp.
|
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 890 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 1005 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 1042 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.
|
inlinenoexcept |
resets the variable to an integer
Definition at line 1064 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 1059 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 988 of file KnowledgeRecord.cpp.
|
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 1226 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 1234 of file KnowledgeRecord.inl.
|
inline |
sets the value to an unknown file type
new_value | new value of the Knowledge Record |
Definition at line 1241 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 1248 of file KnowledgeRecord.inl.
|
static |
Sets the output format for doubles to std::fixed.
Definition at line 40 of file KnowledgeRecord.cpp.
|
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 1345 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 |
size | size of the new_value buffer |
Definition at line 1195 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg, without copying
new_value | new value of the Knowledge Record |
Definition at line 1203 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg
new_value | new value of the Knowledge Record |
Definition at line 1210 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg, without copying
new_value | new value of the Knowledge Record |
Definition at line 1217 of file KnowledgeRecord.inl.
|
inline |
sets the status to modified
Definition at line 645 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 30 of file KnowledgeRecord.cpp.
|
static |
Sets the output format for doubles to std::scientific.
Definition at line 50 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 1163 of file KnowledgeRecord.inl.
|
inline |
sets the value to a plaintext string
new_value | new value of the Knowledge Record |
Definition at line 1171 of file KnowledgeRecord.inl.
|
inline |
sets the value to a plaintext string
new_value | new value of the Knowledge Record |
Definition at line 1179 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 1187 of file KnowledgeRecord.inl.
|
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 676 of file KnowledgeRecord.inl.
|
inline |
Sets the value from another KnowledgeRecord, does not copy clock and write_quality.
Will check that write_quality of new value is >= quality of this record, and ignore update if not. Otherwise, this records quality will be set to new_value.write_quality.
new_value | new value of the Knowledge Record |
Definition at line 1074 of file KnowledgeRecord.inl.
|
inline |
Sets the value from another KnowledgeRecord, does not copy clock and write_quality.
Will check that write_quality of new value is >= quality of this record, and ignore update if not. Otherwise, this records quality will be set to new_value.write_quality.
new_value | new value of the Knowledge Record |
Definition at line 1086 of file KnowledgeRecord.inl.
|
inline |
sets the value to an integer
new_value | new value of the Knowledge Record |
Definition at line 1259 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 1270 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of integers
new_value | new value of the Knowledge Record |
Definition at line 1277 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of integers
new_value | new value of the Knowledge Record |
Definition at line 1284 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 1291 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 1123 of file KnowledgeRecord.inl.
|
inline |
sets the value to a string
new_value | new value of the Knowledge Record |
Definition at line 1099 of file KnowledgeRecord.inl.
|
inline |
sets the value to a string
new_value | new value of the Knowledge Record |
Definition at line 1107 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 1115 of file KnowledgeRecord.inl.
void madara::knowledge::KnowledgeRecord::set_value | ( | T | new_value | ) |
sets the value to a floating point number
new_value | new value of the Knowledge Record |
|
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 1311 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of doubles
new_value | new value of the Knowledge Record |
Definition at line 1318 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of doubles
new_value | new value of the Knowledge Record |
Definition at line 1325 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 1332 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 1131 of file KnowledgeRecord.inl.
|
inline |
sets the value to an xml string
new_value | new value of the Knowledge Record |
Definition at line 1139 of file KnowledgeRecord.inl.
|
inline |
sets the value to an xml string
new_value | new value of the Knowledge Record |
Definition at line 1147 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 1155 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1481 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1455 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1429 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1403 of file KnowledgeRecord.inl.
|
inline |
returns the size of the value
Definition at line 653 of file KnowledgeRecord.inl.
|
inline |
returns the status of the record.
Definition at line 636 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1491 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1465 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1439 of file KnowledgeRecord.inl.
|
inline |
Definition at line 1413 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 143 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 247 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 120 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 170 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 197 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 296 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 413 of file KnowledgeRecord.cpp.
|
inline |
returns the size of the value
Definition at line 670 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 583 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 1513 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 1664 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 1719 of file KnowledgeRecord.inl.
|
friend |
Definition at line 63 of file KnowledgeRecord.h.
union { ... } |
Non-array versions of double/integer.
About 10x faster than using the ref-counted arrays
uint64_t madara::knowledge::KnowledgeRecord::clock = 0 |
last modification time
Definition at line 112 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<double> > madara::knowledge::KnowledgeRecord::double_array_ |
Definition at line 135 of file KnowledgeRecord.h.
double madara::knowledge::KnowledgeRecord::double_value_ |
Definition at line 132 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<unsigned char> > madara::knowledge::KnowledgeRecord::file_value_ |
Definition at line 137 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<Integer> > madara::knowledge::KnowledgeRecord::int_array_ |
Definition at line 134 of file KnowledgeRecord.h.
Integer madara::knowledge::KnowledgeRecord::int_value_ = 0 |
Definition at line 131 of file KnowledgeRecord.h.
|
private |
the logger used for any internal debugging information
Definition at line 106 of file KnowledgeRecord.h.
uint32_t madara::knowledge::KnowledgeRecord::quality = 0 |
priority of the update
Definition at line 117 of file KnowledgeRecord.h.
|
mutableprivate |
is this knowledge record's shared_ptr, if any, exposed to outside holders?
Definition at line 149 of file KnowledgeRecord.h.
std::shared_ptr<std::string> madara::knowledge::KnowledgeRecord::str_value_ |
Definition at line 136 of file KnowledgeRecord.h.
|
private |
type of variable (INTEGER, DOUBLE, STRING, FILE, IMAGE)
Definition at line 143 of file KnowledgeRecord.h.
uint32_t madara::knowledge::KnowledgeRecord::write_quality = 0 |
write priority for any local updates
Definition at line 122 of file KnowledgeRecord.h.