1 #ifndef _MADARA_KNOWLEDGE_BASE_H 2 #define _MADARA_KNOWLEDGE_BASE_H 20 #include "madara/MADARA_export.h" 30 #ifdef _MADARA_PYTHON_CALLBACKS_ 31 #include "boost/python/object.hpp" 126 bool clean_copy =
false);
137 void activate_transport (
void);
142 void close_transport (
void);
148 size_t get_num_transports (
void);
205 return impl_->share_string (key, settings);
209 return context_->share_string (key, settings);
225 return impl_->share_string (key, settings);
229 return context_->share_string (key, settings);
245 return impl_->take_string (key, settings);
249 return context_->take_string (key, settings);
265 return impl_->take_string (key, settings);
269 return context_->take_string (key, settings);
279 std::shared_ptr<std::vector<KnowledgeRecord::Integer>>
286 return impl_->share_integers (key, settings);
290 return context_->share_integers (key, settings);
300 std::shared_ptr<std::vector<KnowledgeRecord::Integer>>
307 return impl_->share_integers (key, settings);
311 return context_->share_integers (key, settings);
321 std::shared_ptr<std::vector<KnowledgeRecord::Integer>>
328 return impl_->take_integers (key, settings);
332 return context_->take_integers (key, settings);
342 std::shared_ptr<std::vector<KnowledgeRecord::Integer>>
349 return impl_->take_integers (key, settings);
353 return context_->take_integers (key, settings);
363 std::shared_ptr<std::vector<double>>
370 return impl_->share_doubles (key, settings);
374 return context_->share_doubles (key, settings);
384 std::shared_ptr<std::vector<double>>
391 return impl_->share_doubles (key, settings);
395 return context_->share_doubles (key, settings);
405 std::shared_ptr<std::vector<double>>
412 return impl_->take_doubles (key, settings);
416 return context_->take_doubles (key, settings);
426 std::shared_ptr<std::vector<double>>
433 return impl_->take_doubles (key, settings);
437 return context_->take_doubles (key, settings);
447 std::shared_ptr<std::vector<unsigned char>>
454 return impl_->share_binary (key, settings);
458 return context_->share_binary (key, settings);
468 std::shared_ptr<std::vector<unsigned char>>
475 return impl_->share_binary (key, settings);
479 return context_->share_binary (key, settings);
489 std::shared_ptr<std::vector<unsigned char>>
496 return impl_->take_binary (key, settings);
500 return context_->take_binary (key, settings);
510 std::shared_ptr<std::vector<unsigned char>>
517 return impl_->take_binary (key, settings);
521 return context_->take_binary (key, settings);
661 return set (variable, 1, settings);
672 const std::vector <double> & value,
684 std::vector <double> && value,
697 const double * value,
712 size_t index, T&& value,
724 typename std::enable_if<std::is_floating_point<T>::value,
725 void*>::type =
nullptr>
739 const std::vector <KnowledgeRecord::Integer> & value,
751 std::vector <KnowledgeRecord::Integer> && value,
777 typename std::enable_if<std::is_integral<T>::value,
778 void*>::type =
nullptr>
793 const char * value,
size_t size,
806 const unsigned char * value,
size_t size,
819 const unsigned char * value,
size_t size,
832 const unsigned char * value,
size_t size,
845 const unsigned char * value,
size_t size,
858 const char * value,
size_t size,
908 #ifndef _MADARA_NO_KARL_ 1000 #ifdef _MADARA_JAVA_ 1006 void define_function (
const std::string & name, jobject callable);
1009 #ifdef _MADARA_PYTHON_CALLBACKS_ 1015 void define_function (
const std::string & name, boost::python::object callable);
1034 #endif // _MADARA_NO_KARL_ 1045 template<
typename T,
1046 typename std::enable_if<std::is_integral<T>::value,
1047 void*>::type =
nullptr>
1063 template<
typename T>
1065 size_t index, T&& value,
1095 const std::vector <KnowledgeRecord::Integer> & value,
1109 std::vector <KnowledgeRecord::Integer> && value,
1123 return set (key, 1, settings);
1135 template<
typename T,
1136 typename std::enable_if<std::is_floating_point<T>::value,
1137 void*>::type =
nullptr>
1153 const double * value,
1168 const std::vector <double> & value,
1182 std::vector <double> && value,
1219 void set_quality (
const std::string & key, uint32_t quality,
1239 void print_all_redeployment_results (std::ostream & output);
1245 void run_all (
void);
1251 long start_latency (
void);
1257 void print_my_latencies (std::ostream & output);
1263 void print_all_latencies (std::ostream & output);
1269 void print_all_summations (std::ostream & output);
1330 void print (
unsigned int level = 0)
const;
1337 void print_knowledge (
unsigned int level = 0)
const;
1348 unsigned int level = 0)
const;
1375 const std::string & key_val_delimiter =
"=")
const;
1395 void clear (
bool erase =
false);
1400 void reset_checkpoint (
void)
const;
1405 void clear_map (
void);
1412 void acquire (
void);
1419 void release (
void);
1446 size_t remove_transport (
size_t index);
1515 std::vector <KnowledgeRecord> & target);
1528 std::map <std::string, knowledge::KnowledgeRecord> & target);
1549 std::vector <std::string> & next_keys,
1550 std::map <std::string, knowledge::KnowledgeRecord> & result,
1551 bool just_keys =
false);
1581 int64_t save_context (
const std::string & filename)
const;
1597 int64_t save_as_json (
const std::string & filename)
const;
1611 int64_t save_as_karl (
const std::string & filename)
const;
1627 int64_t save_checkpoint (
const std::string & filename,
1628 bool reset_modifieds =
true);
1639 int64_t save_checkpoint (
1651 int64_t load_context (
const std::string & filename,
1669 int64_t load_context (
const std::string & filename,
1710 int send_modifieds (
1711 const std::string & prefix =
"KnowledgeBase::send_modifieds",
1722 void clear_modifieds (
void);
1728 void wait_for_change (
void);
1743 std::shared_ptr <KnowledgeBaseImpl>
impl_;
1755 #endif // _MADARA_KNOWLEDGE_BASE_H This class encapsulates an entry in a KnowledgeBase.
std::map< std::string, bool > CopySet
Typedef for set of copyable keys.
std::shared_ptr< std::vector< unsigned char > > take_binary(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Returns a shared_ptr, sharing with the internal one.
MADARA_Export int read_file(const std::string &filename, void *&buffer, size_t &size, bool add_zero_char=false)
Reads a file into a provided void pointer.
std::shared_ptr< std::vector< unsigned char > > share_binary(const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Returns a shared_ptr, sharing with the internal one.
This class stores variables and their values for use by any entity needing state information in a thr...
std::shared_ptr< std::vector< unsigned char > > take_binary(const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Returns a shared_ptr, sharing with the internal one.
Holds settings for checkpoints to load or save.
Provides knowledge logging services to files and terminals.
Holds basic transport settings.
std::shared_ptr< std::string > share_string(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Returns a shared_ptr, sharing with the internal one.
Optimized reference to a variable within the knowledge base.
Compiled, optimized KaRL logic.
std::vector< KnowledgeRecord > FunctionArguments
std::shared_ptr< std::vector< double > > take_doubles(const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Returns a shared_ptr, sharing with the internal one.
std::shared_ptr< std::vector< KnowledgeRecord::Integer > > take_integers(const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Returns a shared_ptr, sharing with the internal one.
std::shared_ptr< KnowledgeBaseImpl > impl_
Pointer to actual implementation, i.e., the "bridge", which is reference counted to automate memory m...
std::shared_ptr< std::vector< unsigned char > > share_binary(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Returns a shared_ptr, sharing with the internal one.
std::shared_ptr< std::vector< double > > share_doubles(const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Returns a shared_ptr, sharing with the internal one.
A multi-threaded logger for logging to one or more destinations.
std::shared_ptr< std::string > share_string(const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Returns a shared_ptr, sharing with the internal one.
std::shared_ptr< std::string > take_string(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Returns a shared_ptr, while resetting this record to empty.
MADARA_Export ssize_t write_file(const std::string &filename, void *buffer, size_t size)
Writes a file with provided contents.
ThreadSafeContext * context_
A knowledge base can also be a facade for another knowledge base.
Holds settings requirements for knowledge, usually in copying.
void set_log_level(int level)
Sets the log level.
This class provides a distributed knowledge base to users.
::std::map< std::string, KnowledgeRecord > KnowledgeMap
std::shared_ptr< std::vector< double > > share_doubles(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Returns a shared_ptr, sharing with the internal one.
An abstract base class defines a simple abstract implementation of an expression tree node...
std::shared_ptr< std::vector< KnowledgeRecord::Integer > > take_integers(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Returns a shared_ptr, sharing with the internal one.
std::shared_ptr< std::vector< double > > take_doubles(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Returns a shared_ptr, sharing with the internal one.
int get_log_level(void)
Gets the log level.
std::shared_ptr< std::vector< KnowledgeRecord::Integer > > share_integers(const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Returns a shared_ptr, sharing with the internal one.
std::vector< VariableReference > VariableReferences
a vector of variable references
Encapsulates settings for an evaluation statement.
MADARA_Export bool exists(const char *originator, uint64_t clock, uint32_t update_number, OriginatorFragmentMap &map)
Checks if a fragment already exists within a fragment map.
Provides functions and classes for the distributed knowledge base.
Settings for applying knowledge updates.
Copyright (c) 2015 Carnegie Mellon University.
Encapsulates settings for a wait statement.
Settings for applying knowledge updates.
Base class from which all transports must be derived.
Provides an interface for external functions into the MADARA KaRL variable settings.
std::shared_ptr< std::vector< KnowledgeRecord::Integer > > share_integers(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Returns a shared_ptr, sharing with the internal one.
std::shared_ptr< std::string > take_string(const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Returns a shared_ptr, while resetting this record to empty.