MADARA  3.2.3
madara::knowledge::KnowledgeRecord Class Reference

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...
 
KnowledgeRecordclone (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...
 
KnowledgeRecordoperator%= (const KnowledgeRecord &rhs)
 In-place modulus operator. More...
 
KnowledgeRecord operator* (const KnowledgeRecord &rhs) const
 Times operator. More...
 
KnowledgeRecordoperator*= (const KnowledgeRecord &rhs)
 In-place multiplication operator. More...
 
KnowledgeRecord operator+ (const KnowledgeRecord &rhs) const
 Plus operator. More...
 
KnowledgeRecordoperator++ (void)
 Preincrement operator. More...
 
KnowledgeRecordoperator+= (const KnowledgeRecord &rhs)
 In-place addition operator. More...
 
KnowledgeRecord operator- (void) const
 Negate. More...
 
KnowledgeRecord operator- (const KnowledgeRecord &rhs) const
 Minus operator. More...
 
KnowledgeRecordoperator-- (void)
 Predecrement operator. More...
 
KnowledgeRecordoperator-= (const KnowledgeRecord &rhs)
 In-place subtraction operator. More...
 
KnowledgeRecord operator/ (const KnowledgeRecord &rhs) const
 Divides operator. More...
 
KnowledgeRecordoperator/= (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
 
KnowledgeRecordoperator= (const KnowledgeRecord &rhs)
 Assignment. More...
 
KnowledgeRecordoperator= (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< Integerto_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::Loggerlogger_ = 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
 

Detailed Description

This class encapsulates an entry in a KnowledgeBase.

Definition at line 59 of file KnowledgeRecord.h.

Member Typedef Documentation

Definition at line 102 of file KnowledgeRecord.h.

template<typename T >
using madara::knowledge::KnowledgeRecord::MemberType = std::shared_ptr<T> KnowledgeRecord::*
private

Definition at line 1447 of file KnowledgeRecord.h.

Member Enumeration Documentation

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.

Enumerator
EMPTY 
INTEGER 
STRING 
DOUBLE 
FLOAT 
UNKNOWN_FILE_TYPE 
XML 
TEXT_FILE 
INTEGER_ARRAY 
DOUBLE_ARRAY 
IMAGE_JPEG 
ALL_ARRAYS 
ALL_INTEGERS 
ALL_DOUBLES 
ALL_PRIMITIVE_TYPES 
ALL_FILE_TYPES 
ALL_IMAGES 
ALL_TEXT_FORMATS 
ALL_TYPES 
ALL_CLEARABLES 

Definition at line 77 of file KnowledgeRecord.h.

Constructor & Destructor Documentation

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( )
inlinenoexcept

Definition at line 153 of file KnowledgeRecord.h.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( logger::Logger logger)
inlineexplicitnoexcept

Definition at line 24 of file KnowledgeRecord.inl.

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type >
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicitnoexcept

Definition at line 31 of file KnowledgeRecord.inl.

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type = nullptr>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( value,
logger::Logger logger = *logger::global_logger.get() 
)
explicitnoexcept
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( const std::vector< Integer > &  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicit

Definition at line 37 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( std::vector< Integer > &&  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicitnoexcept

Definition at line 44 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( std::shared_ptr< std::vector< Integer >>  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicitnoexcept

Definition at line 51 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( const std::vector< double > &  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicit

Definition at line 67 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( std::vector< double > &&  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicitnoexcept

Definition at line 75 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( std::shared_ptr< std::vector< double >>  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicitnoexcept

Definition at line 83 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( const std::string &  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicit

Definition at line 91 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( std::string &&  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicitnoexcept

Definition at line 98 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( std::shared_ptr< std::string >  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicitnoexcept

Definition at line 105 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( const char *  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicit

Definition at line 113 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( std::shared_ptr< std::vector< unsigned char >>  value,
logger::Logger logger = *logger::global_logger.get () 
)
inlineexplicitnoexcept

Definition at line 120 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( const KnowledgeRecord rhs)
inline

Definition at line 128 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::KnowledgeRecord ( knowledge::KnowledgeRecord &&  rhs)
inlinenoexcept

Definition at line 154 of file KnowledgeRecord.inl.

madara::knowledge::KnowledgeRecord::~KnowledgeRecord ( )
inlinenoexcept

Definition at line 182 of file KnowledgeRecord.inl.

template<typename... Args>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( tags::integers_t  ,
Args &&...  args 
)
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.

template<typename... Args>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( tags::shared_t< tags::integers_t ,
Args &&...  args 
)
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.

template<typename... Args>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( tags::doubles_t  ,
Args &&...  args 
)
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.

template<typename... Args>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( tags::shared_t< tags::doubles_t ,
Args &&...  args 
)
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.

template<typename... Args>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( tags::string_t  ,
Args &&...  args 
)
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.

template<typename... Args>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( tags::shared_t< tags::string_t ,
Args &&...  args 
)
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.

template<typename... Args>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( tags::binary_t  ,
Args &&...  args 
)
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.

template<typename... Args>
madara::knowledge::KnowledgeRecord::KnowledgeRecord ( tags::shared_t< tags::binary_t ,
Args &&...  args 
)
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.

Member Function Documentation

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.

void madara::knowledge::KnowledgeRecord::clear_union ( void  )
inlineprivatenoexcept

Definition at line 865 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::clear_value ( void  )
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.

KnowledgeRecord * madara::knowledge::KnowledgeRecord::clone ( void  ) const
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.

Parameters
indexindex of the value to set

Definition at line 1007 of file KnowledgeRecord.cpp.

void madara::knowledge::KnowledgeRecord::deep_copy ( const KnowledgeRecord source)
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.

Parameters
sourcethe Knowledge Record we wish to copy

Definition at line 615 of file KnowledgeRecord.inl.

KnowledgeRecord madara::knowledge::KnowledgeRecord::deep_copy ( ) const
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.

Returns
a deep copy of this knowledge record

Definition at line 622 of file KnowledgeRecord.inl.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace ( tags::shared_t< tags::integers_t ,
Args &&...  args 
)
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.

Parameters
argsarguments forwarded to the shared_ptr constructor

Definition at line 254 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace ( tags::integers_t  ,
Args &&...  args 
)
inline

Construct a vector of integers within this KnowledgeRecord.

Parameters
argsarguments forwarded to the vector constructor

Definition at line 276 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace ( tags::shared_t< tags::doubles_t ,
Args &&...  args 
)
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.

Parameters
argsarguments forwarded to the shared_ptr constructor

Definition at line 307 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace ( tags::doubles_t  ,
Args &&...  args 
)
inline

Construct a vector of doubles within this KnowledgeRecord.

Parameters
argsarguments forwarded to the vector constructor

Definition at line 329 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace ( tags::shared_t< tags::string_t ,
Args &&...  args 
)
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.

Parameters
argsarguments forwarded to the shared_ptr constructor

Definition at line 358 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace ( tags::string_t  ,
Args &&...  args 
)
inline

Construct a string within this KnowledgeRecord.

Parameters
argsarguments forwarded to the string constructor

Definition at line 380 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace ( tags::shared_t< tags::binary_t ,
Args &&...  args 
)
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.

Parameters
argsarguments forwarded to the shared_ptr constructor

Definition at line 411 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace ( tags::binary_t  ,
Args &&...  args 
)
inline

Construct a binary (vector of unsigned char) within this KnowledgeRecord.

Parameters
argsarguments forwarded to the vector constructor

Definition at line 433 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace_doubles ( Args &&...  args)
inline

Construct a vector of doubles within this KnowledgeRecord.

Parameters
argsAll arguments are forwarded to the vector constructor

Definition at line 317 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace_file ( Args &&...  args)
inline

Construct a file (vector of unsigned char) within this KnowledgeRecord.

Parameters
argsAll arguments are forwarded to the vector constructor

Definition at line 421 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace_integers ( Args &&...  args)
inline

Construct a vector of integers within this KnowledgeRecord.

Parameters
argsAll arguments are forwarded to the vector constructor

Definition at line 264 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace_shared_doubles ( Args &&...  args)
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.

Parameters
argsAll arguments are forwarded to the shared_ptr constructor

Definition at line 290 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace_shared_file ( Args &&...  args)
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.

Parameters
argsAll arguments are forwarded to the shared_ptr constructor

Definition at line 394 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace_shared_integers ( Args &&...  args)
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.

Parameters
argsAll arguments are forwarded to the shared_ptr constructor

Definition at line 237 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace_shared_string ( Args &&...  args)
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.

Parameters
argsAll arguments are forwarded to the shared_ptr constructor

Definition at line 342 of file KnowledgeRecord.h.

template<typename T , uint32_t Type, MemberType< T > Member, typename... Args>
std::shared_ptr<T>& madara::knowledge::KnowledgeRecord::emplace_shared_val ( Args &&...  args)
inlineprivate

Definition at line 1450 of file KnowledgeRecord.h.

template<typename T , uint32_t Type, MemberType< std::vector< T >> Member, typename... Args>
std::shared_ptr<std::vector<T> >& madara::knowledge::KnowledgeRecord::emplace_shared_vec ( Args &&...  args)
inlineprivate

Definition at line 1466 of file KnowledgeRecord.h.

template<typename... Args>
void madara::knowledge::KnowledgeRecord::emplace_string ( Args &&...  args)
inline

Construct a string within this KnowledgeRecord.

Parameters
argsAll arguments are forwarded to the string constructor

Definition at line 368 of file KnowledgeRecord.h.

template<typename T , uint32_t Type, MemberType< T > Member, typename... Args>
std::shared_ptr<T>& madara::knowledge::KnowledgeRecord::emplace_val ( Args &&...  args)
inlineprivate

Definition at line 1458 of file KnowledgeRecord.h.

template<typename T , uint32_t Type, MemberType< std::vector< T >> Member, typename... Args>
std::shared_ptr<std::vector<T> >& madara::knowledge::KnowledgeRecord::emplace_vec ( Args &&...  args)
inlineprivate

Definition at line 1473 of file KnowledgeRecord.h.

bool madara::knowledge::KnowledgeRecord::exists ( void  ) const
inline

Checks if record exists (i.e., is not uncreated)

Returns
true if record exists, false otherwise

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.

Parameters
firstfirst index (inclusive, >= 0)
lastlast index (inclusive, < size)

Definition at line 462 of file KnowledgeRecord.cpp.

int64_t madara::knowledge::KnowledgeRecord::get_encoded_size ( const std::string &  key) const
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.

int64_t madara::knowledge::KnowledgeRecord::get_encoded_size ( void  ) const
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.

int madara::knowledge::KnowledgeRecord::get_precision ( void  )
static

Gets the current double precision for double to string conversion.

Returns
the 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.

Parameters
indexindex of the value to set

Definition at line 1033 of file KnowledgeRecord.cpp.

bool madara::knowledge::KnowledgeRecord::is_array_type ( void  ) const
inline

returns if the record is an array type (DOUBLE_ARRAY, INTEGER_ARRAY)

Returns
true if the record is an integer

Definition at line 783 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_array_type ( uint32_t  type)
inlinestatic

returns if the record is a array type (DOUBLE_ARRAY, INTEGER_ARRAY)

Parameters
typethe type to check
Returns
true if the record is an integer

Definition at line 789 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_binary_file_type ( void  ) const
inline

returns true if the knowledge record has a binary file type

Returns
true if type is a file type

Definition at line 820 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_binary_file_type ( uint32_t  type)
inlinestatic

returns true if the knowledge record has a binary file type

Parameters
typethe type of the record
Returns
true if type is a file type

Definition at line 826 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_double_type ( void  ) const
inline

returns if the record is a double type (DOUBLE, DOUBLE_ARRAY)

Returns
true if the record is a double

Definition at line 758 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_double_type ( uint32_t  type)
inlinestatic

returns if the record is a double type (DOUBLE, DOUBLE_ARRAY)

Parameters
typethe type to check
Returns
true if the record is a double

Definition at line 764 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_false ( void  ) const
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 "".

Returns
true if the record is zero or "". False otherwise.

Definition at line 547 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_file_type ( void  ) const
inline

returns true if the knowledge record has a file type

Returns
true if type is a file type

Definition at line 807 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_file_type ( uint32_t  type)
inlinestatic

returns true if the knowledge record has a file type

Parameters
typethe type of the record
Returns
true if type is a file type

Definition at line 813 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_image_type ( void  ) const
inline

returns true if the knowledge record has an image type

Returns
true if type is an image type

Definition at line 795 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_image_type ( uint32_t  type)
inlinestatic

returns true if the knowledge record has an image type

Parameters
typethe type of the record
Returns
true if type is an image type

Definition at line 801 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_integer_type ( void  ) const
inline

returns if the record is a integer type (INTEGER, INTEGER_ARRAY)

Returns
true if the record is an integer

Definition at line 770 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_integer_type ( uint32_t  type)
inlinestatic

returns if the record is a integer type (INTEGER, INTEGER_ARRAY)

Parameters
typethe type to check
Returns
true if the record is an integer

Definition at line 777 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_ref_counted ( void  ) const
inline

returns if the record has a reference-counted type

Returns
true if the record is reference-counted

Definition at line 734 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_ref_counted ( uint32_t  type)
inlinestatic

returns if the record has a reference-counted type

Parameters
typethe type to check
Returns
true if the record is reference-counted

Definition at line 740 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_string_type ( void  ) const
inline

returns true if the record is a string type (STRING, XML, TEXT_FILE)

Returns
true if the record is a string

Definition at line 746 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::is_string_type ( uint32_t  type)
inlinestatic

returns if the record is a string type (STRING, XML, TEXT_FILE)

Parameters
typethe type to check
Returns
true if the record is a string

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 "";

Returns
true if the record is non-zero or not-"". False otherwise.

Definition at line 1166 of file KnowledgeRecord.cpp.

bool madara::knowledge::KnowledgeRecord::is_valid ( void  ) const
inline

Checks to see if the record is valid.

Valid records have a status that is not UNCREATED.

Returns
true if the record is valid. False otherwise.

Definition at line 1426 of file KnowledgeRecord.h.

madara::knowledge::KnowledgeRecord::operator bool ( void  ) const
inlineexplicit

Explicit bool cast.

Returns
the value of is_true()

Definition at line 1507 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::operator! ( void  ) const
inline

Logical not.

Definition at line 322 of file KnowledgeRecord.inl.

Unequal to.

Definition at line 313 of file KnowledgeRecord.inl.

KnowledgeRecord madara::knowledge::KnowledgeRecord::operator% ( const KnowledgeRecord rhs) const
inline

Modulus operator.

Definition at line 526 of file KnowledgeRecord.inl.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator%= ( const KnowledgeRecord rhs)
inline

In-place modulus operator.

Definition at line 481 of file KnowledgeRecord.inl.

KnowledgeRecord madara::knowledge::KnowledgeRecord::operator* ( const KnowledgeRecord rhs) const
inline

Times operator.

Definition at line 502 of file KnowledgeRecord.inl.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator*= ( const KnowledgeRecord rhs)
inline

In-place multiplication operator.

Definition at line 423 of file KnowledgeRecord.inl.

KnowledgeRecord madara::knowledge::KnowledgeRecord::operator+ ( const KnowledgeRecord rhs) const
inline

Plus operator.

Definition at line 538 of file KnowledgeRecord.inl.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator++ ( void  )
inline

Preincrement operator.

In-place preincrement.

Definition at line 388 of file KnowledgeRecord.inl.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator+= ( const KnowledgeRecord rhs)
inline

In-place addition operator.

Definition at line 351 of file KnowledgeRecord.inl.

KnowledgeRecord madara::knowledge::KnowledgeRecord::operator- ( void  ) const
inline

Negate.

Definition at line 331 of file KnowledgeRecord.inl.

KnowledgeRecord madara::knowledge::KnowledgeRecord::operator- ( const KnowledgeRecord rhs) const
inline

Minus operator.

Definition at line 574 of file KnowledgeRecord.inl.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator-- ( void  )
inline

Predecrement operator.

In-place predecrement.

Definition at line 373 of file KnowledgeRecord.inl.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator-= ( const KnowledgeRecord rhs)
inline

In-place subtraction operator.

Definition at line 404 of file KnowledgeRecord.inl.

KnowledgeRecord madara::knowledge::KnowledgeRecord::operator/ ( const KnowledgeRecord rhs) const
inline

Divides operator.

Definition at line 514 of file KnowledgeRecord.inl.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator/= ( const KnowledgeRecord rhs)
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.

template<typename T >
auto madara::knowledge::KnowledgeRecord::operator= ( T &&  t) -> typename std::enable_if<!std::is_convertible<T, KnowledgeRecord>::value, decltype(this->set_value(std::forward<T>(t)), *this)>::type
inline

Definition at line 824 of file KnowledgeRecord.h.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator= ( const KnowledgeRecord rhs)
inline

Assignment.

Definition at line 188 of file KnowledgeRecord.inl.

KnowledgeRecord & madara::knowledge::KnowledgeRecord::operator= ( knowledge::KnowledgeRecord &&  rhs)
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.

const char * madara::knowledge::KnowledgeRecord::read ( const char *  buffer,
int64_t &  buffer_remaining 
)
inline

Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining.

Parameters
bufferthe readable buffer where data is stored
buffer_remainingthe count of bytes remaining in the buffer to read
Returns
current buffer position for next read

Definition at line 890 of file KnowledgeRecord.inl.

const char * madara::knowledge::KnowledgeRecord::read ( const char *  buffer,
std::string &  key,
int64_t &  buffer_remaining 
)
inline

Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining.

Parameters
bufferthe readable buffer where data is stored
keythe name of the variable
buffer_remainingthe count of bytes remaining in the buffer to read
Returns
current buffer position for next read

Definition at line 1005 of file KnowledgeRecord.inl.

const char * madara::knowledge::KnowledgeRecord::read ( const char *  buffer,
uint32_t &  key_id,
int64_t &  buffer_remaining 
)
inline

Reads a KnowledgeRecord instance from a buffer and updates the amount of buffer room remaining.

Parameters
bufferthe readable buffer where data is stored
key_idthe keyed index for the name of a variable
buffer_remainingthe count of bytes remaining in the buffer to read
Returns
current buffer position for next 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

Parameters
filenamelocation of the file to read from
read_as_typeforce a type (XML, TEXT, IMAGE_JPEG, or UNKNOWN_FILE_TYPE)
Returns
size of file

Definition at line 60 of file KnowledgeRecord.cpp.

void madara::knowledge::KnowledgeRecord::reset_value ( void  )
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

Parameters
new_sizenew 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.

Parameters
indexindex of the array item
Returns
value at the index

Definition at line 988 of file KnowledgeRecord.cpp.

void madara::knowledge::KnowledgeRecord::set_file ( const unsigned char *  new_value,
size_t  size 
)
inline

sets the value to an unknown file type

Parameters
new_valuenew value of the Knowledge Record
sizesize of the new_value buffer

Definition at line 1226 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_file ( std::vector< unsigned char > &&  new_value)
inline

sets the value to an unknown file type, without copying

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1234 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_file ( const std::vector< unsigned char > &  new_value)
inline

sets the value to an unknown file type

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1241 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_file ( std::shared_ptr< std::vector< unsigned char >>  new_value)
inline

sets the value to an unknown file type, without copying

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1248 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_fixed ( void  )
static

Sets the output format for doubles to std::fixed.

Definition at line 40 of file KnowledgeRecord.cpp.

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type >
void madara::knowledge::KnowledgeRecord::set_index ( size_t  index,
value 
)
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.

Parameters
indexindex of the value to set
valuethe 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.

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type = nullptr>
void madara::knowledge::KnowledgeRecord::set_index ( size_t  index,
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.

Parameters
indexindex of the value to set
valuethe value to set at the specified index
void madara::knowledge::KnowledgeRecord::set_jpeg ( const unsigned char *  new_value,
size_t  size 
)
inline

sets the value to a jpeg

Parameters
new_valuenew value of the Knowledge Record
sizesize of the new_value buffer

Definition at line 1195 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_jpeg ( std::vector< unsigned char > &&  new_value)
inline

sets the value to a jpeg, without copying

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1203 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_jpeg ( const std::vector< unsigned char > &  new_value)
inline

sets the value to a jpeg

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1210 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_jpeg ( std::shared_ptr< std::vector< unsigned char >>  new_value)
inline

sets the value to a jpeg, without copying

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1217 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_modified ( void  )
inline

sets the status to modified

Definition at line 645 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_precision ( int  new_precision)
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.

Parameters
new_precisionnew double precision to use

Definition at line 30 of file KnowledgeRecord.cpp.

void madara::knowledge::KnowledgeRecord::set_scientific ( void  )
static

Sets the output format for doubles to std::scientific.

Definition at line 50 of file KnowledgeRecord.cpp.

void madara::knowledge::KnowledgeRecord::set_text ( const char *  new_value,
size_t  size 
)
inline

sets the value to a plaintext string

Parameters
new_valuenew value of the Knowledge Record
sizesize of the new_value buffer

Definition at line 1163 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_text ( std::string &&  new_value)
inline

sets the value to a plaintext string

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1171 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_text ( const std::string &  new_value)
inline

sets the value to a plaintext string

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1179 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_text ( std::shared_ptr< std::string >  new_value)
inline

sets the value to a plaintext string.

Does not copy the string.

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1187 of file KnowledgeRecord.inl.

bool madara::knowledge::KnowledgeRecord::set_type ( int32_t  type)
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.

Parameters
typethe new type
Returns
true if conversion successfully applied, or was already type, false if not

Definition at line 676 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( const KnowledgeRecord new_value)
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.

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1074 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( KnowledgeRecord &&  new_value)
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.

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1086 of file KnowledgeRecord.inl.

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type >
void madara::knowledge::KnowledgeRecord::set_value ( new_value)
inline

sets the value to an integer

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1259 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( const Integer new_value,
uint32_t  size 
)
inline

sets the value to an array of integers

Parameters
new_valuenew value of the Knowledge Record
sizenum elements in the array

Definition at line 1270 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( std::vector< Integer > &&  new_value)
inline

sets the value to an array of integers

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1277 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( const std::vector< Integer > &  new_value)
inline

sets the value to an array of integers

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1284 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( std::shared_ptr< std::vector< Integer >>  new_value)
inline

sets the value to an array of integers, without copying

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1291 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( const char *  new_value,
uint32_t  size 
)
inline

sets the value to a string, from a buffer

Parameters
new_valuenew value of the Knowledge Record
sizenum elements in the buffer

Definition at line 1123 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( std::string &&  new_value)
inline

sets the value to a string

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1099 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( const std::string &  new_value)
inline

sets the value to a string

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1107 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( std::shared_ptr< std::string >  new_value)
inline

sets the value to a string.

Does not copy the string.

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1115 of file KnowledgeRecord.inl.

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, void * >::type = nullptr>
void madara::knowledge::KnowledgeRecord::set_value ( new_value)

sets the value to a floating point number

Parameters
new_valuenew value of the Knowledge Record
void madara::knowledge::KnowledgeRecord::set_value ( const double *  new_value,
uint32_t  size 
)
inline

sets the value to an array of doubles

Parameters
new_valuenew value of the Knowledge Record
sizenum elements in the array

Definition at line 1311 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( std::vector< double > &&  new_value)
inline

sets the value to an array of doubles

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1318 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( const std::vector< double > &  new_value)
inline

sets the value to an array of doubles

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1325 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_value ( std::shared_ptr< std::vector< double >>  new_value)
inline

sets the value to an array of doubles, without copying

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1332 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_xml ( const char *  new_value,
size_t  size 
)
inline

sets the value to an xml string

Parameters
new_valuenew value of the Knowledge Record
sizesize of the new_value buffer

Definition at line 1131 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_xml ( std::string &&  new_value)
inline

sets the value to an xml string

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1139 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_xml ( const std::string &  new_value)
inline

sets the value to an xml string

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1147 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::set_xml ( std::shared_ptr< std::string >  new_value)
inline

sets the value to an xml string.

Does not copy the string.

Parameters
new_valuenew value of the Knowledge Record

Definition at line 1155 of file KnowledgeRecord.inl.

std::shared_ptr< std::vector< unsigned char > > madara::knowledge::KnowledgeRecord::share_binary ( ) const
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 1481 of file KnowledgeRecord.inl.

std::shared_ptr< std::vector< double > > madara::knowledge::KnowledgeRecord::share_doubles ( ) const
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 1455 of file KnowledgeRecord.inl.

std::shared_ptr< std::vector< KnowledgeRecord::Integer > > madara::knowledge::KnowledgeRecord::share_integers ( ) const
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 1429 of file KnowledgeRecord.inl.

std::shared_ptr< std::string > madara::knowledge::KnowledgeRecord::share_string ( ) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not a string, returns NULL shared_ptr

Definition at line 1403 of file KnowledgeRecord.inl.

uint32_t madara::knowledge::KnowledgeRecord::size ( void  ) const
inline

returns the size of the value

Definition at line 653 of file KnowledgeRecord.inl.

int madara::knowledge::KnowledgeRecord::status ( void  ) const
inline

returns the status of the record.

Returns
1 if modified, 0 if uncreated

Definition at line 636 of file KnowledgeRecord.inl.

std::shared_ptr< std::vector< unsigned char > > madara::knowledge::KnowledgeRecord::take_binary ( )
inline
Returns
a shared_ptr, while resetting this record to empty. If this record is not a binary file value, returns NULL shared_ptr and this record is unmodified.

Definition at line 1491 of file KnowledgeRecord.inl.

std::shared_ptr< std::vector< double > > madara::knowledge::KnowledgeRecord::take_doubles ( )
inline
Returns
a shared_ptr, while resetting this record to empty. If this record is not doubles array, returns NULL shared_ptr and this record is unmodified.

Definition at line 1465 of file KnowledgeRecord.inl.

std::shared_ptr< std::vector< KnowledgeRecord::Integer > > madara::knowledge::KnowledgeRecord::take_integers ( )
inline
Returns
a shared_ptr, while resetting this record to empty. If this record is not an int array, returns NULL shared_ptr and this record is unmodified.

Definition at line 1439 of file KnowledgeRecord.inl.

std::shared_ptr< std::string > madara::knowledge::KnowledgeRecord::take_string ( )
inline
Returns
a shared_ptr, while resetting this record to empty. If this record is not a string, returns NULL shared_ptr and this record is unmodified.

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

Returns
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

Parameters
filenamefile 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

Returns
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.

Parameters
delimitercharacters to insert in between elements of an array
Returns
the value as a string

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

Parameters
sizesize of the unmanaged buffer
Returns
the unmanaged buffer of size bytes

Definition at line 413 of file KnowledgeRecord.cpp.

int32_t madara::knowledge::KnowledgeRecord::type ( void  ) const
inline

returns the size of the value

Definition at line 670 of file KnowledgeRecord.inl.

void madara::knowledge::KnowledgeRecord::unshare ( void  )
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.

char * madara::knowledge::KnowledgeRecord::write ( char *  buffer,
int64_t &  buffer_remaining 
) const
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

Parameters
bufferthe readable buffer where data is stored
buffer_remainingthe count of bytes remaining in the buffer to read
Returns
current buffer position for next write

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.

char * madara::knowledge::KnowledgeRecord::write ( char *  buffer,
const std::string &  key,
int64_t &  buffer_remaining 
) const
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

Parameters
bufferthe readable buffer where data is stored
keythe name of the variable
buffer_remainingthe count of bytes remaining in the buffer to read
Returns
current buffer position for next write

Definition at line 1664 of file KnowledgeRecord.inl.

char * madara::knowledge::KnowledgeRecord::write ( char *  buffer,
uint32_t  key_id,
int64_t &  buffer_remaining 
) const
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

Parameters
bufferthe readable buffer where data is stored
key_idthe id of the variable
buffer_remainingthe count of bytes remaining in the buffer to read
Returns
current buffer position for next write

Definition at line 1719 of file KnowledgeRecord.inl.

Friends And Related Function Documentation

friend class ThreadSafeContext
friend

Definition at line 63 of file KnowledgeRecord.h.

Member Data Documentation

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.

logger::Logger* madara::knowledge::KnowledgeRecord::logger_ = logger::global_logger.get ()
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.

bool madara::knowledge::KnowledgeRecord::shared_ = OWNED
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.

uint32_t madara::knowledge::KnowledgeRecord::type_ = EMPTY
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.


The documentation for this class was generated from the following files: