JANA2
JFactory Class Referenceabstract
Inheritance diagram for JFactory:
Collaboration diagram for JFactory:

Public Types

enum  JFactory_Flags_t {
  JFACTORY_NULL = 0x00,
  PERSISTENT = 0x01,
  WRITE_TO_OUTPUT = 0x02,
  NOT_OBJECT_OWNER = 0x04
}
 

Public Member Functions

 JFactory (std::string aName, std::string aTag="")
 
std::string GetName () const
 
std::string GetTag () const
 
uint32_t GetPreviousRunNumber (void) const
 
void SetPreviousRunNumber (uint32_t aRunNumber)
 
uint32_t GetFactoryFlags (void)
 Get all flags in the form of a single word.
 
void SetFactoryFlag (JFactory_Flags_t f)
 Set a flag (or flags)
 
void ClearFactoryFlag (JFactory_Flags_t f)
 Clear a flag (or flags)
 
bool TestFactoryFlag (JFactory_Flags_t f)
 Test if a flag (or set of flags) is set.
 
virtual std::type_index GetObjectType () const =0
 
virtual void ClearData ()=0
 
virtual void Init ()
 
virtual void ChangeRun (const std::shared_ptr< const JEvent > &aEvent)
 
virtual void Process (const std::shared_ptr< const JEvent > &aEvent)
 
template<typename T >
void Set (std::vector< T * > &items)
 
template<typename S >
std::vector< S * > GetAs ()
 Access the encapsulated data, performing an upcast if necessary. More...
 
void SetApplication (JApplication *app)
 JApplication setter. This is meant to be used under the hood.
 
JApplicationGetApplication ()
 JApplication getter. More...
 

Protected Types

enum  Status {
  Uninitialized,
  Unprocessed,
  Processed,
  Inserted
}
 

Protected Member Functions

virtual void Set (std::vector< JObject * > &data)=0
 
virtual void Insert (JObject *data)=0
 

Protected Attributes

std::string mPluginName
 
std::string mFactoryName
 
std::string mObjectName
 
std::string mTag
 
uint32_t mFlags = 0
 
uint32_t mPreviousRunNumber = -1
 
JApplicationmApp = nullptr
 
std::unordered_map< std::type_index, void * > mUpcastVTable
 
Status mStatus = Status::Uninitialized
 
std::mutex mMutex
 
std::once_flag mInitFlag
 

Member Function Documentation

JApplication* JFactory::GetApplication ( )
inline

JApplication getter.

This is meant to be called by user-defined JFactories which need to acquire parameter values or services from JFactory::Init()

template<typename S >
std::vector< S * > JFactory::GetAs ( )

Access the encapsulated data, performing an upcast if necessary.

This is useful for extracting data from all JFactories<T> where T extends a parent class S, such as JObject or TObject, in contexts where T is not known or it would introduce an unwanted coupling. The main application is for building DSTs.

Be aware of the following caveats:

  • The factory's object type must not use virtual inheritance.
  • If JFactory::Process hasn't already been called, this will return an empty vector. This will NOT call JFactory::Process.
  • Someone must call JFactoryT<T>::EnableGetAs<S>, preferably the constructor. Otherwise, this will return an empty vector.
  • If S isn't a base class of T, this will return an empty vector.

Referenced by TestFactoryFlag().

Here is the caller graph for this function:


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