JANA2
C++ framework for multi-threaded data processing
Loading...
Searching...
No Matches
JService Struct Reference
Inheritance diagram for JService:
[legend]
Collaboration diagram for JService:
[legend]

Public Member Functions

virtual ~JService ()=default
 JServices may require other JServices, which may be loaded out of order from different plugins.
 
void DoInit (JServiceLocator *)
 
virtual void acquire_services (JServiceLocator *)
 
- 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 ()
 
void Wire (JApplication *app)
 
bool IsEnabled () const
 
void SetEnabled (bool is_enabled)
 
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
 
virtual void Summarize (JComponentSummary &) const
 
CallbackStyle GetCallbackStyle () const
 
void SetApplication (JApplication *app)
 
void SetLogger (JLogger logger)
 
template<typename F >
void CallWithJExceptionWrapper (std::string func_name, F func)
 
void DoInit ()
 
virtual void Init ()
 
void RegisterParameter (ParameterBase *parameter)
 
void RegisterService (ServiceBase *service)
 
const std::vector< ParameterBase * > GetAllParameters () const
 

Additional Inherited Members

- Public Types inherited from jana::components::JComponent
enum class  CallbackStyle {
  LegacyMode ,
  ExpertMode
}
 
- 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
 
std::atomic_bool m_is_initialized {false}
 
std::atomic_bool m_is_finalized {false}
 
std::mutex m_mutex
 
JApplicationm_app = nullptr
 
JLogger m_logger
 
bool m_is_enabled = true
 

Constructor & Destructor Documentation

◆ ~JService()

virtual JService::~JService ( )
virtualdefault

JServices may require other JServices, which may be loaded out of order from different plugins.

For this reason, initialization of JServices is delayed until all plugins are loaded. Suppose you are writing Service B which depends on Service A. To acquire A during B's initialization, you should either declare a Service<A> m_a_svc{this} helper member, or fetch it manually by calling GetApplication()->GetService<A>() from inside B::Init(). Either way, the JServices will be initialized recursively and in the correct order.

Note that historically JServices used the acquire_services() callback instead of Init(). While acquire_services hasn't been deprecated yet, it is on the roadmap, so we strongly recommend you override Init() instead.

Note: Don't call JApplication::GetService<SvcT>() or JServiceLocator::get<SvcT>() from InitPlugin()!


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