JANA2
C++ framework for multi-threaded data processing
JFactorySet Class Reference

Public Member Functions

 JFactorySet (const std::vector< JFactoryGenerator * > &aFactoryGenerators)
 
virtual ~JFactorySet ()
 
bool Add (JFactory *aFactory)
 
bool Add (JMultifactory *multifactory)
 
void Print (void) const
 
void Release (void)
 Release() loops over all contained factories, clearing their data.
 
JFactoryGetFactory (const std::string &object_name, const std::string &tag="") const
 
template<typename T >
JFactoryT< T > * GetFactory (const std::string &tag="") const
 
std::vector< JFactory * > GetAllFactories () const
 
std::vector< JMultifactory * > GetAllMultifactories () const
 
template<typename T >
std::vector< JFactoryT< T > * > GetAllFactories () const
 
JEventLevel GetLevel () const
 
void SetLevel (JEventLevel level)
 

Protected Attributes

std::map< std::pair< std::type_index, std::string >, JFactory * > mFactories
 
std::map< std::pair< std::string, std::string >, JFactory * > mFactoriesFromString
 
std::vector< JMultifactory * > mMultifactories
 
bool mIsFactoryOwner = true
 
JEventLevel mLevel = JEventLevel::PhysicsEvent
 

Constructor & Destructor Documentation

◆ ~JFactorySet()

JFactorySet::~JFactorySet ( )
virtual

The destructor will delete any factories in the set, unless mIsFactoryOwner is set to false. The only time mIsFactoryOwner should/can be set false is when a JMultifactory is using a JFactorySet internally to manage its JMultifactoryHelpers.

Member Function Documentation

◆ Add() [1/2]

bool JFactorySet::Add ( JFactory aFactory)

Add a JFactory to this JFactorySet. The JFactorySet assumes ownership of this factory. If the JFactorySet already contains a JFactory with the same key, throw an exception and let the user figure out what to do. This scenario occurs when the user has multiple JFactory<T> producing the same T JObject, and is not distinguishing between them via tags.

Referenced by Add(), and JEvent::Insert().

◆ Add() [2/2]

bool JFactorySet::Add ( JMultifactory multifactory)

Add a JMultifactory to this JFactorySet. This JFactorySet takes ownership of its JMultifactoryHelpers, which was previously held by the JMultifactory.mHelpers JFactorySet. Ownership of the JMultifactory itself is shared among those helpers.

This is a little bit weird, but we are using a JFactorySet internally to JMultifactory in order to store and efficiently access its JMultifactoryHelpers. Ownership of the JMultifactoryHelpers is transferred to the enclosing JFactorySet.

References Add().


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