JANA2
C++ framework for multi-threaded data processing
JFactory Class Referenceabstract
Inheritance diagram for JFactory:
[legend]
Collaboration diagram for JFactory:
[legend]

Public Types

enum class  Status {
  Uninitialized ,
  Unprocessed ,
  Processed ,
  Inserted
}
 
enum class  CreationStatus {
  NotCreatedYet ,
  Created ,
  Inserted ,
  InsertedViaGetObjects ,
  NeverCreated
}
 
enum  JFactory_Flags_t {
  JFACTORY_NULL = 0x00 ,
  PERSISTENT = 0x01 ,
  WRITE_TO_OUTPUT = 0x02 ,
  NOT_OBJECT_OWNER = 0x04 ,
  REGENERATE = 0x08
}
 
- Public Types inherited from jana::components::JComponent
enum class  Status {
  Uninitialized ,
  Initialized ,
  Opened ,
  Closed ,
  Finalized
}
 
enum class  CallbackStyle {
  LegacyMode ,
  ExpertMode ,
  DeclarativeMode
}
 

Public Member Functions

 JFactory (std::string aName, std::string aTag="")
 
std::string GetName () const __attribute__((deprecated))
 
std::string GetTag () const
 
std::string GetObjectName () const
 
std::string GetFactoryName () const
 
Status GetStatus () const
 
CreationStatus GetCreationStatus () const
 
JCallGraphRecorder::JDataOrigin GetInsertOrigin () const
 If objects were placed here by JEvent::Insert() this records whether that call was made from a source or factory.
 
uint32_t GetPreviousRunNumber (void) const
 
void SetName (std::string objectName) __attribute__((deprecated))
 
void SetTag (std::string tag)
 
void SetObjectName (std::string objectName)
 
void SetFactoryName (std::string factoryName)
 
void SetStatus (Status status)
 
void SetCreationStatus (CreationStatus status)
 
void SetInsertOrigin (JCallGraphRecorder::JDataOrigin origin)
 Called automatically by JEvent::Insert() to records whether that call was made by a source or factory.
 
void SetPreviousRunNumber (uint32_t aRunNumber)
 
uint32_t GetFactoryFlags () const
 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) const
 Test if a flag (or set of flags) is set.
 
void SetPersistentFlag (bool persistent)
 
void SetNotOwnerFlag (bool not_owner)
 
void SetRegenerateFlag (bool regenerate)
 
void SetWriteToOutputFlag (bool write_to_output)
 
bool GetWriteToOutputFlag ()
 
JCallGraphRecorder::JDataSource GetDataSource () const
 Get data source value depending on how objects came to be here. (Used mainly by JEvent::Get() )
 
virtual std::type_index GetObjectType () const =0
 
virtual void ClearData ()=0
 
virtual void Init ()
 
virtual void BeginRun (const std::shared_ptr< const JEvent > &)
 
virtual void ChangeRun (const std::shared_ptr< const JEvent > &)
 
virtual void EndRun ()
 
virtual void Process (const std::shared_ptr< const JEvent > &)
 
virtual void Finish ()
 
virtual std::size_t GetNumObjects () const
 
template<typename S >
std::vector< S * > GetAs ()
 Access the encapsulated data, performing an upcast if necessary. More...
 
virtual void Create (const std::shared_ptr< const JEvent > &event)
 Create() calls JFactory::Init,BeginRun,Process in an invariant-preserving way without knowing the exact type of object contained. More...
 
void DoInit ()
 
void Summarize (JComponentSummary &summary) const override
 
virtual void Set (const std::vector< JObject * > &data)=0
 
virtual void Insert (JObject *data)=0
 
- 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)
 

Protected Attributes

std::string mObjectName
 
std::string mTag
 
uint32_t mFlags = WRITE_TO_OUTPUT
 
int32_t mPreviousRunNumber = -1
 
std::unordered_map< std::type_index, std::unique_ptr< JAny > > mUpcastVTable
 
Status mStatus = Status::Uninitialized
 
JCallGraphRecorder::JDataOrigin m_insert_origin = JCallGraphRecorder::ORIGIN_NOT_AVAILABLE
 
CreationStatus mCreationStatus = CreationStatus::NotCreatedYet
 
- 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
 

Member Function Documentation

◆ Create()

void JFactory::Create ( const std::shared_ptr< const JEvent > &  event)
virtual

Create() calls JFactory::Init,BeginRun,Process in an invariant-preserving way without knowing the exact type of object contained.

In order to access these objects when all you have is a JFactory*, use JFactory::GetAs().

Reimplemented in JFactoryPodioT< T >.

References TestFactoryFlag().

Referenced by JFactoryPodioT< T >::Create(), and JFactoryT< T >::CreateAndGetData().

◆ GetAs()

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.

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