28 template <
typename Range,
typename StorageType>
30 auto c =
static_cast<const StorageType*
>( obj );
31 if ( !c )
return Range();
34 auto first =
begin( *c );
35 auto last =
end( *c );
36 auto _first =
reinterpret_cast<typename Range::const_iterator*
>( &first );
37 auto _last =
reinterpret_cast<typename Range::const_iterator*
>( &last );
38 return Range( *_first, *_last );
41 template <
typename ValueType,
typename Range = Gaudi::Range_<
typename ValueType::ConstVector>>
43 using Selection =
typename ValueType::Selection;
44 auto sel =
dynamic_cast<const Selection*
>( obj );
46 auto con =
dynamic_cast<std::add_const_t<typename ValueType::Container>*
>( obj );
53 using Type = std::add_const_t<T>;
54 assert( dataObj !=
nullptr );
55 auto obj =
dynamic_cast<Type*
>( dataObj );
56 bool ok = ( obj != nullptr );
58 const auto* registry = dataObj->
registry();
59 throw GaudiException(
"The type expected for " + registry->identifier() +
" is " +
61 " and is different from the one of the object in the store which is " +
65 assert( obj ==
static_cast<Type*
>( dataObj ) );
69 template <Gaudi::DataHandle::Mode,
typename T,
typename U>
72 std::conditional_t<std::is_base_of_v<DataObject, T> && std::is_same_v<T, U>, T,
76 template <
typename T,
typename U>
80 template <
typename T,
typename U>
84 template <
typename T,
typename U>
86 using type = std::optional<Gaudi::NamedRange_<T>>;
89 template <Gaudi::DataHandle::Mode mode,
typename T,
typename U = T>
92 std::string
replace_all( std::string str, std::string_view from, std::string_view to );
128 bool exist()
const {
return get(
false ) !=
nullptr; }
138 T*
put( std::unique_ptr<T>
object )
const;
146 T*
get(
bool mustExist )
const;
161 auto dataObj =
fetch();
170 return static_cast<T*
>( dataObj );
179 return objectp.release();
185 T* obj =
get(
false );
186 return obj ? obj :
put( std::make_unique<T>() );
195 using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
214template <
typename ValueType>
216 auto dataObj = fetch();
218 throw GaudiException(
"Cannot retrieve \'" + objKey() +
"\' from transient store.",
221 if ( !m_converter ) {
223 if ( !m_converter ) {
225 ")" +
" cannot be obtained from object in event store" +
" (" +
230 return ( *m_converter )( dataObj );
239 using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
258template <
typename ValueType>
260 auto dataObj = fetch();
262 throw GaudiException(
"Cannot retrieve \'" + objKey() +
"\' from transient store.",
265 if ( !m_converter ) {
267 if ( !m_converter ) {
269 ")" +
" cannot be obtained from object in event store" +
" (" +
274 return ( *m_converter )( dataObj );
284 using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
292 std::optional<Range>
get()
const;
303template <
typename ValueType>
305 auto dataObj = fetch();
306 if ( !dataObj )
return std::nullopt;
307 if ( !m_converter ) {
309 if ( !m_converter ) {
311 ")" +
" cannot be obtained from object in event store" +
" (" +
316 return ( *m_converter )( dataObj );
329 T*
get()
const {
return &
_get(
true )->getData(); }
331 auto data =
_get(
false );
332 return data ? &data->getData() :
nullptr;
338 const T*
put( T&& obj )
const {
340 auto objectp = std::make_unique<AnyDataWrapper<T>>( std::move( obj ) );
341 if (
auto sc =
m_EDS->registerObject(
objKey(), objectp.get() ); sc.isFailure() ) {
342 throw GaudiException(
"Error in put of " +
objKey(),
"DataObjectHandle<AnyDataWrapper<T>>::put", sc );
344 return &objectp.release()->getData();
350 std::optional<std::size_t>
size()
const {
return _get()->size(); }
377template <
typename View,
typename Owned>
385 View*
get()
const {
return &
_get(
true )->getData(); }
387 auto data =
_get(
false );
388 return data ? &data->getData() :
nullptr;
396 if (
auto sc =
m_EDS->registerObject(
objKey(), objectp.get() ); sc.isFailure() ) {
397 throw GaudiException(
"Error in put of " +
objKey(),
"DataObjectHandle<AnyDataWithViewWrapper<T>::put", sc );
399 return &objectp.release()->getData();
401 const View*
put( Owned&& obj )
const {
408 std::optional<std::size_t>
size()
const {
return _get()->size(); }
435 template <
typename T,
typename U = T>
437 template <
typename T,
typename U = T>
443 template <
typename... Args, std::size_t... Is>
453 template <std::derived_from<IProperty> OWNER,
typename K>
456 std::move( doc ) ) {}
458 template <
typename... Args>
463template <
typename T,
typename U = T>
465 template <
typename... Args, std::size_t... Is>
475 template <std::derived_from<IProperty> OWNER,
typename K>
478 std::move( doc ) ) {}
480 template <
typename... Args>
This file has been imported from LoKi project "C++ ToolKit for Smart and Friendly Physics Analysis"
SmartIF< IDataProviderSvc > m_EDS
DataObjectHandleBase(DataObjID k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
DataObject * fetch() const
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
std::string pythonRepr() const override
T * get() const
Retrieve object from transient data store.
mutable ::details::Converter_t< Range > m_converter
std::string pythonRepr() const override
std::string pythonRepr() const override
std::remove_cv_t< std::remove_pointer_t< typename T::value_type > > ValueType
std::string pythonRepr() const override
std::remove_cv_t< std::remove_pointer_t< typename T::value_type > > ValueType
T * get() const
Retrieve object from transient data store.
std::string pythonRepr() const override
AnyDataWithViewWrapper< View, Owned > * _get(bool mustExist) const
T * getIfExists() const
Bypass check of existence of object in transient store Only uses main location of the.
std::string pythonRepr() const override
T * put(std::unique_ptr< T > object) const
Register object in transient store.
Range get() const
Retrieve object from transient data store.
View * get() const
Retrieve object from transient data store.
std::optional< std::size_t > size() const
Size of boxed item, if boxed item has a 'size' method.
mutable ::details::Converter_t< Range > m_converter
const T * put(T &&obj) const
Register object in transient store.
std::optional< std::size_t > size() const
Size of boxed item, if boxed item has a 'size' method.
Gaudi::Range_< typename ValueType::ConstVector > Range
mutable ::details::Converter_t< Range > m_converter
T * get(bool mustExist) const
Try to retrieve from the transient store.
Gaudi::NamedRange_< typename ValueType::ConstVector > Range
AnyDataWrapper< T > * _get(bool mustExist) const
Range get() const
Retrieve object from transient data store.
View * getIfExists() const
std::optional< Range > get() const
Retrieve object from transient data store.
const View * put(Owned &&obj) const
Gaudi::NamedRange_< typename ValueType::ConstVector > Range
T * getOrCreate() const
Get object from store or create a new one if it doesn't exist.
DataObjectHandleBase(DataObjID k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
bool exist() const
Check the existence of the object in the transient store.
std::remove_cv_t< std::remove_pointer_t< typename T::value_type > > ValueType
const View * put(std::unique_ptr< AnyDataWithViewWrapper< View, Owned > > objectp) const
Register object in transient store.
A DataObject is the base class of any identifiable object on any data store.
IRegistry * registry() const
Get pointer to Registry.
DataObjectReadHandle(std::tuple< Args... > &&args)
DataObjectReadHandle(OWNER *owner, std::string propertyName, K key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
DataObjectReadHandle(const DataObjID &k, IDataHandleHolder *owner)
DataObjectReadHandle(std::tuple< Args... > &&args, std::index_sequence< Is... >)
DataObjectWriteHandle(const DataObjID &k, IDataHandleHolder *owner)
DataObjectWriteHandle(std::tuple< Args... > &&args)
DataObjectWriteHandle(std::tuple< Args... > &&args, std::index_sequence< Is... >)
DataObjectWriteHandle(OWNER *owner, std::string propertyName, K key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
static const std::string default_type
virtual std::string pythonRepr() const
IDataHandleHolder * m_owner
virtual IDataHandleHolder * owner() const
virtual const std::string & objKey() const
DataHandle(DataObjID k, Mode a=Reader, IDataHandleHolder *owner=nullptr)
Useful class for representation of "sequence" of the objects through the range of valid iterators.
Define general base for Gaudi exception.
This class is used for returning status codes from appropriate routines.
constexpr static const auto FAILURE
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Converter_t< Range > select_range_converter(const DataObject *obj)
DataObjectHandle< Payload_t< Gaudi::DataHandle::Reader, T, U > > ReadHandle
T(*)(const DataObject *) Converter_t
DataObjectHandle< Payload_t< Gaudi::DataHandle::Writer, T, U > > WriteHandle
Range make_range(const DataObject *obj)
bool verifyType(const DataObject *dataObj)
std::string replace_all(std::string str, std::string_view from, std::string_view to)
auto begin(reverse_wrapper< T > &w)
auto end(reverse_wrapper< T > &w)
typename Payload_helper< mode, T, U >::type Payload_t
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
std::optional< Gaudi::NamedRange_< T > > type
Gaudi::NamedRange_< T > type