2 #ifndef _MADARA_EXTERNAL_FUNCTIONS_H_ 3 #define _MADARA_EXTERNAL_FUNCTIONS_H_ 6 #include "madara/MADARA_export.h" 16 #include "madara_jni.h" 19 #ifdef _MADARA_PYTHON_CALLBACKS_ 20 #include <boost/python.hpp> 36 class ThreadSafeContext;
66 : extern_named (0), extern_unnamed (0),
68 #ifndef _MADARA_NO_KARL_
72 functor (0), type (UNINITIALIZED)
80 : extern_named (0), extern_unnamed (func),
82 #ifndef _MADARA_NO_KARL_
86 functor (0), type (EXTERN_UNNAMED)
95 : extern_named (func), extern_unnamed (0),
97 #ifndef _MADARA_NO_KARL_
101 functor (0), type (EXTERN_NAMED)
105 #ifndef _MADARA_NO_KARL_ 110 : extern_named (0), extern_unnamed (0), function_contents (func),
111 functor (0), type (KARL_EXPRESSION)
115 #endif // _MADARA_NO_KARL_ 121 : extern_named (0), extern_unnamed (0),
123 #ifndef _MADARA_NO_KARL_
127 functor (filter), type (FUNCTOR)
133 return type == EXTERN_UNNAMED && extern_unnamed;
138 return type == EXTERN_NAMED && extern_named;
143 return type == KARL_EXPRESSION;
148 return type == FUNCTOR;
153 return type == UNINITIALIZED;
163 #ifndef _MADARA_NO_KARL_ 166 #endif // _MADARA_NO_KARL_ 185 JNIEnv* env = madara_jni_get_env();
186 java_object = (jobject) env->NewGlobalRef(
object);
189 inline bool is_java_callable (
void)
const 191 return type == JAVA_CALLABLE;
196 #ifdef _MADARA_PYTHON_CALLBACKS_ 200 Function (boost::python::object & func)
202 python_function (func), type (PYTHON_CALLABLE)
204 bool invalid_callable =
false;
207 if (0 == PyObject_HasAttrString (func.ptr (),
"__call__"))
212 "Handler must be a callable object");
214 boost::python::throw_error_already_set();
218 bool is_python_callable (
void)
const 220 return type == PYTHON_CALLABLE && !python_function.is_none ();
223 boost::python::object python_function;
232 #endif // _MADARA_EXTERNAL_FUNCTIONS_H_ This class encapsulates an entry in a KnowledgeBase.
Function(KnowledgeRecord(*func)(const char *, FunctionArguments &, Variables &))
Constructor for function pointer.
This class stores a function definition.
bool is_functor(void) const
Encapsulates a MADARA KaRL expression into an evaluatable tree.
madara::knowledge::KnowledgeRecord KnowledgeRecord
Function(filters::RecordFilter *filter)
Constructor for KaRL expression.
bool is_karl_expression(void) const
Function(const madara::expression::ExpressionTree &func)
Constructor for KaRL expression.
MADARA_Export utility::Refcounter< logger::Logger > global_logger
Function()
Default constructor.
Abstract base class for implementing individual record filters via a functor interface.
Provides knowledge logging services to files and terminals.
std::vector< KnowledgeRecord > FunctionArguments
bool is_uninitialized(void) const
bool is_extern_named(void) const
Types
Types of functions supported.
madara::knowledge::KnowledgeRecord VALUE_TYPE
Provides functions and classes for the distributed knowledge base.
filters::RecordFilter * functor
Copyright (c) 2015 Carnegie Mellon University.
Provides an interface for external functions into the MADARA KaRL variable settings.
bool is_extern_unnamed(void) const
Function(KnowledgeRecord(*func)(FunctionArguments &, Variables &))
Constructor for function pointer.
madara::expression::ExpressionTree function_contents