![]() |
The Gaudi Framework
master (ff829712)
|
Simple implementation of a smart pointer with different values for different event contexts (slots). More...
#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/ContextSpecificPtr.h>
Public Member Functions | |
T * | get () const |
Return the pointer for the current context (null for a new context). | |
T *& | set (T *ptr) |
Set the pointer for the current context. | |
T *& | operator= (T *ptr) |
Assignment operator (. | |
bool | isValid () const |
Return true if the pointer is not null. | |
operator bool () const | |
Conversion to boolean (. | |
bool | operator== (T *rhs) const |
Comparison with another pointer. | |
T & | operator* () |
Dereference operators. | |
const T & | operator* () const |
T * | operator-> () |
const T * | operator-> () const |
Private Types | |
typedef std::unordered_map< ContextIdType, T * > | StorageType |
Type used for the internal storage. | |
StorageType | m_ptrs |
Internal storage for the different internal pointers. | |
std::mutex | m_ptrs_lock |
Mutex for the m_ptrs container. | |
void | clear () |
Non thread-safe methods. | |
template<class Mapper> | |
auto | accumulate (Mapper f, std::invoke_result_t< Mapper, const T * > init) const -> decltype(init) |
Taking a function f that from a T* produces a value, return the sum of all the values corresponding to the contained pointers using init as first value. | |
template<class Mapper, class BinaryOperation> | |
auto | accumulate (Mapper f, std::invoke_result_t< Mapper, const T * > init, BinaryOperation op) const -> decltype(init) |
Taking a function f that from a T* produces a value, return the accumulated result, through the operation 'op', of all the values corresponding to the contained pointers using init as first value. | |
template<class F> | |
void | for_each (F f) const |
Call a function on each contained pointer. | |
template<class F> | |
void | for_each (F f) |
Call a function on each contained pointer. (non-const version) | |
template<class F> | |
void | for_all (F f) const |
Call a function on each element, passing slot# as well. | |
template<class F> | |
void | for_all (F f) |
void | deleteAll () |
Simple implementation of a smart pointer with different values for different event contexts (slots).
When the copy for a new context is requested, the returned pointer is null.
The interface is meant to allow for a drop-in replacement for regular pointers. It's still responsibility of the user to delete the memory associated to the pointers.
Definition at line 39 of file ContextSpecificPtr.h.
|
private |
Type used for the internal storage.
Definition at line 42 of file ContextSpecificPtr.h.
|
inline |
Taking a function f that from a T* produces a value, return the sum of all the values corresponding to the contained pointers using init as first value.
Definition at line 84 of file ContextSpecificPtr.h.
|
inline |
Taking a function f that from a T* produces a value, return the accumulated result, through the operation 'op', of all the values corresponding to the contained pointers using init as first value.
Definition at line 92 of file ContextSpecificPtr.h.
|
inline |
Non thread-safe methods.
Set to null all the used pointers.
Definition at line 78 of file ContextSpecificPtr.h.
|
inline |
Definition at line 126 of file ContextSpecificPtr.h.
|
inline |
Definition at line 121 of file ContextSpecificPtr.h.
|
inline |
Call a function on each element, passing slot# as well.
Definition at line 116 of file ContextSpecificPtr.h.
|
inline |
Call a function on each contained pointer. (non-const version)
Definition at line 109 of file ContextSpecificPtr.h.
|
inline |
Call a function on each contained pointer.
Definition at line 102 of file ContextSpecificPtr.h.
|
inline |
Return the pointer for the current context (null for a new context).
Definition at line 46 of file ContextSpecificPtr.h.
|
inline |
Return true if the pointer is not null.
Definition at line 60 of file ContextSpecificPtr.h.
|
inline |
Conversion to boolean (.
Definition at line 63 of file ContextSpecificPtr.h.
|
inline |
|
inline |
Definition at line 70 of file ContextSpecificPtr.h.
|
inline |
Definition at line 71 of file ContextSpecificPtr.h.
|
inline |
Definition at line 72 of file ContextSpecificPtr.h.
|
inline |
Assignment operator (.
Definition at line 57 of file ContextSpecificPtr.h.
|
inline |
Comparison with another pointer.
Definition at line 66 of file ContextSpecificPtr.h.
|
inline |
Set the pointer for the current context.
Definition at line 51 of file ContextSpecificPtr.h.
|
mutableprivate |
Internal storage for the different internal pointers.
Definition at line 135 of file ContextSpecificPtr.h.
|
mutableprivate |
Mutex for the m_ptrs container.
Definition at line 137 of file ContextSpecificPtr.h.