Go to the documentation of this file.
   20 #include <boost/algorithm/string/replace.hpp> 
   21 #include <type_traits> 
   29   template <
typename Range, 
typename StorageType>
 
   31     auto c = 
static_cast<const StorageType*
>( obj );
 
   32     if ( !
c ) 
return Range();
 
   36     auto last   = 
end( *
c );
 
   37     auto _first = 
reinterpret_cast<typename Range::const_iterator*
>( &first );
 
   38     auto _last  = 
reinterpret_cast<typename Range::const_iterator*
>( &last );
 
   39     return Range( *_first, *_last );
 
   42   template <
typename ValueType, 
typename Range = Gaudi::Range_<
typename ValueType::ConstVector>>
 
   44     using Selection = 
typename ValueType::Selection;
 
   45     auto sel        = 
dynamic_cast<const Selection*
>( obj );
 
   46     if ( 
sel ) 
return &make_range<Range, typename ValueType::Selection>;
 
   47     auto con = 
dynamic_cast<std::add_const_t<typename ValueType::Container>*
>( obj );
 
   48     if ( con ) 
return &make_range<Range, typename ValueType::Container>;
 
   54     using Type = std::add_const_t<T>;
 
   55     assert( dataObj != 
nullptr );
 
   56     auto obj = 
dynamic_cast<Type*
>( dataObj );
 
   62                                 " and is different from the one of the object in the store which is " +
 
   66     assert( obj == 
static_cast<Type*
>( dataObj ) );
 
   70   template <Gaudi::DataHandle::Mode, 
typename T, 
typename U>
 
   73         std::conditional_t<std::is_base_of_v<DataObject, T> && std::is_same_v<T, U>, T,
 
   77   template <
typename T, 
typename U>
 
   81   template <
typename T, 
typename U>
 
   85   template <
typename T, 
typename U>
 
   87     using type = std::optional<Gaudi::NamedRange_<T>>;
 
   90   template <Gaudi::DataHandle::Mode mode, 
typename T, 
typename U = T>
 
  109 template <
