JANA2
|
JStreamingEventSource is a class template which simplifies streaming events into JANA. More...
#include <JStreamingEventSource.h>
Public Member Functions | |
JStreamingEventSource (std::unique_ptr< JTransport > &&transport) | |
The constructor requires a unique pointer to a JTransport implementation. More... | |
void | Open () override |
Open delegates down to the transport, which will open a network socket or similar. | |
void | GetEvent (std::shared_ptr< JEvent > event) override |
GetEvent attempts to receive a JEventMessage. More... | |
Public Member Functions inherited from JEventSource | |
JEventSource (std::string resource_name, JApplication *app=nullptr) | |
virtual bool | GetObjects (const std::shared_ptr< const JEvent > &aEvent, JFactory *aFactory) |
virtual void | DoInitialize () |
ReturnStatus | DoNext (std::shared_ptr< JEvent > event) |
SourceStatus | GetStatus () const |
std::string | GetPluginName () const |
std::string | GetTypeName () const |
std::string | GetResourceName () const |
uint64_t | GetEventCount () const |
JApplication * | GetApplication () const |
virtual std::string | GetType () const |
std::string | GetName () const |
virtual std::string | GetVDescription () const |
Optional for getting description via source rather than JEventSourceGenerator. | |
JFactoryGenerator * | GetFactoryGenerator () const |
void | SetTypeName (std::string type_name) |
SetTypeName is intended as a replacement to GetType(), which should be less confusing for the user. More... | |
void | SetFactoryGenerator (JFactoryGenerator *generator) |
void | SetApplication (JApplication *app) |
void | SetPluginName (std::string plugin_name) |
void | SetRange (uint64_t nskip, uint64_t nevents) |
Static Public Member Functions | |
static std::string | GetDescription () |
Additional Inherited Members | |
Public Types inherited from JEventSource | |
enum | SourceStatus { Unopened, Opened, Finished } |
SourceStatus describes the current state of the EventSource. | |
enum | ReturnStatus { Success, TryAgain, Finished } |
ReturnStatus describes what happened the last time a GetEvent() was attempted. More... | |
enum | RETURN_STATUS { kSUCCESS, kNO_MORE_EVENTS, kBUSY, kTRY_AGAIN, kERROR, kUNKNOWN } |
The user is supposed to throw RETURN_STATUS::kNO_MORE_EVENTS or kBUSY from GetEvent() | |
JStreamingEventSource is a class template which simplifies streaming events into JANA.
JStreamingEventSource makes it convenient to stream existing events into JANA by handling transport and message format as separate, orthogonal concerns. The user need only implement classes satisfying the JTransport and JEventMessage interfaces, and then they get a JStreamingEventSource 'for free'.
JStreamingEventSource<T> is templated on some message type T, which is a subclass of JEventMessage. This is needed so that it can construct new message objects of the appropriate subclass. As a result, JStreamingEventSource<T> only emits JEvents containing JEventMessages of type T, which means that every message produced upstream must be compatible with that message format. This shouldn't be a problem: it is always possible to make the message format more flexible, and any associated complexity is fundamentally a property of the message format anyway. However, if we are using JStreamingEventSource, it is essential that each message corresponds to one JEvent.
The JStreamingEventSource owns its JTransport, but passes ownership of each JMessage to its enclosing JEvent.
|
inlineexplicit |
The constructor requires a unique pointer to a JTransport implementation.
This is a reasonable assumption to make because each JEventSource already corresponds to some unique resource. JStreamingEventSource should be free to destroy its transport object whenever it likes, so try to keep the JTransport free of weird shared state.
|
inlineoverridevirtual |
GetEvent attempts to receive a JEventMessage.
If it succeeds, it inserts it into the JEvent and sets the event number and run number appropriately.
Implements JEventSource.