MADARA  3.2.3
KnowledgeCast.h File Reference
#include <string>
#include <cstring>
#include <type_traits>
#include <stdbool.h>
#include <madara/knowledge/KnowledgeRecord.h>
#include <madara/utility/SupportTest.h>

Go to the source code of this file.

Classes

class  madara::knowledge::type< T >
 helper type for specifying template type parameters using a function argument instead of inside explicit "<...>". More...
 

Namespaces

 madara
 Copyright (c) 2015 Carnegie Mellon University.
 
 madara::knowledge
 Provides functions and classes for the distributed knowledge base.
 

Macros

#define MADARA_KNOWLEDGE_BINARY_OP(op)
 Generates binary math operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecord. More...
 
#define MADARA_KNOWLEDGE_COMPARE_OP(op)
 Generates comparison operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecords. More...
 
#define MADARA_KNOWLEDGE_COMPOSITE_OP(op)
 Generates composite assignment operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecord. More...
 

Functions

template<class Out >
Out madara::knowledge::knowledge_cast (const KnowledgeRecord &in)
 Convert a KnowledgeRecord into a specified type. More...
 
template<class Out >
Out madara::knowledge::knowledge_cast (type< T > t, const KnowledgeRecord &in)
 Convert a KnowledgeRecord into a specified type, using the "type" helper struct to specify type. More...
 
template<class Out >
Out & madara::knowledge::knowledge_cast (const KnowledgeRecord &in, Out &out)
 Convert a KnowledgeRecord into a specified type, using an output parameter. More...
 
template<class In >
KnowledgeRecord madara::knowledge::knowledge_cast (const In &in)
 Convert a given value into a KnowledgeRecord. More...
 
bool madara::knowledge::operator!= (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator!= (const KnowledgeRecord &l, const std::string &r)
 
bool madara::knowledge::operator!= (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator!= (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l)!=r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator!= (const T &l, const KnowledgeRecord &r) -> decltype(l!=knowledge_cast< T >(r))
 
bool madara::knowledge::operator!= (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator!= (const KnowledgeRecord &l, const char *r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator% (const KnowledgeRecord &l, const T &r) -> decltype(l%knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator% (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l)%r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator%= (KnowledgeRecord &l, const T &r) -> decltype(l%=knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator* (const KnowledgeRecord &l, const T &r) -> decltype(l *knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator* (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l)*r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator*= (KnowledgeRecord &l, const T &r) -> decltype(l *=knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator+ (const KnowledgeRecord &l, const T &r) -> decltype(l+knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator+ (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l)+r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator+= (KnowledgeRecord &l, const T &r) -> decltype(l+=knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator- (const KnowledgeRecord &l, const T &r) -> decltype(l-knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator- (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l)-r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator-= (KnowledgeRecord &l, const T &r) -> decltype(l-=knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator/ (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l)/r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator/ (const KnowledgeRecord &l, const T &r) -> decltype(l/knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator/= (KnowledgeRecord &l, const T &r) -> decltype(l/=knowledge_cast(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator< (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l)< r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator< (const T &l, const KnowledgeRecord &r) -> decltype(l< knowledge_cast< T >(r))
 
bool madara::knowledge::operator< (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator< (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator< (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator< (const KnowledgeRecord &l, const std::string &r)
 
bool madara::knowledge::operator< (const std::string &l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator<= (const KnowledgeRecord &l, std::nullptr_t)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator<= (const T &l, const KnowledgeRecord &r) -> decltype(l<=knowledge_cast< T >(r))
 
bool madara::knowledge::operator<= (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator<= (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator<= (const KnowledgeRecord &l, const std::string &r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator<= (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l)<=r)
 
bool madara::knowledge::operator<= (const std::string &l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator== (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator== (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator== (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator== (const KnowledgeRecord &l, const std::string &r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator== (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l)==r)
 
bool madara::knowledge::operator== (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator== (const T &l, const KnowledgeRecord &r) -> decltype(l==knowledge_cast< T >(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator> (const T &l, const KnowledgeRecord &r) -> decltype(l >knowledge_cast< T >(r))
 
bool madara::knowledge::operator> (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator> (const KnowledgeRecord &l, const std::string &r)
 
bool madara::knowledge::operator> (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator> (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l) >r)
 
bool madara::knowledge::operator> (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator> (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator>= (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator>= (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator>= (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator>= (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator>= (const T &l, const KnowledgeRecord &r) -> decltype(l >=knowledge_cast< T >(r))
 
template<typename T , typename std::enable_if<!std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator>= (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l) >=r)
 
bool madara::knowledge::operator>= (const KnowledgeRecord &l, const std::string &r)
 

Macro Definition Documentation

#define MADARA_KNOWLEDGE_BINARY_OP (   op)
Value:
template<typename T, \
typename std::enable_if<!std::is_convertible<T, KnowledgeRecord>::value && \
std::is_fundamental<T>::value, void *>::type = nullptr> \
inline auto operator op (const KnowledgeRecord &l, const T &r) -> \
decltype(l op knowledge_cast(r)) \
{ \
return l op knowledge_cast(r); \
} \
\
template<typename T, \
typename std::enable_if<!std::is_convertible<T, KnowledgeRecord>::value && \
std::is_fundamental<T>::value, void *>::type = nullptr> \
inline auto operator op (const T &l, const KnowledgeRecord &r) -> \
decltype(knowledge_cast(l) op r) \
{ \
return knowledge_cast(l) op r; \
}
This class encapsulates an entry in a KnowledgeBase.
KnowledgeRecord knowledge_cast(const In &in)
Convert a given value into a KnowledgeRecord.

Generates binary math operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecord.

Definition at line 554 of file KnowledgeCast.h.

#define MADARA_KNOWLEDGE_COMPARE_OP (   op)

Generates comparison operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecords.

Definition at line 481 of file KnowledgeCast.h.

#define MADARA_KNOWLEDGE_COMPOSITE_OP (   op)
Value:
template<typename T, \
typename std::enable_if<!std::is_convertible<T, KnowledgeRecord>::value && \
std::is_fundamental<T>::value, void *>::type = nullptr> \
inline auto operator op (KnowledgeRecord &l, const T &r) -> \
decltype(l op knowledge_cast(r)) \
{ \
return l op knowledge_cast(r); \
}
This class encapsulates an entry in a KnowledgeBase.
KnowledgeRecord knowledge_cast(const In &in)
Convert a given value into a KnowledgeRecord.

Generates composite assignment operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecord.

Definition at line 581 of file KnowledgeCast.h.