typename T>
 
  128   bool exist()
 const { 
return get( 
false ) != 
nullptr; }
 
  140   [[deprecated( 
"please pass a std::unique_ptr instead of a raw pointer" )]] T* 
put( T* 
object )
 const {
 
  151   T*           
get( 
bool mustExist ) 
const;
 
  164 template <
typename T>
 
  166   auto dataObj = 
fetch();
 
  169       throw GaudiException( 
"Cannot retrieve \'" + objKey() + 
"\' from transient store.",
 
  174   if ( !m_goodType ) m_goodType = ::details::verifyType<T>( dataObj );
 
  175   return static_cast<T*
>( dataObj );
 
  179 template <
typename T>
 
  182   StatusCode sc = m_EDS->registerObject( objKey(), objectp.
get() );
 
  183   if ( !sc.
isSuccess() ) { 
throw GaudiException( 
"Error in put of " + objKey(), 
"DataObjectHandle<T>::put", sc ); }
 
  188 template <
typename T>
 
  190   T* obj = 
get( 
false );
 
  191   return obj ? obj : 
put( std::make_unique<T>() );
 
  197 template <
typename T>
 
  200   using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
 
  217   mutable ::details::Converter_t<Range> m_converter = 
nullptr;
 
  220 template <
typename ValueType>
 
  222   auto dataObj = 
fetch();
 
  224     throw GaudiException( 
"Cannot retrieve \'" + objKey() + 
"\' from transient store.",
 
  227   if ( !m_converter ) {
 
  228     m_converter = ::details::select_range_converter<ValueType>( dataObj );
 
  229     if ( !m_converter ) {
 
  231                                 ")" + 
" cannot be obtained from object in event store" + 
" (" +
 
  236   return ( *m_converter )( dataObj );
 
  242 template <
typename T>
 
  245   using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
 
  262   mutable ::details::Converter_t<Range> m_converter = 
nullptr;
 
  265 template <
typename ValueType>
 
  267   auto dataObj = 
fetch();
 
  269     throw GaudiException( 
"Cannot retrieve \'" + objKey() + 
"\' from transient store.",
 
  272   if ( !m_converter ) {
 
  273     m_converter = ::details::select_range_converter<ValueType, Range>( dataObj );
 
  274     if ( !m_converter ) {
 
  276                                 ")" + 
" cannot be obtained from object in event store" + 
" (" +
 
  281   return ( *m_converter )( dataObj );
 
  288 template <
typename T>
 
  291   using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
 
  299   std::optional<Range> 
get() 
const;
 
  308   mutable ::details::Converter_t<Range> m_converter = 
nullptr;
 
  311 template <
typename ValueType>
 
  313   auto dataObj = 
fetch();
 
  314   if ( !dataObj ) 
return std::nullopt;
 
  315   if ( !m_converter ) {
 
  316     m_converter = ::details::select_range_converter<ValueType, Range>( dataObj );
 
  317     if ( !m_converter ) {
 
  319                                 ")" + 
" cannot be obtained from object in event store" + 
" (" +
 
  324   return ( *m_converter )( dataObj );
 
  329 template <
typename T>
 
  337   T* 
get()
 const { 
return &_get( 
true )->getData(); }
 
  339     auto data = _get( 
false );
 
  340     return data ? &data->getData() : 
nullptr;
 
  346   const T* 
put( T&& obj )
 const {
 
  348     auto objectp = std::make_unique<AnyDataWrapper<T>>( 
std::move( obj ) );
 
  349     if ( 
auto sc = m_EDS->registerObject( objKey(), objectp.get() ); sc.isFailure() ) {
 
  350       throw GaudiException( 
"Error in put of " + objKey(), 
"DataObjectHandle<AnyDataWrapper<T>>::put", sc );
 
  352     return &objectp.release()->getData();
 
  358   std::optional<std::size_t> 
size()
 const { 
return _get()->size(); }
 
  371         throw GaudiException( 
"Cannot retrieve \'" + objKey() + 
"\' from transient store.",
 
  386 template <
typename View, 
typename Owned>
 
  394   View* 
get()
 const { 
return &_get( 
true )->getData(); }
 
  396     auto data = _get( 
false );
 
  397     return data ? &data->getData() : 
nullptr;
 
  405     if ( 
auto sc = m_EDS->registerObject( objKey(), objectp.get() ); sc.isFailure() ) {
 
  406       throw GaudiException( 
"Error in put of " + objKey(), 
"DataObjectHandle<AnyDataWithViewWrapper<T>::put", sc );
 
  408     return &objectp.release()->getData();
 
  410   const View* 
put( Owned&& obj )
 const {
 
  417   std::optional<std::size_t> 
size()
 const { 
return _get()->size(); }
 
  430         throw GaudiException( 
"Cannot retrieve \'" + objKey() + 
"\' from transient store.",
 
  437     if ( !
m_goodType ) 
m_goodType = ::details::verifyType<AnyDataWithViewWrapper<View, Owned>>( obj );
 
  445   template <
typename T, 
typename U = T>
 
  447   template <
typename T, 
typename U = T>
 
  451 template <
typename T>
 
  463   template <
typename OWNER, 
typename K, 
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
 
  468   template <
typename... Args>
 
  473 template <
typename T, 
typename U = T>
 
  485   template <
typename OWNER, 
typename K, 
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
 
  490   template <
typename... Args>
 
  
 
DataObjectHandle< Payload_t< Gaudi::DataHandle::Writer, T, U > > WriteHandle
DataObjectWriteHandle(OWNER *owner, std::string propertyName, K key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
Range get() const
Retrieve object from transient data store.
std::string pythonRepr() const override
std::optional< Range > get() const
Retrieve object from transient data store.
std::remove_cv_t< std::remove_pointer_t< typename T::value_type > > ValueType
DataObjectWriteHandle(std::tuple< Args... > &&args, std::index_sequence< Is... >)
T * getOrCreate() const
Get object from store or create a new one if it doesn't exist.
std::remove_cv_t< std::remove_pointer_t< typename T::value_type > > ValueType
get
decorate the vector of properties
const T * put(T &&obj) const
Register object in transient store.
std::optional< Gaudi::NamedRange_< T > > type
DataObjectReadHandle(OWNER *owner, std::string propertyName, K key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
bool verifyType(const DataObject *dataObj)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
std::string pythonRepr() const override
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
bool exist() const
Check the existence of the object in the transient store.
View * getIfExists() const
T * get() const
Retrieve object from transient data store.
std::conditional_t< std::is_base_of_v< DataObject, T > &&std::is_same_v< T, U >, T, std::conditional_t< std::is_same_v< T, U >, AnyDataWrapper< std::remove_const_t< T > >, AnyDataWithViewWrapper< std::remove_const_t< T >, std::remove_const_t< U > >> > type
T * get() const
Retrieve object from transient data store.
AnyDataWithViewWrapper< View, Owned > * _get(bool mustExist) const
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Range make_range(const DataObject *obj)
T * get(bool mustExist) const
Try to retrieve from the transient store.
DataObjectReadHandle(const DataObjID &k, IDataHandleHolder *owner)
auto begin(reverse_wrapper< T > &w)
std::remove_cv_t< std::remove_pointer_t< typename T::value_type > > ValueType
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
DataObjectWriteHandle(const DataObjID &k, IDataHandleHolder *owner)
std::optional< std::size_t > size() const
Size of boxed item, if boxed item has a 'size' method.
Converter_t< Range > select_range_converter(const DataObject *obj)
std::string pythonRepr() const override
DataObjectWriteHandle(std::tuple< Args... > &&args)
T * put(std::unique_ptr< T > object) const
Register object in transient store.
typename Payload_helper< mode, T, U >::type Payload_t
virtual std::string pythonRepr() const
T(*)(const DataObject *) Converter_t
DataObjectHandleBase(DataObjID k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
View * get() const
Retrieve object from transient data store.
std::string pythonRepr() const override
constexpr static const auto FAILURE
T * getIfExists() const
Bypass check of existence of object in transient store Only uses main location of the.
AnyDataWrapper< T > * _get(bool mustExist) const
DataObjectHandle< Payload_t< Gaudi::DataHandle::Reader, T, U > > ReadHandle
const View * put(std::unique_ptr< AnyDataWithViewWrapper< View, Owned >> objectp) const
Register object in transient store.
Range get() const
Retrieve object from transient data store.
const View * put(Owned &&obj) const
IRegistry * registry() const
Get pointer to Registry.
DataObjectReadHandle(std::tuple< Args... > &&args, std::index_sequence< Is... >)
DataObjectReadHandle(std::tuple< Args... > &&args)
auto put(const DataObjectHandle< Out1 > &out_handle, Out2 &&out)
std::string pythonRepr() const override
std::optional< std::size_t > size() const
Size of boxed item, if boxed item has a 'size' method.
auto end(reverse_wrapper< T > &w)
std::string pythonRepr() const override