1 #ifndef FUNCTIONAL_DETAILS_H 2 #define FUNCTIONAL_DETAILS_H 17 #include "boost/optional.hpp" 20 #include <range/v3/view/const.hpp> 21 #include <range/v3/view/zip.hpp> 35 template <
typename OS,
typename Arg>
38 out <<
"SizeOf'" <<
System::typeinfoName(
typeid( Arg ) ) <<
"'=" << std::forward<Arg>( arg ).size();
42 template <
typename OS,
typename Arg,
typename... Args>
58 template <
typename A,
typename B>
61 return a.size() == b.size();
65 template <
typename A,
typename B,
typename... C>
66 inline bool check_sizes(
const A& a,
const B& b,
const C&...
c ) noexcept
72 template <
typename... Args>
77 mess <<
"Zipped containers have different sizes : ";
84 template <
typename... Args>
89 return ranges::view::zip( std::forward<Args>( args )... );
93 template <
typename... Args>
98 return ranges::view::const_( ranges::view::zip( std::forward<Args>( args )... ) );
103 template <
typename T>
109 template <
typename T>
114 template <
typename Out1,
typename Out2,
118 return out_handle.
put(
new Out1( std::forward<Out2>( out ) ) );
121 template <
typename Out1,
typename Out2,
125 out_handle.
put( std::forward<Out2>( out ) );
129 template <
typename OutHandle,
typename Out>
130 void put( OutHandle& out_handle, boost::optional<Out>&& out )
141 template <
typename Container>
144 template <
typename Container,
typename Value>
147 return c.push_back( std::forward<Value>( v ) );
150 template <
typename Container,
typename Value>
153 return c.insert( std::forward<Value>( v ) );
157 template <
typename Container,
164 template <
typename Container,
typename Value>
174 template <typename In, typename = typename std::enable_if<!std::is_pointer<In>::value>
::type>
180 template <
typename In>
183 assert( in !=
nullptr );
192 template <
typename T>
196 template <
typename T>
202 template <
typename T>
204 template <
typename T>
207 template <
typename T>
216 template <
typename Container,
typename Value>
221 template <
typename Container,
typename Value>
227 template <
typename In>
229 template <
template <
typename>
class Handle,
typename I,
235 template <
template <
typename>
class Handle,
typename I,
239 return h.getIfExists();
243 template <
typename T>
248 template <
typename T>
255 template <
typename Container>
259 using val_t = std::add_const_t<std::remove_pointer_t<Container>>;
260 using ptr_t = std::add_pointer_t<val_t>;
261 using ref_t = std::add_lvalue_reference_t<val_t>;
266 using value_type = std::conditional_t<is_optional, ptr_t, val_t>;
270 typename ContainerVector::const_iterator
m_i;
272 iterator(
typename ContainerVector::const_iterator iter ) : m_i( iter ) {}
273 using ret_t = std::conditional_t<is_optional, ptr_t, ref_t>;
289 explicit operator bool()
const {
return !is_null(); }
293 template <
typename T>
306 return *m_containers[i];
323 template <
typename...>
326 template <
typename...>
330 template <
typename... T>
335 template <
typename Default,
typename AlwaysVoid,
template <
typename...>
class Op,
typename... Args>
341 template <
typename Default,
template <
typename...>
class Op,
typename... Args>
348 template <
typename Default,
template <
typename...>
class Op,
typename... Args>
352 template <
template <
typename...>
class Default,
template <
typename...>
class Op,
typename Tr,
typename T>
359 template <
typename Tr>
361 template <
typename Tr,
typename T>
364 template <
typename Tr,
typename T>
366 template <
typename Tr,
typename T>
373 template <
typename Tr>
380 template <
typename Tr,
typename T>
382 template <
typename Tr,
typename T>
389 template <std::
size_t N,
typename Tuple>
394 std::index_sequence<I...> )
400 std::index_sequence<I...> )
403 ( owner.
declareProperty( std::get<I>( inputs ).first, std::get<I>( props ) ), 0 )...};
407 template <
typename Tuple,
typename KeyValues>
410 return details2::make_tuple_of_handles_helper<Tuple>(
411 owner, initvalue, mode, std::make_index_sequence<std::tuple_size<Tuple>::value>{} );
414 template <
typename KeyValues,
typename Properties>
417 constexpr
auto N = std::tuple_size<KeyValues>::value;
418 static_assert( N == std::tuple_size<Properties>::value,
"Inconsistent lengths" );
422 template <
typename Handles>
427 handles.reserve( init.
size() );
429 [&](
const std::string& loc ) ->
typename Handles::value_type {
430 return {loc, mode, owner};
437 template <
typename OutputSpec,
typename InputSpec,
typename Traits_>
440 template <
typename... Out,
typename... In,
typename Traits_>
444 "BaseClass must inherit from Algorithm" );
483 template <std::
size_t N = 0>
486 return std::get<N>(
m_inputs ).objKey();
490 template <std::
size_t N = 0>
493 return std::get<N>( m_outputs ).objKey();
502 template <
typename... In,
typename Traits_>
506 "BaseClass must inherit from Algorithm" );
529 template <std::
size_t N = 0>
532 return std::get<N>(
m_inputs ).objKey();
540 template <
typename... Out,
typename Traits_>
544 "BaseClass must inherit from Algorithm" );
566 template <std::
size_t N = 0>
569 return std::get<N>( m_outputs ).objKey();
578 template <
typename Fun,
typename Container,
typename... Args>
581 static_assert(
sizeof...( Args ) == 0,
"Args should not be used!" );
584 template <
typename Fun,
typename Container>
587 fun.postprocess(
c );
DataHandleMixin(const std::string &name, ISvcLocator *pSvcLocator, const std::array< KeyValue, N_out > &outputs)
DataHandleMixin(const std::string &name, ISvcLocator *pSvcLocator, const std::array< KeyValue, N_in > &inputs)
auto operator()(Container &c, Value &&v) const -> decltype(c.insert(v))
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Tuple make_tuple_of_handles_helper(IDataHandleHolder *o, const KeyValues &initvalue, Gaudi::DataHandle::Mode m, std::index_sequence< I... >)
constexpr std::add_const< T >::type & as_const(T &t) noexcept
In & operator()(In *in) const
detected_or_t_< detail2::defaultHandle_, detail2::OutputHandle_, Tr, T > OutputHandle_t
Define general base for Gaudi exception.
DataHandleMixin(const std::string &name, ISvcLocator *locator, const std::array< KeyValue, N_in > &inputs, const KeyValue &output)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
void reserve(size_type size)
Handles make_vector_of_handles(IDataHandleHolder *owner, const std::vector< std::string > &init, Gaudi::DataHandle::Mode mode)
The namespace threadpool contains a thread pool and related utility classes.
friend bool operator!=(const iterator &lhs, const iterator &rhs)
void declare_tuple_of_properties(Algorithm &owner, const KeyValues &inputs, Properties &props)
unsigned int inputLocationSize() const
detected_or_t< GaudiAlgorithm, detail2::BaseClass_, Tr > BaseClass_t
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
void declare_tuple_of_properties_helper(Algorithm &owner, const KeyValues &inputs, Properties &props, std::index_sequence< I... >)
auto operator()(Container &c, c_remove_ptr_t< Container > &&v) const
void printSizes(OS &out, Arg &&arg)
Print the parameter.
const std::string & outputLocation() const
ContainerVector::const_iterator m_i
constexpr struct Gaudi::Functional::details::insert_t insert
DataHandleMixin(const std::string &name, ISvcLocator *pSvcLocator, const std::array< KeyValue, N_in > &inputs, const std::array< KeyValue, N_out > &outputs)
typename Tr::template InputHandle< T > InputHandle_
Header file for class GaudiAlgorithm.
DataHandleMixin(const std::string &name, ISvcLocator *locator, const KeyValue &input, const KeyValue &output)
std::add_const_t< std::remove_pointer_t< Container >> val_t
typename std::remove_pointer< typename Container::value_type >::type c_remove_ptr_t
bool is_null(size_type i) const
class MergingTransformer< Out(const vector_of_const_< In > void
auto operator()(Container &c, Value &&v) const -> decltype(c.push_back(v))
const std::string & inputLocation() const
void push_back(Container &c, const Value &v, std::true_type)
std::vector< Gaudi::Details::PropertyBase * > Properties
iterator(typename ContainerVector::const_iterator iter)
std::add_lvalue_reference_t< val_t > ref_t
T * deref_if(T *const t, std::false_type)
typename void_t_< T... >::type void_t
const Container & operator[](size_type i) const
constexpr struct Gaudi::Functional::details::deref_t deref
const T * put(T &&object)
Register object in transient store.
std::conditional_t< is_optional, ptr_t, val_t > value_type
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
Implementation of the detection idiom (negative case).
ContainerVector m_containers
const std::string & inputLocation() const
constexpr void applyPostProcessing(const Fun &, Container &, Args...)
DataHandleMixin(const std::string &name, ISvcLocator *locator, const KeyValue &input, const std::array< KeyValue, N_out > &outputs)
const std::string & outputLocation() const
In & operator()(In &in) const
auto operator()(const Handle< I > &h) -> const In &
T * put(T *object)
Register object in transient store.
typename details2::remove_optional< T >::type remove_optional_t
auto operator()(const Handle< I > &h) -> const In
DataHandleMixin(const std::string &name, ISvcLocator *locator, const KeyValue &output)
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
Tuple make_tuple_of_handles(IDataHandleHolder *owner, const KeyValues &initvalue, Gaudi::DataHandle::Mode mode)
unsigned int outputLocationSize() const
unsigned int inputLocationSize() const
typename std::conditional< std::is_base_of< DataObject, T >::value, DataObjectHandle< T >, AnyDataHandle< T >>::type defaultHandle_
decltype(auto) verifySizes(Args &...args)
Verify the data container sizes have the same sizes.
Base class from which all concrete algorithm classes should be derived.
std::vector< InputHandle_t< In > > m_inputs
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
std::conditional_t< is_optional, ptr_t, ref_t > ret_t
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
detected_or_t< Default< Tr, T >, Op, Tr, T > detected_or_t_
void operator()(Container &c, boost::optional< Value > &&v) const
bool check_sizes(const A &) noexcept
Resolve case there is only one container in the range.
std::tuple< details::InputHandle_t< Traits_, In >... > m_inputs
void push_back(T &&container)
T back_inserter(T...args)
const Container & at(size_type i) const
typename std::tuple_element< N, Tuple >::type element_t
std::tuple< details::OutputHandle_t< Traits_, Out >... > m_outputs
double fun(const std::vector< double > &x)
DataHandleMixin(const std::string &name, ISvcLocator *locator, const KeyValue &input)
typename Tr::template OutputHandle< T > OutputHandle_
struct[[deprecated("use MergingTransformer instead")]] Traits_
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
std::add_pointer_t< val_t > ptr_t
typename Tr::BaseClass BaseClass_
detected_or_t_< detail2::defaultHandle_, detail2::InputHandle_, Tr, T > InputHandle_t
decltype(auto) const_range(Args &&...args)
Zips multiple containers together to form a single const range.
std::tuple< details::InputHandle_t< Traits_, In >... > m_inputs
T & deref_if(T *const t, std::true_type)
Helper functions to set/get the application return code.
std::tuple< details::OutputHandle_t< Traits_, Out >... > m_outputs
def Reader(readerType, filename, qacross, qToEngine)
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)
void push_back(Container &c, const Value &v, std::false_type)
typename detail2::detector< Default, void, Op, Args... >::type detected_or_t
std::pair< std::string, std::vector< std::string >> KeyValues
typename ContainerVector::size_type size_type
unsigned int outputLocationSize() const