JANA2
C++ framework for multi-threaded data processing
|
JService is a trait indicating that an object can be shared among JANA components via a simple ServiceLocator. More...
#include <JServiceLocator.h>
Public Member Functions | |
template<typename T > | |
void | provide (std::shared_ptr< T > t) |
template<typename T > | |
std::shared_ptr< T > | get () |
void | wire_everything () |
JService is a trait indicating that an object can be shared among JANA components via a simple ServiceLocator.
It provides a callback interface for configuring itself when it depends on other JServices. JServiceLocator is a nexus for collecting, initializing, and retrieving JServices. This may be exposed via the JApplication facade, or used on its own. JServiceLocator uses shared-pointer semantics to ensure that JServices always get freed, but also don't get freed prematurely if a JApplication or JServiceLocator go out of scope.
|
inline |
Retrieve a JService. If acquire_services() has not yet been called, it will be. Usually called from Service::finalize(). It may be called from anywhere, but it is generally safer to retrieve the services we need during acquire_dependencies() and keep pointers to those, instead of keeping a pointer to the ServiceLocator itself. (This also makes it easier to migrate to dependency injection if we so desire)
|
inline |
Publish a Service to the ServiceLocator. This Service should have already been constructed, but not finalized. Users are intended to call this from InitPlugin() most of the time
|
inline |
Make sure that all Services have been finalized. This is not strictly necessary, but it makes user errors easier to understand, and it prevents Services from being unpredictably finalized later on, particularly during computation.