![]() |
The Gaudi Framework
v30r0 (c919700c)
|
Simple implementation of a smart pointer with different values for different event contexts (slots). More...
#include <GaudiKernel/ContextSpecificPtr.h>
Public Member Functions | |
T * | get () const |
Return the pointer for the current context (null for a new context). More... | |
T *& | set (T *ptr) |
Set the pointer for the current context. More... | |
T *& | operator= (T *ptr) |
Assignment operator (. More... | |
bool | isValid () const |
Return true if the pointer is not null. More... | |
operator bool () const | |
Conversion to boolean (. More... | |
bool | operator== (T *rhs) const |
Comparison with another pointer. More... | |
T & | operator* () |
Dereference operators. More... | |
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. More... | |
StorageType | m_ptrs |
Internal storage for the different internal pointers. More... | |
std::mutex | m_ptrs_lock |
Mutex for the m_ptrs container. More... | |
void | clear () |
Non thread-safe methods. More... | |
template<class Mapper > | |
std::result_of< Mapper(const T *)>::type | accumulate (Mapper f, typename std::result_of< Mapper(const T *)>::type init) const |
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. More... | |
template<class Mapper , class BinaryOperation > | |
std::result_of< Mapper(const T *)>::type | accumulate (Mapper f, typename std::result_of< Mapper(const T *)>::type init, BinaryOperation op) const |
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. More... | |
template<class F > | |
void | for_each (F f) const |
Call a function on each contained pointer. More... | |
template<class F > | |
void | for_each (F f) |
Call a function on each contained pointer. (non-const version) More... | |
template<class F > | |
void | for_all (F f) const |
Call a function on each element, passing slot# as well. More... | |
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 32 of file ContextSpecificPtr.h.
|
private |
Type used for the internal storage.
Definition at line 36 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 81 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 74 of file ContextSpecificPtr.h.
|
inline |
Definition at line 132 of file ContextSpecificPtr.h.
|
inline |
Call a function on each element, passing slot# as well.
Definition at line 120 of file ContextSpecificPtr.h.
|
inline |
Definition at line 126 of file ContextSpecificPtr.h.
|
inline |
Call a function on each contained pointer.
Definition at line 104 of file ContextSpecificPtr.h.
|
inline |
Call a function on each contained pointer. (non-const version)
Definition at line 112 of file ContextSpecificPtr.h.
|
inline |
Return the pointer for the current context (null for a new context).
Definition at line 40 of file ContextSpecificPtr.h.
|
inline |
Return true if the pointer is not null.
Definition at line 56 of file ContextSpecificPtr.h.
|
inline |
Conversion to boolean (.
Definition at line 59 of file ContextSpecificPtr.h.
|
inline |
|
inline |
Definition at line 66 of file ContextSpecificPtr.h.
|
inline |
Definition at line 67 of file ContextSpecificPtr.h.
|
inline |
Definition at line 68 of file ContextSpecificPtr.h.
|
inline |
|
inline |
Comparison with another pointer.
Definition at line 62 of file ContextSpecificPtr.h.
|
inline |
Set the pointer for the current context.
Definition at line 46 of file ContextSpecificPtr.h.
|
mutableprivate |
Internal storage for the different internal pointers.
Definition at line 142 of file ContextSpecificPtr.h.
|
mutableprivate |
Mutex for the m_ptrs container.
Definition at line 144 of file ContextSpecificPtr.h.