JANA2
JEventSourceGeneratorT< T > Class Template Reference

This templated class is used to generate JEventSource based objects to handle reading events into JANA. More...

#include <JEventSourceGeneratorT.h>

Inheritance diagram for JEventSourceGeneratorT< T >:
Collaboration diagram for JEventSourceGeneratorT< T >:

Public Member Functions

 JEventSourceGeneratorT (JApplication *app=nullptr)
 
std::string GetType (void) const
 Return name of the source type this will generate.
 
std::string GetDescription (void) const
 Return description of the source type this will generate.
 
JEventSourceMakeJEventSource (std::string source)
 Create an instance of the source type this generates.
 
double CheckOpenable (std::string source)
 Check how likely a source of the type this generates is to read the specified source. More...
 
- Public Member Functions inherited from JEventSourceGenerator
 JEventSourceGenerator (JApplication *app=nullptr)
 

Protected Member Functions

void SetJApplication (JApplication *app)
 This is called by JEventSourceManager::AddJEventSourceGenerator which itself is called by JApplication::Add(JEventSourceGenerator*). More...
 
- Protected Member Functions inherited from JEventSourceGenerator
void SetJApplication (JApplication *app)
 This is called by JEventSourceManager::AddJEventSourceGenerator which itself is called by JApplication::Add(JEventSourceGenerator*). More...
 
void SetPlugin (std::string plugin_name)
 SetPlugin is called by JANA itself and should not be exposed to the user.
 
std::string GetPlugin () const
 GetPlugin is called by JANA itself and should not be exposed to the user.
 

Additional Inherited Members

- Public Attributes inherited from JEventSourceGenerator
friend JComponentManager
 
- Protected Attributes inherited from JEventSourceGenerator
JApplicationmApplication {nullptr}
 
std::string mPluginName
 

Detailed Description

template<typename T>
class JEventSourceGeneratorT< T >

This templated class is used to generate JEventSource based objects to handle reading events into JANA.

Multiple JEventSourceGenerator objects may exist in a given program, each representing a different input type. For example, one source may be used to read raw data while another may be used to read DST formats. A third may be used to read from a network connection for online applications. For each source specified in a given job, JANA will determine which JEventSource class to use to read from it. It does this via the CheckOpenable method of JEventSourceSourceGenerator.

A new instance of the JEventSource subclass will be created for each input source in the job. For example, if two files of the same type, are specified then the JEventSourceGenerator corresponding to that file type will be used to create two JEventSource objects.

REQUIREMENTS OF JEventSource SUBCLASS:

  • constructor that accepts (std::string, JApplication*)
  • static std::string GetDescription(void) method

NOTE ON CheckOpenable:

This method should "peek" at the source to see if it is one that it can open. It should return a value between 0 and 1 inclusive with 0 meaning "cannot open" and 1 meaning "absolutely can open". The check can be as simple as looking at the source name (e.g. does it have a specific suffix) or more involved (e.g. opening the file and checking for a magic header). Note that it should not be assumed that the source represents a file name. It could indicate a URL or how to connect to some other non-file source.

Member Function Documentation

template<typename T >
double JEventSourceGeneratorT< T >::CheckOpenable ( std::string  source)
inlinevirtual

Check how likely a source of the type this generates is to read the specified source.

This mechanism is to allow a single executable to read from multiple file types, each corresponding to a different JEventSource subclass. If you use only a single source type, then there is no need to override this. If you do need this functionality however, then override this in your code with something like:

template<> double JEventSourceGeneratorT<MyType>::CheckOpenable(std::string source) { ... }

Implements JEventSourceGenerator.

template<typename T >
void JEventSourceGeneratorT< T >::SetJApplication ( JApplication app)
inlineprotected

This is called by JEventSourceManager::AddJEventSourceGenerator which itself is called by JApplication::Add(JEventSourceGenerator*).

There should be no need to call it from anywhere else.


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