Loading [MathJax]/extensions/tex2jax.js
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; }
147 T*
get(
bool mustExist )
const;
160 template <
typename T>
162 auto dataObj =
fetch();
165 throw GaudiException(
"Cannot retrieve \'" + objKey() +
"\' from transient store.",
170 if ( !m_goodType ) m_goodType = ::details::verifyType<T>( dataObj );
171 return static_cast<T*
>( dataObj );
175 template <
typename T>
178 StatusCode sc = m_EDS->registerObject( objKey(), objectp.
get() );
179 if ( !sc.
isSuccess() ) {
throw GaudiException(
"Error in put of " + objKey(),
"DataObjectHandle<T>::put", sc ); }
184 template <
typename T>
186 T* obj =
get(
false );
187 return obj ? obj :
put( std::make_unique<T>() );
193 template <
typename T>
196 using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
213 mutable ::details::Converter_t<Range> m_converter =
nullptr;
216 template <
typename ValueType>
218 auto dataObj =
fetch();
220 throw GaudiException(
"Cannot retrieve \'" + objKey() +
"\' from transient store.",
223 if ( !m_converter ) {
224 m_converter = ::details::select_range_converter<ValueType>( dataObj );
225 if ( !m_converter ) {
227 ")" +
" cannot be obtained from object in event store" +
" (" +
232 return ( *m_converter )( dataObj );
238 template <
typename T>
241 using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
258 mutable ::details::Converter_t<Range> m_converter =
nullptr;
261 template <
typename ValueType>
263 auto dataObj =
fetch();
265 throw GaudiException(
"Cannot retrieve \'" + objKey() +
"\' from transient store.",
268 if ( !m_converter ) {
269 m_converter = ::details::select_range_converter<ValueType, Range>( dataObj );
270 if ( !m_converter ) {
272 ")" +
" cannot be obtained from object in event store" +
" (" +
277 return ( *m_converter )( dataObj );
284 template <
typename T>
287 using ValueType = std::remove_cv_t<std::remove_pointer_t<typename T::value_type>>;
295 std::optional<Range>
get()
const;
304 mutable ::details::Converter_t<Range> m_converter =
nullptr;
307 template <
typename ValueType>
309 auto dataObj =
fetch();
310 if ( !dataObj )
return std::nullopt;
311 if ( !m_converter ) {
312 m_converter = ::details::select_range_converter<ValueType, Range>( dataObj );
313 if ( !m_converter ) {
315 ")" +
" cannot be obtained from object in event store" +
" (" +
320 return ( *m_converter )( dataObj );
325 template <
typename T>
333 T*
get()
const {
return &_get(
true )->getData(); }
335 auto data = _get(
false );
336 return data ? &data->getData() :
nullptr;
342 const T*
put( T&& obj )
const {
344 auto objectp = std::make_unique<AnyDataWrapper<T>>(
std::move( obj ) );
345 if (
auto sc = m_EDS->registerObject( objKey(), objectp.get() ); sc.isFailure() ) {
346 throw GaudiException(
"Error in put of " + objKey(),
"DataObjectHandle<AnyDataWrapper<T>>::put", sc );
348 return &objectp.release()->getData();
354 std::optional<std::size_t>
size()
const {
return _get()->size(); }
367 throw GaudiException(
"Cannot retrieve \'" + objKey() +
"\' from transient store.",
382 template <
typename View,
typename Owned>
390 View*
get()
const {
return &_get(
true )->getData(); }
392 auto data = _get(
false );
393 return data ? &data->getData() :
nullptr;
401 if (
auto sc = m_EDS->registerObject( objKey(), objectp.get() ); sc.isFailure() ) {
402 throw GaudiException(
"Error in put of " + objKey(),
"DataObjectHandle<AnyDataWithViewWrapper<T>::put", sc );
404 return &objectp.release()->getData();
406 const View*
put( Owned&& obj )
const {
413 std::optional<std::size_t>
size()
const {
return _get()->size(); }
426 throw GaudiException(
"Cannot retrieve \'" + objKey() +
"\' from transient store.",
433 if ( !
m_goodType )
m_goodType = ::details::verifyType<AnyDataWithViewWrapper<View, Owned>>( obj );
441 template <
typename T,
typename U = T>
443 template <
typename T,
typename U = T>
447 template <
typename T>
459 template <std::derived_from<IProperty> OWNER,
typename K>
464 template <
typename... Args>
469 template <
typename T,
typename U = T>
481 template <std::derived_from<IProperty> OWNER,
typename K>
486 template <
typename... Args>
DataObjectHandle< Payload_t< Gaudi::DataHandle::Writer, T, U > > WriteHandle
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
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
DataObjectWriteHandle(OWNER *owner, std::string propertyName, K key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
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)
DataObjectReadHandle(OWNER *owner, std::string propertyName, K key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
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.
auto put(const DataObjectHandle< Out1 > &out_handle, Out2 &&out)
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)
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