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 );
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 <
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>
86 template <
typename T,
typename U = T>
104 template <
typename T>
123 bool exist()
const {
return get(
false ) !=
nullptr; }
135 [[deprecated(
"please pass a std::unique_ptr instead of a raw pointer" )]] T*
put( T*
object )
const {
146 T*
get(
bool mustExist )
const;
159 template <
typename T>
161 auto dataObj =
fetch();
164 throw GaudiException(
"Cannot retrieve " + objKey() +
" from transient store.",
169 if (
UNLIKELY( !m_goodType ) ) m_goodType = ::details::verifyType<T>( dataObj );
170 return static_cast<T*
>( dataObj );
174 template <
typename T>
177 StatusCode sc = m_EDS->registerObject( objKey(), objectp.
get() );
178 if ( !sc.
isSuccess() ) {
throw GaudiException(
"Error in put of " + objKey(),
"DataObjectHandle<T>::put", sc ); }
183 template <
typename T>
185 T* obj =
get(
false );
186 return obj ? obj :
put( std::make_unique<T>() );
192 template <
typename T>
195 using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
212 mutable ::details::Converter_t<Range> m_converter =
nullptr;
215 template <
typename ValueType>
217 auto dataObj =
fetch();
219 throw GaudiException(
"Cannot retrieve " + objKey() +
" from transient store.",
223 m_converter = ::details::select_range_converter<ValueType>( dataObj );
224 if ( !m_converter ) {
226 ")" +
" cannot be obtained from object in event store" +
" (" +
231 return ( *m_converter )( dataObj );
237 template <
typename T>
240 using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
257 mutable ::details::Converter_t<Range> m_converter =
nullptr;
260 template <
typename ValueType>
262 auto dataObj =
fetch();
264 throw GaudiException(
"Cannot retrieve " + objKey() +
" from transient store.",
268 m_converter = ::details::select_range_converter<ValueType, Range>( dataObj );
269 if ( !m_converter ) {
271 ")" +
" cannot be obtained from object in event store" +
" (" +
276 return ( *m_converter )( dataObj );
281 template <
typename T>
289 T*
get()
const {
return &
_get(
true )->getData(); }
291 auto data =
_get(
false );
292 return data ? &data->getData() :
nullptr;
298 const T*
put( T&& obj )
const {
300 auto objectp = std::make_unique<AnyDataWrapper<T>>(
std::move( obj ) );
301 if (
auto sc = m_EDS->registerObject( objKey(), objectp.get() ); sc.isFailure() ) {
302 throw GaudiException(
"Error in put of " + objKey(),
"DataObjectHandle<AnyDataWrapper<T>>::put", sc );
304 return &objectp.release()->getData();
310 std::optional<std::size_t>
size()
const {
return _get()->size(); }
323 throw GaudiException(
"Cannot retrieve " + objKey() +
" from transient store.",
338 template <
typename View,
typename Owned>
346 View*
get()
const {
return &
_get(
true )->getData(); }
348 auto data =
_get(
false );
349 return data ? &data->getData() :
nullptr;
357 if (
auto sc = m_EDS->registerObject( objKey(), objectp.get() ); sc.isFailure() ) {
358 throw GaudiException(
"Error in put of " + objKey(),
"DataObjectHandle<AnyDataWithViewWrapper<T>::put", sc );
360 return &objectp.release()->getData();
362 const View*
put( Owned&& obj )
const {
369 std::optional<std::size_t>
size()
const {
return _get()->size(); }
382 throw GaudiException(
"Cannot retrieve " + objKey() +
" from transient store.",
397 template <
typename T>
409 template <
typename OWNER,
typename K,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
414 template <
typename... Args>
419 template <
typename T,
typename U = T>
431 template <
typename OWNER,
typename K,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
436 template <
typename... Args>
456 #pragma GCC diagnostic push
457 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
458 template <
typename T>
460 template <
class OWNER,
class K,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
466 #pragma GCC diagnostic pop
Range get() const
Retrieve object from transient data store.
std::string pythonRepr() const override
typename Payload_helper< T, U >::type Payload_t
std::remove_cv_t< std::remove_pointer_t< typename T::value_type > > ValueType
DataObjectReadHandle(const std::tuple< Args... > &args)
DataObjectReadHandle(const 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
const T * put(T &&obj) const
Register object in transient store.
DataObjectHandleBase(const DataObjID &k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
bool verifyType(const DataObject *dataObj)
Transitional class to help moving all code to Handles even if some usage requires 'dynamic' behavior,...
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
DataObjectWriteHandle(const std::tuple< Args... > &args)
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
bool exist() const
Check the existence of the object in the transient store.
View * getIfExists() const
DataObjectReadHandle(OWNER *owner, std::string propertyName, const K &key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
T * get() const
Retrieve object from transient data store.
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
DeprecatedDynamicDataObjectHandle(OWNER const *owner, const K &key={})
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.
DataObjectWriteHandle(const std::tuple< Args... > &args, std::index_sequence< Is... >)
DataObjectReadHandle(const DataObjID &k, IDataHandleHolder *owner)
auto begin(reverse_wrapper< T > &w)
Header file for std:chrono::duration-based Counters.
DataObjectWriteHandle(const DataObjID &k, IDataHandleHolder *owner)
std::optional< std::size_t > size() const
Size of boxed item, if boxed item has a 'size' method.
DataObjectWriteHandle(OWNER *owner, std::string propertyName, const K &key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
Converter_t< Range > select_range_converter(const DataObject *obj)
std::string pythonRepr() const override
T * put(std::unique_ptr< T > object) const
Register object in transient store.
virtual std::string pythonRepr() const
T(*)(const DataObject *) Converter_t
View * 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
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
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.
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