MADARA
3.1.8
|
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... | |
KnowledgeRecord & | operator= (const KnowledgeRecord &rhs) |
Assignment. More... | |
KnowledgeRecord & | operator= (KnowledgeRecord &&rhs) noexcept |
Move Assignment. More... | |
bool | operator== (const KnowledgeRecord &rhs) const |
Equal to. More... | |
template<typename T , typename std::enable_if< std::is_integral< T >::value, void * >::type = nullptr> | |
bool | operator== (T value) const |
Equal to. More... | |
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type = nullptr> | |
bool | operator== (T value) const |
Equal to. More... | |
bool | operator== (const std::string &value) const |
Equal to. More... | |
bool | operator== (const char *value) 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 a double 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 |
Returns a shared_ptr, sharing with the internal one. More... | |
std::shared_ptr< std::vector< double > > | share_doubles () const |
Returns a shared_ptr, sharing with the internal one. More... | |
std::shared_ptr< std::vector< Integer > > | share_integers () const |
Returns a shared_ptr, sharing with the internal one. More... | |
std::shared_ptr< std::string > | share_string () const |
Returns a shared_ptr, sharing with the internal one. More... | |
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 () |
Returns a shared_ptr, while resetting this record to empty. More... | |
std::shared_ptr< std::vector< double > > | take_doubles () |
Returns a shared_ptr, while resetting this record to empty. More... | |
std::shared_ptr< std::vector< Integer > > | take_integers () |
Returns a shared_ptr, while resetting this record to empty. More... | |
std::shared_ptr< std::string > | take_string () |
Returns a shared_ptr, while resetting this record to empty. 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... | |
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 60 of file KnowledgeRecord.h.
typedef int64_t madara::knowledge::KnowledgeRecord::Integer |
Definition at line 103 of file KnowledgeRecord.h.
|
private |
Definition at line 229 of file KnowledgeRecord.h.
anonymous enum |
Enumerator | |
---|---|
UNCREATED | |
MODIFIED |
Definition at line 66 of file KnowledgeRecord.h.
anonymous enum |
Enumerator | |
---|---|
OWNED | |
SHARED |
Definition at line 72 of file KnowledgeRecord.h.
Definition at line 78 of file KnowledgeRecord.h.
|
inlinenoexcept |
Definition at line 154 of file KnowledgeRecord.h.
|
inlineexplicitnoexcept |
Definition at line 21 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 28 of file KnowledgeRecord.inl.
|
explicitnoexcept |
|
inlineexplicit |
Definition at line 34 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 41 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 48 of file KnowledgeRecord.inl.
|
inlineexplicit |
Definition at line 64 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 72 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 80 of file KnowledgeRecord.inl.
|
inlineexplicit |
Definition at line 88 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 95 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 102 of file KnowledgeRecord.inl.
|
inlineexplicit |
Definition at line 110 of file KnowledgeRecord.inl.
|
inlineexplicitnoexcept |
Definition at line 117 of file KnowledgeRecord.inl.
|
inline |
Definition at line 125 of file KnowledgeRecord.inl.
|
inlinenoexcept |
Definition at line 151 of file KnowledgeRecord.inl.
|
inlinenoexcept |
Definition at line 177 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 477 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 488 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 498 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 509 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 522 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 537 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 547 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 559 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 1096 of file KnowledgeRecord.cpp.
|
inlineprivatenoexcept |
Definition at line 852 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 869 of file KnowledgeRecord.inl.
|
inline |
clones the record.
Caller must ensure returned pointer is deleted.
Definition at line 592 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 1006 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 602 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 609 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 288 of file KnowledgeRecord.h.
|
inline |
Construct a vector of integers within this KnowledgeRecord.
args | arguments forwarded to the vector constructor |
Definition at line 310 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 341 of file KnowledgeRecord.h.
|
inline |
Construct a vector of doubles within this KnowledgeRecord.
args | arguments forwarded to the vector constructor |
Definition at line 363 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 392 of file KnowledgeRecord.h.
|
inline |
Construct a string within this KnowledgeRecord.
args | arguments forwarded to the string constructor |
Definition at line 414 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 445 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 467 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 351 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 455 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 298 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 324 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 428 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 271 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 376 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 232 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 248 of file KnowledgeRecord.h.
|
inline |
Construct a string within this KnowledgeRecord.
args | All arguments are forwarded to the string constructor |
Definition at line 402 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 240 of file KnowledgeRecord.h.
|
inlineprivate |
Definition at line 255 of file KnowledgeRecord.h.
|
inline |
Checks if record exists (i.e., is not uncreated)
Definition at line 617 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 464 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 708 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 676 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 1032 of file KnowledgeRecord.cpp.
|
inline |
returns if the record is an array type (DOUBLE_ARRAY, INTEGER_ARRAY)
Definition at line 770 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 776 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has a binary file type
Definition at line 807 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 813 of file KnowledgeRecord.inl.
|
inline |
returns if the record is a double type (DOUBLE, DOUBLE_ARRAY)
Definition at line 745 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record is a double type (DOUBLE, DOUBLE_ARRAY)
type | the type to check |
Definition at line 751 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 534 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has a file type
Definition at line 794 of file KnowledgeRecord.inl.
|
inlinestatic |
returns true if the knowledge record has a file type
type | the type of the record |
Definition at line 800 of file KnowledgeRecord.inl.
|
inline |
returns true if the knowledge record has an image type
Definition at line 782 of file KnowledgeRecord.inl.
|
inlinestatic |
returns true if the knowledge record has an image type
type | the type of the record |
Definition at line 788 of file KnowledgeRecord.inl.
|
inline |
returns if the record is a integer type (INTEGER, INTEGER_ARRAY)
Definition at line 757 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record is a integer type (INTEGER, INTEGER_ARRAY)
type | the type to check |
Definition at line 764 of file KnowledgeRecord.inl.
|
inline |
returns if the record has a reference-counted type
Definition at line 721 of file KnowledgeRecord.inl.
|
inlinestatic |
returns if the record has a reference-counted type
type | the type to check |
Definition at line 727 of file KnowledgeRecord.inl.
|
inline |
returns true if the record is a string type (STRING, XML, TEXT_FILE)
Definition at line 733 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 739 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 1165 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 1437 of file KnowledgeRecord.h.
|
inlineexplicit |
Explicit bool cast.
Definition at line 1494 of file KnowledgeRecord.inl.
|
inline |
Logical not.
Definition at line 313 of file KnowledgeRecord.inl.
|
inline |
Unequal to.
Definition at line 304 of file KnowledgeRecord.inl.
|
inline |
Modulus operator.
Definition at line 513 of file KnowledgeRecord.inl.
|
inline |
In-place modulus operator.
Definition at line 468 of file KnowledgeRecord.inl.
|
inline |
Times operator.
Definition at line 489 of file KnowledgeRecord.inl.
|
inline |
In-place multiplication operator.
Definition at line 410 of file KnowledgeRecord.inl.
|
inline |
Plus operator.
Definition at line 525 of file KnowledgeRecord.inl.
|
inline |
|
inline |
In-place addition operator.
Definition at line 338 of file KnowledgeRecord.inl.
|
inline |
Negate.
Definition at line 322 of file KnowledgeRecord.inl.
|
inline |
Minus operator.
Definition at line 561 of file KnowledgeRecord.inl.
|
inline |
|
inline |
In-place subtraction operator.
Definition at line 391 of file KnowledgeRecord.inl.
|
inline |
Divides operator.
Definition at line 501 of file KnowledgeRecord.inl.
|
inline |
In-place division operator.
Definition at line 429 of file KnowledgeRecord.inl.
bool madara::knowledge::KnowledgeRecord::operator< | ( | const KnowledgeRecord & | rhs | ) | const |
Less than.
Definition at line 538 of file KnowledgeRecord.cpp.
bool madara::knowledge::KnowledgeRecord::operator<= | ( | const KnowledgeRecord & | rhs | ) | const |
Less than or equal to.
Definition at line 624 of file KnowledgeRecord.cpp.
|
inline |
Assignment.
Definition at line 183 of file KnowledgeRecord.inl.
|
inlinenoexcept |
Move Assignment.
Definition at line 218 of file KnowledgeRecord.inl.
bool madara::knowledge::KnowledgeRecord::operator== | ( | const KnowledgeRecord & | rhs | ) | const |
Equal to.
Definition at line 710 of file KnowledgeRecord.cpp.
|
inline |
Equal to.
Definition at line 255 of file KnowledgeRecord.inl.
bool madara::knowledge::KnowledgeRecord::operator== | ( | T | value | ) | const |
Equal to.
|
inline |
Equal to.
Definition at line 291 of file KnowledgeRecord.inl.
|
inline |
Equal to.
Definition at line 298 of file KnowledgeRecord.inl.
bool madara::knowledge::KnowledgeRecord::operator> | ( | const KnowledgeRecord & | rhs | ) | const |
Greater than.
Definition at line 812 of file KnowledgeRecord.cpp.
bool madara::knowledge::KnowledgeRecord::operator>= | ( | const KnowledgeRecord & | rhs | ) | const |
Greater than or equal to.
Definition at line 899 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 877 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 992 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 1029 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 1051 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 1058 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 987 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 1213 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 1221 of file KnowledgeRecord.inl.
|
inline |
sets the value to an unknown file type
new_value | new value of the Knowledge Record |
Definition at line 1228 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 1235 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 1332 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 1182 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg, without copying
new_value | new value of the Knowledge Record |
Definition at line 1190 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg
new_value | new value of the Knowledge Record |
Definition at line 1197 of file KnowledgeRecord.inl.
|
inline |
sets the value to a jpeg, without copying
new_value | new value of the Knowledge Record |
Definition at line 1204 of file KnowledgeRecord.inl.
|
inline |
sets the status to modified
Definition at line 632 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 1150 of file KnowledgeRecord.inl.
|
inline |
sets the value to a plaintext string
new_value | new value of the Knowledge Record |
Definition at line 1158 of file KnowledgeRecord.inl.
|
inline |
sets the value to a plaintext string
new_value | new value of the Knowledge Record |
Definition at line 1166 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 1174 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 663 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 |
size | num elements in the array |
Definition at line 1061 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 |
size | num elements in the array |
Definition at line 1073 of file KnowledgeRecord.inl.
|
inline |
sets the value to a double
new_value | new value of the Knowledge Record |
Definition at line 1246 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 1257 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of integers
new_value | new value of the Knowledge Record |
Definition at line 1264 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of integers
new_value | new value of the Knowledge Record |
Definition at line 1271 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 1278 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 1110 of file KnowledgeRecord.inl.
|
inline |
sets the value to a string
new_value | new value of the Knowledge Record |
Definition at line 1086 of file KnowledgeRecord.inl.
|
inline |
sets the value to a string
new_value | new value of the Knowledge Record |
Definition at line 1094 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 1102 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 1298 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of doubles
new_value | new value of the Knowledge Record |
Definition at line 1305 of file KnowledgeRecord.inl.
|
inline |
sets the value to an array of doubles
new_value | new value of the Knowledge Record |
Definition at line 1312 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 1319 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 1118 of file KnowledgeRecord.inl.
|
inline |
sets the value to an xml string
new_value | new value of the Knowledge Record |
Definition at line 1126 of file KnowledgeRecord.inl.
|
inline |
sets the value to an xml string
new_value | new value of the Knowledge Record |
Definition at line 1134 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 1142 of file KnowledgeRecord.inl.
|
inline |
Returns a shared_ptr, sharing with the internal one.
If this record is not a binary file value, returns NULL shared_ptr
Definition at line 1468 of file KnowledgeRecord.inl.
|
inline |
Returns a shared_ptr, sharing with the internal one.
If this record is not a doubles array, returns NULL shared_ptr
Definition at line 1442 of file KnowledgeRecord.inl.
|
inline |
Returns a shared_ptr, sharing with the internal one.
If this record is not an int array, returns NULL shared_ptr
Definition at line 1416 of file KnowledgeRecord.inl.
|
inline |
Returns a shared_ptr, sharing with the internal one.
If this record is not a string, returns NULL shared_ptr
Definition at line 1390 of file KnowledgeRecord.inl.
|
inline |
returns the size of the value
Definition at line 640 of file KnowledgeRecord.inl.
|
inline |
returns the status of the record.
Definition at line 623 of file KnowledgeRecord.inl.
|
inline |
Returns a shared_ptr, while resetting this record to empty.
If this record is not a binary file value, returns NULL shared_ptr
Definition at line 1478 of file KnowledgeRecord.inl.
|
inline |
Returns a shared_ptr, while resetting this record to empty.
If this record is not doubles array, returns NULL shared_ptr
Definition at line 1452 of file KnowledgeRecord.inl.
|
inline |
Returns a shared_ptr, while resetting this record to empty.
If this record is not an int array, returns NULL shared_ptr
Definition at line 1426 of file KnowledgeRecord.inl.
|
inline |
Returns a shared_ptr, while resetting this record to empty.
If this record is not a string, returns NULL shared_ptr
Definition at line 1400 of file KnowledgeRecord.inl.
double madara::knowledge::KnowledgeRecord::to_double | ( | void | ) | const |
converts the value to a float/double
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 248 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
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 298 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 415 of file KnowledgeRecord.cpp.
|
inline |
returns the size of the value
Definition at line 657 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 570 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 1500 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 1645 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 1694 of file KnowledgeRecord.inl.
|
friend |
Definition at line 64 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 113 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<double> > madara::knowledge::KnowledgeRecord::double_array_ |
Definition at line 136 of file KnowledgeRecord.h.
double madara::knowledge::KnowledgeRecord::double_value_ |
Definition at line 133 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<unsigned char> > madara::knowledge::KnowledgeRecord::file_value_ |
Definition at line 138 of file KnowledgeRecord.h.
std::shared_ptr<std::vector<Integer> > madara::knowledge::KnowledgeRecord::int_array_ |
Definition at line 135 of file KnowledgeRecord.h.
Integer madara::knowledge::KnowledgeRecord::int_value_ = 0 |
Definition at line 132 of file KnowledgeRecord.h.
|
private |
the logger used for any internal debugging information
Definition at line 107 of file KnowledgeRecord.h.
uint32_t madara::knowledge::KnowledgeRecord::quality = 0 |
priority of the update
Definition at line 118 of file KnowledgeRecord.h.
|
mutableprivate |
is this knowledge record's shared_ptr, if any, exposed to outside holders?
Definition at line 150 of file KnowledgeRecord.h.
std::shared_ptr<std::string> madara::knowledge::KnowledgeRecord::str_value_ |
Definition at line 137 of file KnowledgeRecord.h.
|
private |
type of variable (INTEGER, DOUBLE, STRING, FILE, IMAGE)
Definition at line 144 of file KnowledgeRecord.h.
uint32_t madara::knowledge::KnowledgeRecord::write_quality = 0 |
write priority for any local updates
Definition at line 123 of file KnowledgeRecord.h.