2 #ifndef _MADARA_EXTERNAL_FUNCTIONS_H_
3 #define _MADARA_EXTERNAL_FUNCTIONS_H_
6 #include "madara/MadaraExport.h"
17 #include "madara_jni.h"
20 #ifdef _MADARA_PYTHON_CALLBACKS_
21 #include <boost/python.hpp>
37 class ThreadSafeContext;
69 #ifndef _MADARA_NO_KARL_
85 #ifndef _MADARA_NO_KARL_
101 #ifndef _MADARA_NO_KARL_
110 #ifndef _MADARA_NO_KARL_
117 function_contents(func),
119 type(KARL_EXPRESSION)
129 function_contents(exp.expression),
131 type(KARL_EXPRESSION)
144 #ifndef _MADARA_NO_KARL_
155 return type == EXTERN_UNNAMED && extern_unnamed;
160 return type == EXTERN_NAMED && extern_named;
165 return type == KARL_EXPRESSION;
170 return type == FUNCTOR;
175 return type == UNINITIALIZED;
185 #ifndef _MADARA_NO_KARL_
205 JNIEnv* env = madara_jni_get_env();
206 java_object = (jobject)env->NewGlobalRef(
object);
211 return type == JAVA_CALLABLE;
216 #ifdef _MADARA_PYTHON_CALLBACKS_
222 type(PYTHON_CALLABLE),
223 python_function(func)
226 if (0 == PyObject_HasAttrString(func.ptr(),
"__call__"))
229 PyErr_SetString(PyExc_TypeError,
"Handler must be a callable object");
231 boost::python::throw_error_already_set();
237 return type == PYTHON_CALLABLE && !python_function.is_none();
madara::knowledge::KnowledgeRecord KnowledgeRecord
Encapsulates a MADARA KaRL expression into an evaluatable tree.
Abstract base class for implementing individual record filters via a functor interface.
Compiled, optimized KaRL logic.
This class stores a function definition.
boost::python::object python_function
bool is_extern_named(void) const
Function(KnowledgeRecord(*func)(const char *, FunctionArguments &, Variables &))
Constructor for function pointer.
Function(KnowledgeRecord(*func)(FunctionArguments &, Variables &))
Constructor for function pointer.
Types
Types of functions supported.
bool is_java_callable(void) const
Function(jobject &object)
Constructor for java.
bool is_uninitialized(void) const
bool is_extern_unnamed(void) const
Function()
Default constructor.
Function(const madara::expression::ExpressionTree &func)
Constructor for KaRL expression.
Function(filters::RecordFilter *filter)
Constructor for KaRL expression.
filters::RecordFilter * functor
bool is_python_callable(void) const
madara::expression::ExpressionTree function_contents
bool is_karl_expression(void) const
Function(const madara::knowledge::CompiledExpression &exp)
Constructor for KaRL expression.
Function(boost::python::object &func)
Constructor for function pointer.
bool is_functor(void) const
This class encapsulates an entry in a KnowledgeBase.
Provides an interface for external functions into the MADARA KaRL variable settings.
Provides functions and classes for the distributed knowledge base.
T get(const KnowledgeRecord &kr)
Get the value of a KnowlegeRecord.
madara::knowledge::KnowledgeRecord VALUE_TYPE
std::vector< KnowledgeRecord > FunctionArguments
Provides knowledge logging services to files and terminals.
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger
Copyright(c) 2020 Galois.