JANA2
JFactoryT< T > Class Template Reference
Inheritance diagram for JFactoryT< T >:
Collaboration diagram for JFactoryT< T >:

Public Types

using IteratorType = typename std::vector< T * >::const_iterator
 
using PairType = std::pair< IteratorType, IteratorType >
 
- Public Types inherited from JFactory
enum  JFactory_Flags_t {
  JFACTORY_NULL = 0x00,
  PERSISTENT = 0x01,
  WRITE_TO_OUTPUT = 0x02,
  NOT_OBJECT_OWNER = 0x04
}
 

Public Member Functions

 JFactoryT (const std::string &aName=JTypeInfo::demangle< T >(), const std::string &aTag="")
 
void Init () override
 
void ChangeRun (const std::shared_ptr< const JEvent > &aEvent) override
 
void Process (const std::shared_ptr< const JEvent > &aEvent) override
 
std::type_index GetObjectType (void) const override
 
PairType GetOrCreate (const std::shared_ptr< const JEvent > &event, JApplication *app, uint64_t run_number)
 GetOrCreate handles all the preconditions and postconditions involved in calling the user-defined Open(), ChangeRun(), and Process() methods. More...
 
void Set (std::vector< JObject * > &aData) override
 Please use the typed setters instead whenever possible.
 
void Insert (JObject *aDatum) override
 Please use the typed setters instead whenever possible.
 
void Set (const std::vector< T * > &aData)
 
void Set (std::vector< T * > &&aData)
 
void Insert (T *aDatum)
 
template<typename S >
void EnableGetAs ()
 EnableGetAs generates a vtable entry so that users may extract the contents of this JFactoryT from the type-erased JFactory. More...
 
void ClearData () override
 
void SetMetadata (JMetadata< T > metadata)
 Set the JFactory's metadata. More...
 
JMetadata< T > GetMetadata ()
 Get the JFactory's metadata. More...
 
- Public Member Functions inherited from JFactory
 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.
 
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 Attributes

std::vector< T * > mData
 
JMetadata< T > mMetadata
 
- Protected Attributes inherited from JFactory
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
 

Additional Inherited Members

- Protected Types inherited from JFactory
enum  Status {
  Uninitialized,
  Unprocessed,
  Processed,
  Inserted
}
 

Member Function Documentation

template<typename T >
template<typename S >
void JFactoryT< T >::EnableGetAs ( )

EnableGetAs generates a vtable entry so that users may extract the contents of this JFactoryT from the type-erased JFactory.

The user has to manually specify which upcasts to allow, and they have to do so for each instance. It is recommended to do so in the constructor. Note that EnableGetAs<T>() is called automatically.

template<typename T>
JMetadata<T> JFactoryT< T >::GetMetadata ( )
inline

Get the JFactory's metadata.

This is meant to be called by user during their JFactoryT::Process and also used by JEvent under the hood. Metadata will not be cleared on ClearData(), but will be destroyed when the JFactoryT is.

template<typename T>
PairType JFactoryT< T >::GetOrCreate ( const std::shared_ptr< const JEvent > &  event,
JApplication app,
uint64_t  run_number 
)
inline

GetOrCreate handles all the preconditions and postconditions involved in calling the user-defined Open(), ChangeRun(), and Process() methods.

These include making sure the JFactory JApplication is set, Init() is called exactly once, exceptions are tagged with the originating plugin and eventsource, ChangeRun() is called if and only if the run number changes, etc.

template<typename T>
void JFactoryT< T >::SetMetadata ( JMetadata< T >  metadata)
inline

Set the JFactory's metadata.

This is meant to be called by user during their JFactoryT::Process Metadata will not be cleared on ClearData(), but will be destroyed when the JFactoryT is.


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