The Gaudi Framework  v37r0 (b608885e)
DataObjectHandle< AnyDataWithViewWrapper< View, Owned > > Class Template Reference

specialization for AnyDataWithViewWrapper More...

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

Inheritance diagram for DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >:
Collaboration diagram for DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >:

Public Member Functions

View * get () const
 Retrieve object from transient data store. More...
 
View * getIfExists () const
 
const View * put (std::unique_ptr< AnyDataWithViewWrapper< View, Owned >> objectp) const
 Register object in transient store. More...
 
const View * put (Owned &&obj) const
 
std::optional< std::size_tsize () const
 Size of boxed item, if boxed item has a 'size' method. More...
 
std::string pythonRepr () const override
 
 DataObjectHandleBase (DataObjID k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
 
 DataObjectHandleBase (std::string k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
 
 DataObjectHandleBase (const DataObjectHandleBase &)=delete
 
 DataObjectHandleBase (DataObjectHandleBase &&)
 
template<class OWNER , class K , typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
 DataObjectHandleBase (OWNER *owner, Gaudi::DataHandle::Mode m, std::string name, K key={}, std::string doc="")
 Autodeclaring constructor with property name, mode, key and documentation. More...
 
- Public Member Functions inherited from DataObjectHandleBase
 DataObjectHandleBase (DataObjID k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
 
 DataObjectHandleBase (std::string k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
 
 ~DataObjectHandleBase () override
 
 DataObjectHandleBase (const DataObjectHandleBase &)=delete
 
 DataObjectHandleBase (DataObjectHandleBase &&)
 
DataObjectHandleBaseoperator= (const DataObjectHandleBase &)
 
template<class OWNER , class K , typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
 DataObjectHandleBase (OWNER *owner, Gaudi::DataHandle::Mode m, std::string name, K key={}, std::string doc="")
 Autodeclaring constructor with property name, mode, key and documentation. More...
 
bool isOptional () const
 Check if the data object declared is optional for the algorithm. More...
 
void setOptional (bool optional=true)
 
bool isValid () const
 
- Public Member Functions inherited from Gaudi::DataHandle
 DataHandle (DataObjID k, Mode a=Reader, IDataHandleHolder *owner=nullptr)
 
 DataHandle (DataObjID k, bool isCond, Mode a=Reader, IDataHandleHolder *owner=nullptr)
 
virtual ~DataHandle ()=default
 
virtual void setOwner (IDataHandleHolder *o)
 
virtual IDataHandleHolderowner () const
 
virtual Mode mode () const
 
virtual void setKey (DataObjID key) const
 
virtual void updateKey (std::string key) const
 
virtual const std::stringobjKey () const
 
virtual const DataObjIDfullKey () const
 
virtual void reset (bool)
 
virtual bool isCondition () const
 

Private Member Functions

AnyDataWithViewWrapper< View, Owned > * _get (bool mustExist) const
 

Private Attributes

bool m_goodType = false
 

Additional Inherited Members

- Public Types inherited from Gaudi::DataHandle
enum  Mode { Reader = 1 << 2, Writer = 1 << 4 }
 
using PropertyType = DataHandleProperty
 
- Protected Member Functions inherited from DataObjectHandleBase
bool init () override
 
DataObjectfetch () const
 
- Protected Attributes inherited from DataObjectHandleBase
SmartIF< IDataProviderSvcm_EDS
 
SmartIF< IMessageSvcm_MS
 
bool m_init = false
 
bool m_optional = false
 
std::atomic< bool > m_searchDone = false
 Whether the search part of the fetch method (so dealing with alt names was already executed or not. More...
 
std::mutex m_searchMutex
 A Mutex protecting the calls to the search part of the fetch method, so that we are sure that we only call it once. More...
 
- Protected Attributes inherited from Gaudi::DataHandle
DataObjID m_key = { "NONE" }
 The key of the object behind this DataHandle Although it may look strange to have it mutable, this can actually change in case the object had alternative names, and it should not be visible to the end user, for which the Handle is still the same. More...
 
IDataHandleHolderm_owner = nullptr
 
- Static Protected Attributes inherited from Gaudi::DataHandle
static const std::string default_type = "unknown_t"
 

Detailed Description

template<typename View, typename Owned>
class DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >

specialization for AnyDataWithViewWrapper

Definition at line 340 of file DataObjectHandle.h.

Member Function Documentation

◆ _get()

template<typename View , typename Owned >
AnyDataWithViewWrapper<View, Owned>* DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::_get ( bool  mustExist) const
inlineprivate

Definition at line 379 of file DataObjectHandle.h.

379  {
380  auto obj = fetch();
381  if ( !obj ) {
382  if ( mustExist ) {
383  throw GaudiException( "Cannot retrieve " + objKey() + " from transient store.",
384  m_owner ? owner()->name() : "no owner", StatusCode::FAILURE );
385 
386  } else {
387  return nullptr;
388  }
389  }
390  if ( !m_goodType ) m_goodType = ::details::verifyType<AnyDataWithViewWrapper<View, Owned>>( obj );
391  return static_cast<AnyDataWithViewWrapper<View, Owned>*>( obj );
392  }

◆ DataObjectHandleBase() [1/5]

template<typename View , typename Owned >
DataObjectHandleBase::DataObjectHandleBase
delete

◆ DataObjectHandleBase() [2/5]

template<typename View , typename Owned >
DataObjectHandleBase::DataObjectHandleBase

Definition at line 43 of file DataObjectHandleBase.cpp.

27  : Gaudi::DataHandle( other )
28  , m_EDS( std::move( other.m_EDS ) )
29  , m_MS( std::move( other.m_MS ) )
30  , m_init( other.m_init )
31  , m_optional( other.m_optional )
32  , m_searchDone( other.m_searchDone.load() ) {
33  m_owner->declare( *this );
34 }

◆ DataObjectHandleBase() [3/5]

template<typename View , typename Owned >
DataObjectHandleBase::DataObjectHandleBase

Definition at line 38 of file DataObjectHandleBase.cpp.

52  : Gaudi::DataHandle( std::move( k ), a, owner ) {
53  m_owner->declare( *this );
54 }

◆ DataObjectHandleBase() [4/5]

template<typename View , typename Owned >
template<class OWNER , class K , typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
DataObjectHandleBase::DataObjectHandleBase ( class OWNER  ,
class ,
typename  = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>> 
)
inline

Autodeclaring constructor with property name, mode, key and documentation.

Note
the use std::enable_if is required to avoid ambiguities

Definition at line 49 of file DataObjectHandleBase.h.

49  {},
50  std::string doc = "" )
52  auto p = owner->declareProperty( std::move( name ), *this, std::move( doc ) );
53  p->template setOwnerType<OWNER>();
54  }

◆ DataObjectHandleBase() [5/5]

template<typename View , typename Owned >
DataObjectHandleBase::DataObjectHandleBase

Definition at line 39 of file DataObjectHandleBase.cpp.

59  : DataObjectHandleBase( DataObjID{ std::move( k ) }, a, owner ) {}

◆ get()

template<typename View , typename Owned >
View* DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::get ( ) const
inline

Retrieve object from transient data store.

Definition at line 347 of file DataObjectHandle.h.

347 { return &_get( true )->getData(); }

◆ getIfExists()

template<typename View , typename Owned >
View* DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::getIfExists ( ) const
inline

Definition at line 348 of file DataObjectHandle.h.

348  {
349  auto data = _get( false );
350  return data ? &data->getData() : nullptr;
351  }

◆ put() [1/2]

template<typename View , typename Owned >
const View* DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::put ( Owned &&  obj) const
inline

Definition at line 363 of file DataObjectHandle.h.

363  {
364  return put( std::make_unique<AnyDataWithViewWrapper<View, Owned>>( std::move( obj ) ) );
365  }

◆ put() [2/2]

template<typename View , typename Owned >
const View* DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::put ( std::unique_ptr< AnyDataWithViewWrapper< View, Owned >>  objectp) const
inline

Register object in transient store.

Definition at line 356 of file DataObjectHandle.h.

356  {
357  assert( m_init );
358  if ( auto sc = m_EDS->registerObject( objKey(), objectp.get() ); sc.isFailure() ) {
359  throw GaudiException( "Error in put of " + objKey(), "DataObjectHandle<AnyDataWithViewWrapper<T>::put", sc );
360  }
361  return &objectp.release()->getData();
362  }

◆ pythonRepr()

template<typename View , typename Owned >
std::string DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::pythonRepr ( ) const
inlineoverridevirtual

Reimplemented from Gaudi::DataHandle.

Definition at line 372 of file DataObjectHandle.h.

372  {
373  auto repr = DataObjectHandleBase::pythonRepr();
374  boost::replace_all( repr, default_type, System::typeinfoName( typeid( View ) ) );
375  return repr;
376  }

◆ size()

template<typename View , typename Owned >
std::optional<std::size_t> DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::size ( ) const
inline

Size of boxed item, if boxed item has a 'size' method.

Definition at line 370 of file DataObjectHandle.h.

370 { return _get()->size(); }

Member Data Documentation

◆ m_goodType

template<typename View , typename Owned >
bool DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::m_goodType = false
mutableprivate

Definition at line 393 of file DataObjectHandle.h.


The documentation for this class was generated from the following file:
std::string
STL class.
std::move
T move(T... args)
bug_34121.name
name
Definition: bug_34121.py:20
Gaudi::DataHandle::default_type
static const std::string default_type
Definition: DataHandle.h:83
DataObjectHandleBase::m_EDS
SmartIF< IDataProviderSvc > m_EDS
Definition: DataObjectHandleBase.h:70
DataObjectHandleBase::m_MS
SmartIF< IMessageSvc > m_MS
Definition: DataObjectHandleBase.h:71
GaudiException
Definition: GaudiException.h:31
DataObjectHandleBase::m_optional
bool m_optional
Definition: DataObjectHandleBase.h:74
Gaudi::DataHandle
Definition: DataHandle.h:38
std::unique_ptr::get
T get(T... args)
std::unique_ptr::release
T release(T... args)
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:313
IDataHandleHolder::declare
virtual void declare(Gaudi::DataHandle &)=0
Gaudi::DataHandle::owner
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:53
DataObjectHandleBase::m_init
bool m_init
Definition: DataObjectHandleBase.h:73
DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::_get
AnyDataWithViewWrapper< View, Owned > * _get(bool mustExist) const
Definition: DataObjectHandle.h:379
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:108
Gaudi::DataHandle::objKey
virtual const std::string & objKey() const
Definition: DataHandle.h:60
Gaudi::DataHandle::m_owner
IDataHandleHolder * m_owner
Definition: DataHandle.h:81
DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::m_goodType
bool m_goodType
Definition: DataObjectHandle.h:393
AnyDataWithViewWrapper
Definition: AnyDataWrapper.h:55
DataObjID
Definition: DataObjID.h:47
DataObjectHandleBase::fetch
DataObject * fetch() const
Definition: DataObjectHandleBase.cpp:65
DataObjectHandleBase::m_searchDone
std::atomic< bool > m_searchDone
Whether the search part of the fetch method (so dealing with alt names was already executed or not.
Definition: DataObjectHandleBase.h:81
Gaudi::DataHandle::pythonRepr
virtual std::string pythonRepr() const
Definition: DataHandle.cpp:19
DataObjectHandleBase::DataObjectHandleBase
DataObjectHandleBase(DataObjID k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
Definition: DataObjectHandleBase.cpp:51
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
DataObjectHandle< AnyDataWithViewWrapper< View, Owned > >::put
const View * put(std::unique_ptr< AnyDataWithViewWrapper< View, Owned >> objectp) const
Register object in transient store.
Definition: DataObjectHandle.h:356
ProduceConsume.key
key
Definition: ProduceConsume.py:81