The Gaudi Framework  master (ff829712)
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.
 
 operator T& ()
 
 operator T& () const
 
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)
 

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 169 of file ContextSpecificPtr.h.

169{ 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 174 of file ContextSpecificPtr.h.

174 {
175 return m_ptr.accumulate( []( const T* p ) { return *p; }, init, op );
176 }

◆ for_all() [1/2]

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

Definition at line 196 of file ContextSpecificPtr.h.

196 {
197 m_ptr.for_all( [&f]( size_t s, T* p ) { f( s, *p ); } );
198 }

◆ 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 192 of file ContextSpecificPtr.h.

192 {
193 m_ptr.for_all( [&f]( size_t s, const T* p ) { f( s, *p ); } );
194 }

◆ 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 186 of file ContextSpecificPtr.h.

186 {
187 m_ptr.for_each( [&f]( T* p ) { f( *p ); } );
188 }

◆ 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 180 of file ContextSpecificPtr.h.

180 {
181 m_ptr.for_each( [&f]( const T* p ) { f( *p ); } );
182 }

◆ operator T&() [1/2]

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

Definition at line 155 of file ContextSpecificPtr.h.

155 {
156 if ( !m_ptr ) m_ptr = new T( m_proto );
157 return *m_ptr;
158 }

◆ operator T&() [2/2]

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

Definition at line 160 of file ContextSpecificPtr.h.

160 {
161 if ( !m_ptr ) m_ptr = new T( m_proto );
162 return *m_ptr;
163 }

◆ operator=()

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

Assignment operator.

Definition at line 166 of file ContextSpecificPtr.h.

166{ return (T&)( *this ) = other; }

Member Data Documentation

◆ m_proto

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

Prototype value.

Definition at line 205 of file ContextSpecificPtr.h.

205{};

◆ m_ptr

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

Internal implementation.

Definition at line 207 of file ContextSpecificPtr.h.


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