JANA2
C++ framework for multi-threaded data processing
JStreamingEventSource< MessageT > Class Template Reference

JStreamingEventSource is a class template which simplifies streaming events into JANA. More...

#include <JStreamingEventSource.h>

Inheritance diagram for JStreamingEventSource< MessageT >:
[legend]
Collaboration diagram for JStreamingEventSource< MessageT >:
[legend]

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.
 
Result Emit (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 void Init ()
 
virtual void Preprocess (const JEvent &) const
 For work that should be done in parallel on a JEvent, but is tightly coupled to the JEventSource for some reason. More...
 
virtual void FinishEvent (JEvent &)
 FinishEvent is used to notify the JEventSource that an event has been completely processed. More...
 
virtual void Close ()
 Close is called by JANA when it is finished accepting events from this event source. More...
 
virtual void GetEvent (std::shared_ptr< JEvent >)
 GetEvent is called by JANA in order to emit a fresh event into the stream. More...
 
virtual bool GetObjects (const std::shared_ptr< const JEvent > &, JFactory *)
 GetObjects was historically used for lazily unpacking data from a JEvent and putting it into a "dummy" JFactory. More...
 
std::string GetResourceName () const
 
uint64_t GetEventCount () const
 
uint64_t GetEmittedEventCount () const
 
uint64_t GetFinishedEventCount () const
 
virtual std::string GetType () const
 
std::string GetName () const
 
bool IsGetObjectsEnabled () const
 
bool IsFinishEventEnabled () const
 
bool IsPreprocessEnabled () const
 
uint64_t GetNSkip ()
 
uint64_t GetNEvents ()
 
virtual std::string GetVDescription () const
 Optional for getting description via source rather than JEventSourceGenerator.
 
void SetResourceName (std::string resource_name)
 
void EnableFinishEvent (bool enable=true)
 EnableFinishEvent() is intended to be called by the user in the constructor in order to tell JANA to call the provided FinishEvent method after all JEventProcessors have finished with a given event. More...
 
void EnableGetObjects (bool enable=true)
 
void EnablePreprocess (bool enable=true)
 
void SetNEvents (uint64_t nevents)
 
void SetNSkip (uint64_t nskip)
 
void DoInitialize ()
 
virtual void DoInit ()
 
void DoOpen (bool with_lock=true)
 
void DoClose (bool with_lock=true)
 
Result DoNext (std::shared_ptr< JEvent > event)
 
Result DoNextCompatibility (std::shared_ptr< JEvent > event)
 
void DoFinish (JEvent &event)
 
void Summarize (JComponentSummary &summary) const override
 
- Public Member Functions inherited from jana::components::JComponent
void SetLevel (JEventLevel level)
 
void SetCallbackStyle (CallbackStyle style)
 
void SetPrefix (std::string prefix)
 
void SetTypeName (std::string type_name)
 For convenience, we provide a NAME_OF_THIS macro so that the user doesn't have to store the type name as a string, because that could get out of sync if automatic refactoring tools are used.
 
JApplicationGetApplication () const
 
JLoggerGetLogger ()
 
std::string GetPrefix () const
 
JEventLevel GetLevel () const
 
std::string GetLoggerName () const
 
std::string GetPluginName () const
 
void SetLoggerName (std::string logger_name)
 
void SetPluginName (std::string plugin_name)
 
std::string GetTypeName () const
 
CallbackStyle GetCallbackStyle () const
 
Status GetStatus () const
 
void SetApplication (JApplication *app)
 
void SetLogger (JLogger logger)
 
template<typename F >
void CallWithJExceptionWrapper (std::string func_name, F func)
 
void RegisterParameter (ParameterBase *parameter)
 
void RegisterService (ServiceBase *service)
 
void ConfigureAllParameters (std::map< std::string, std::string > fields)
 

Static Public Member Functions

static std::string GetDescription ()
 

Additional Inherited Members

- Public Types inherited from JEventSource
enum class  Result {
  Success ,
  FailureTryAgain ,
  FailureFinished
}
 Result describes what happened the last time a GetEvent() was attempted. More...
 
enum class  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()
 
- Public Types inherited from jana::components::JComponent
enum class  Status {
  Uninitialized ,
  Initialized ,
  Opened ,
  Closed ,
  Finalized
}
 
enum class  CallbackStyle {
  LegacyMode ,
  ExpertMode ,
  DeclarativeMode
}
 
- Protected Member Functions inherited from jana::components::JHasOutputs
void RegisterOutput (OutputBase *output)
 
- Protected Attributes inherited from jana::components::JComponent
std::vector< ParameterBase * > m_parameters
 
std::vector< ServiceBase * > m_services
 
JEventLevel m_level = JEventLevel::PhysicsEvent
 
CallbackStyle m_callback_style = CallbackStyle::LegacyMode
 
std::string m_prefix
 
std::string m_plugin_name
 
std::string m_logger_name
 
std::string m_type_name
 
Status m_status = Status::Uninitialized
 
std::mutex m_mutex
 
JApplicationm_app = nullptr
 
JLogger m_logger
 
- Protected Attributes inherited from jana::components::JHasOutputs
std::vector< OutputBase * > m_outputs
 

Detailed Description

template<class MessageT>
class JStreamingEventSource< MessageT >

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.

Constructor & Destructor Documentation

◆ JStreamingEventSource()

template<class MessageT >
JStreamingEventSource< MessageT >::JStreamingEventSource ( std::unique_ptr< JTransport > &&  transport)
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.

Member Function Documentation

◆ Emit()

template<class MessageT >
Result JStreamingEventSource< MessageT >::Emit ( JEvent event)
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.

Reimplemented from JEventSource.


The documentation for this class was generated from the following file: