18 #ifndef _APAMA_EPL_PLUGINS_HPP_ 19 #define _APAMA_EPL_PLUGINS_HPP_ 29 namespace correlator {
30 class CorrelatorInterface;
52 namespace _EPLPLUGIN_INTERNAL_CPP_NAMESPACE {
71 #include <sag_internal/epl_plugin_wrap.hpp> 75 namespace _EPLPLUGIN_INTERNAL_CPP_NAMESPACE {
80 template<
typename DERIVED>
104 template <
typename FN_T, FN_T fn>
105 void registerMethod(
const char *name,
bool blocking=
true);
123 template <
typename FN_T, FN_T fn>
124 void registerMethod(
const char *name,
const char *signature,
bool blocking=
true);
126 ApamaEPLMethodData *getMethods();
129 std::vector<ApamaEPLMethodData> methods;
146 : internal(other.internal), obj(other.internal)
154 internal = other.internal;
163 void addChannel(
const char *channel);
171 bool removeChannel(
const char *channel);
176 void removeAllChannels();
184 EventHandlerSubscription(
const EventHandlerSubscription&) =
delete;
185 EventHandlerSubscription &operator=(
const EventHandlerSubscription &) =
delete;
199 typedef std::unique_ptr<EventHandler>
ptr_t;
207 virtual void handleEvent(
const char *type,
data_t &&event,
const char *channel) = 0;
220 typedef std::unique_ptr<ThreadEndedHandler>
ptr_t;
224 virtual void threadEnded() = 0;
256 void receiveThreadEndedCallbacks(std::unique_ptr<ThreadEndedHandler> &&handler)
const;
266 EventHandler::subscription_t registerEventHandler(std::unique_ptr<EventHandler> &&handler,
const char *channel, event_mode_t mode=MAP_MODE,
bool blocking=
true)
const;
272 void sendEvent(
const char *event)
const;
280 return sendEvent(event.c_str());
288 void sendEvent(
const char *type,
data_t &&event)
const;
297 sendEventTo(event.c_str(), ctx);
305 void sendEventTo(
const char *event, uint64_t ctx)
const;
313 void sendEventTo(
const char *type,
data_t &&event, uint64_t ctx)
const;
319 void sendEventTo(
const std::string &event,
const std::string &channel)
const 321 sendEventTo(event.c_str(), channel.c_str());
328 void sendEventTo(
const char *event,
const char *channel)
const;
335 void sendEventTo(
const char *type,
data_t &&event,
const char *channel)
const;
342 void pluginMethodBlocking()
const;
348 int64_t getCurrentContextId()
const;
354 static bool callEventHandler(
void *handler,
const char *type, sag_underlying_data_t event,
const char *channel);
356 static void deleteEventHandler(
void *handler);
358 static bool callThreadEndedHandler(
void *handler);
360 static void deleteThreadEndedHandler(
void *handler);
396 template<
typename DERIVED>
401 typedef data_t (*call_method_fn_t)(DERIVED *
self,
const list_t &args);
413 logger(
"plugins."+name)
426 static data_t callMethod(
void *
self,
void *fn,
const list_t &args);
429 DERIVED &derived() {
return *static_cast<DERIVED*>(
this); }
454 namespace epl {
using namespace _EPLPLUGIN_INTERNAL_CPP_NAMESPACE; }
459 #include <sag_internal/epl_plugin_functions.hpp> 460 #include <sag_internal/epl_plugin_methods.hpp> 461 #include <sag_internal/exception.hpp> 462 #include <sag_internal/epl_plugin_macros.hpp> 471 #define APAMA_DECLARE_EPL_PLUGIN(Class) _APAMA_DECLARE_EPL_PLUGIN(Class) 473 #endif // _APAMA_EPL_PLUGINS_HPP_ Derive from this class to define a Correlator EPL plug-in.
Definition: epl_plugin.hpp:397
EventHandlerSubscription & operator=(EventHandlerSubscription &&other)
Move an EventHandlerSubscription into this one.
Definition: epl_plugin.hpp:152
Class for writing to the system logger.
Definition: sag_plugin_logging.hpp:72
std::unique_ptr< EventHandler > ptr_t
Pointer type for passing to registerEventHandler.
Definition: epl_plugin.hpp:199
Helper class for writing visitors to apply to data_t.
Definition: sag_connectivity_cpp.hpp:136
This type is returned from CorrelatorInterface::registerEventHandler and can be used to add and remov...
Definition: epl_plugin.hpp:138
void sendEvent(const std::string &event) const
(deprecated) Send an event in string form to the default input queue.
Definition: epl_plugin.hpp:278
get_details::GetVisitor< const T >::result_type get(const data_t &t)
Get the contents of a data_t, given the type.
Definition: sag_connectivity_cpp.hpp:68
Contains the C++ implementation of the underlying datatypes used by connectivity plugins and their ac...
std::unique_ptr< ThreadEndedHandler > ptr_t
Pointer type for passing to receiveThreadEndedCallbacks.
Definition: epl_plugin.hpp:220
void sendEventTo(const std::string &event, const std::string &channel) const
Send an event in string form to a channel.
Definition: epl_plugin.hpp:319
size_t getNumMethods()
Return the number of declared methods.
Definition: epl_plugin.hpp:87
static CorrelatorInterface & getCorrelator()
Return a reference to the correlator host interface.
Definition: epl_plugin.hpp:416
V::result_type apply_visitor(const V &v, data_t &t)
Apply a visitor (using the boost::static_visitor pattern) to the given data_t.
Definition: sag_connectivity_cpp.hpp:37
sag_underlying_decimal_t decimal_t
Decimals are implemented with an underlying 64bit int conforming to IEEE 754 decimal 64.
Definition: sag_connectivity_cpp.hpp:55
An interface for subscribing to events and receiving them in the plug-in.
Definition: epl_plugin.hpp:193
A list class which implements many of the functions on std::vector.
Definition: sag_connectivity_cpp.hpp:34
virtual ~ThreadEndedHandler()
To allow virtual deletion.
Definition: epl_plugin.hpp:222
EventHandlerSubscription()
Create a dummy EventHandlerSubscription.
Definition: epl_plugin.hpp:143
event_mode_t
Mode for receiving events in.
Definition: epl_plugin.hpp:245
MethodData< DERIVED > method_data_t
Convenience typedef for the method data type.
Definition: epl_plugin.hpp:406
EPLPlugin base_plugin_t
Convenience typedef for the base type.
Definition: epl_plugin.hpp:404
Data structure used for declaring methods in the initialize function (EPLPlugin) to be exported to EP...
Definition: epl_plugin.hpp:81
A map class which implements many of the functions on std::map.
Definition: sag_connectivity_cpp.hpp:36
Logger logger
A Logger object which can be used to log to the correlator log file.
Definition: epl_plugin.hpp:423
Deliver events in string form.
Definition: epl_plugin.hpp:248
virtual ~EventHandler()
To allow virtual deletion.
Definition: epl_plugin.hpp:201
An interface to the correlator which lets plug-ins call methods on the host.
Definition: epl_plugin.hpp:233
A class that holds an untyped byte buffer.
Definition: sag_connectivity_cpp.hpp:27
Contains the headers needed to implement your own Connectivity Plugins.
EPLPlugin(const std::string &name)
Construct an EPL plug-in with a name (for logging)
Definition: epl_plugin.hpp:412
Helper class for writing visitors to apply to data_t.
Definition: sag_connectivity_cpp.hpp:44
An interface for receiving notifications of threads being destroyed.
Definition: epl_plugin.hpp:216
A variant type which can be one of the following:
Definition: sag_connectivity_cpp.hpp:42
EventHandlerSubscription(EventHandlerSubscription &&other)
Move an EventHandlerSubscription.
Definition: epl_plugin.hpp:145
A wrapper type for holding arbitrary objects inside a data_t.
Definition: sag_connectivity_cpp.hpp:55
EventHandlerSubscription subscription_t
Pointer to a type used to add and remove channels on a registered handler.
Definition: epl_plugin.hpp:197
void sendEventTo(const std::string &event, uint64_t ctx) const
Send an event in string form to a specific context.
Definition: epl_plugin.hpp:295