Typedefs | |
typedef int | context_t |
Abstraction of a context type. | |
Functions | |
context_t | generate () |
generate new unique context value, never returns 0 value. | |
void | set (context_t ctx) |
Set the context. | |
context_t | get () |
Get current context, returns 0 if context was not set yet. | |
psana::Context::context_t | generate () |
generate new unique context value, never returns 0 value. | |
void | set (psana::Context::context_t ctx) |
Set the context. | |
psana::Context::context_t | get () |
Get current context, returns 0 if context was not set yet. |
There could be several instances of the psana framework (including separate sets of modules and separate configurations) in one application. Some services need to know which framework instance they serve, for example configuration service needs to provide different set of parameters for modules in different frameworks. To simplify implementation of user modules we want to avoid passing information about current framework instance from framework down to modules. Instead we use concept of context to implement indirect notification of the clients about current context.
The context is implemented as a global object keeping some abstract values that are unique for different frameworks (index of a framework instance could be used for example). This global object is set by framework instance during initialization. Any object that needs to know context should copy its value and use it later to identify framework instance. Constructor of a module is one good place where the context can be checked. After framework initialization it is never guaranteed that context could be updated.
NOTE: current implementation not thread safe and should not be used from multiple threads.
This software was developed for the LCLS project. If you use all or part of it, please give an appropriate acknowledgment.
typedef int psana::Context::context_t |
context_t psana::Context::generate | ( | ) |
generate new unique context value, never returns 0 value.
Definition at line 43 of file Context.cpp.
References g_next.
void psana::Context::set | ( | context_t | ctx | ) |
Set the context.
Definition at line 50 of file Context.cpp.
References g_current.
Referenced by psana::PSAna::dataSource(), and psana::PSAna::PSAna().
context_t psana::Context::get | ( | ) |
Get current context, returns 0 if context was not set yet.
Definition at line 57 of file Context.cpp.
References g_current.
psana::Context::context_t psana::Context::generate | ( | ) |
generate new unique context value, never returns 0 value.
Definition at line 43 of file Context.cpp.
References g_next.
void psana::Context::set | ( | psana::Context::context_t | ctx | ) |
Set the context.
Definition at line 50 of file Context.cpp.
References g_current.
Referenced by psana::PSAna::dataSource(), and psana::PSAna::PSAna().
psana::Context::context_t psana::Context::get | ( | ) |
Get current context, returns 0 if context was not set yet.
Definition at line 57 of file Context.cpp.
References g_current.