The Gaudi Framework  master (e68eea06)
Loading...
Searching...
No Matches
Gaudi::Hive::ContextSpecificData< T > Class Template Reference

Implementation of a context specific storage accessible as a sort of smart reference class. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/ContextSpecificPtr.h>

Collaboration diagram for Gaudi::Hive::ContextSpecificData< T >:

Public Member Functions

 ContextSpecificData (T proto={})
 Constructor with prototype value.
 
 ~ContextSpecificData ()
 Destructor.
 
T & get () const
 Access contained value.
 
T & operator= (const T &other)
 Assignment operator.
 
accumulate (T init) const
 Return the sum of all the contained values using init as first value.
 
template<class T1, class BinaryOperation>
T1 accumulate (T1 init, BinaryOperation op) const
 Return the accumulated result, through the operation 'op', of all the contained values using init as first value.
 
template<class F>
void for_each (F f) const
 Call a function on each contained value.
 
template<class F>
void for_each (F f)
 Call a function on each contained value. (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)
 
 operator T& ()
 Conversion and dereference operators.
 
 operator const T & () const
 
ContextSpecificPtr< T > & operator-> ()
 
const ContextSpecificPtr< T > & operator-> () const
 

Private Member Functions

 ContextSpecificData (const ContextSpecificData &)=delete
 

Private Attributes

m_proto = {}
 Prototype value.
 
ContextSpecificPtr< T > m_ptr
 Internal implementation.
 

Detailed Description

template<typename T>
class Gaudi::Hive::ContextSpecificData< T >

Implementation of a context specific storage accessible as a sort of smart reference class.

New values are created from the prototype passed to the constructor.

Definition at line 147 of file ContextSpecificPtr.h.

Constructor & Destructor Documentation

◆ ContextSpecificData() [1/2]

template<typename T>
Gaudi::Hive::ContextSpecificData< T >::ContextSpecificData ( T proto = {})
inline

Constructor with prototype value.

Definition at line 150 of file ContextSpecificPtr.h.

150{} ) : m_proto( std::move( proto ) ) {}
Implementation of a context specific storage accessible as a sort of smart reference class.

◆ ~ContextSpecificData()

template<typename T>
Gaudi::Hive::ContextSpecificData< T >::~ContextSpecificData ( )
inline

Destructor.

Definition at line 153 of file ContextSpecificPtr.h.

153{ m_ptr.deleteAll(); }
ContextSpecificPtr< T > m_ptr
Internal implementation.

◆ ContextSpecificData() [2/2]

template<typename T>
Gaudi::Hive::ContextSpecificData< T >::ContextSpecificData ( const ContextSpecificData< T > & )
privatedelete

Member Function Documentation

◆ accumulate() [1/2]

template<typename T>
T Gaudi::Hive::ContextSpecificData< T >::accumulate ( T init) const
inline

Return the sum of all the contained values using init as first value.

Definition at line 179 of file ContextSpecificPtr.h.

179{ return accumulate( init, std::plus<>() ); }
T accumulate(T init) const
Return the sum of all the contained values using init as first value.

◆ accumulate() [2/2]

template<typename T>
template<class T1, class BinaryOperation>
T1 Gaudi::Hive::ContextSpecificData< T >::accumulate ( T1 init,
BinaryOperation op ) const
inline

Return the accumulated result, through the operation 'op', of all the contained values using init as first value.

Definition at line 184 of file ContextSpecificPtr.h.

184 {
185 return m_ptr.accumulate( []( const T* p ) { return *p; }, init, op );
186 }

◆ for_all() [1/2]

template<typename T>
template<class F>
void Gaudi::Hive::ContextSpecificData< T >::for_all ( F f)
inline

Definition at line 206 of file ContextSpecificPtr.h.

206 {
207 m_ptr.for_all( [&f]( size_t s, T* p ) { f( s, *p ); } );
208 }

◆ for_all() [2/2]

template<typename T>
template<class F>
void Gaudi::Hive::ContextSpecificData< T >::for_all ( F f) const
inline

Call a function on each element, passing slot# as well.

Definition at line 202 of file ContextSpecificPtr.h.

202 {
203 m_ptr.for_all( [&f]( size_t s, const T* p ) { f( s, *p ); } );
204 }

◆ for_each() [1/2]

template<typename T>
template<class F>
void Gaudi::Hive::ContextSpecificData< T >::for_each ( F f)
inline

Call a function on each contained value. (non-const version)

Definition at line 196 of file ContextSpecificPtr.h.

196 {
197 m_ptr.for_each( [&f]( T* p ) { f( *p ); } );
198 }

◆ for_each() [2/2]

template<typename T>
template<class F>
void Gaudi::Hive::ContextSpecificData< T >::for_each ( F f) const
inline

Call a function on each contained value.

Definition at line 190 of file ContextSpecificPtr.h.

190 {
191 m_ptr.for_each( [&f]( const T* p ) { f( *p ); } );
192 }

◆ get()

template<typename T>
T & Gaudi::Hive::ContextSpecificData< T >::get ( ) const
inline

Access contained value.

Definition at line 156 of file ContextSpecificPtr.h.

156 {
157 if ( !m_ptr ) m_ptr.set( new T( m_proto ) );
158 return *m_ptr;
159 }

◆ operator const T &()

template<typename T>
Gaudi::Hive::ContextSpecificData< T >::operator const T & ( ) const
inline

Definition at line 163 of file ContextSpecificPtr.h.

163{ return get(); }
T & get() const
Access contained value.

◆ operator T&()

template<typename T>
Gaudi::Hive::ContextSpecificData< T >::operator T& ( )
inline

Conversion and dereference operators.

Definition at line 162 of file ContextSpecificPtr.h.

162{ return get(); }

◆ operator->() [1/2]

template<typename T>
ContextSpecificPtr< T > & Gaudi::Hive::ContextSpecificData< T >::operator-> ( )
inline

Definition at line 165 of file ContextSpecificPtr.h.

165 {
166 get(); // ensure there is a value for this thread
167 return m_ptr;
168 }

◆ operator->() [2/2]

template<typename T>
const ContextSpecificPtr< T > & Gaudi::Hive::ContextSpecificData< T >::operator-> ( ) const
inline

Definition at line 169 of file ContextSpecificPtr.h.

169 {
170 get(); // ensure there is a value for this thread
171 return m_ptr;
172 }

◆ operator=()

template<typename T>
T & Gaudi::Hive::ContextSpecificData< T >::operator= ( const T & other)
inline

Assignment operator.

Definition at line 176 of file ContextSpecificPtr.h.

176{ return static_cast<T&>( *this ) = other; }

Member Data Documentation

◆ m_proto

template<typename T>
T Gaudi::Hive::ContextSpecificData< T >::m_proto = {}
private

Prototype value.

Definition at line 215 of file ContextSpecificPtr.h.

215{};

◆ m_ptr

template<typename T>
ContextSpecificPtr<T> Gaudi::Hive::ContextSpecificData< T >::m_ptr
mutableprivate

Internal implementation.

Definition at line 217 of file ContextSpecificPtr.h.


The documentation for this class was generated from the following file: