Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
utilities.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
15 #include <boost/algorithm/string/join.hpp>
16 #include <initializer_list>
17 #include <string>
18 
19 namespace Gaudi::Functional {
20 
21  namespace Traits {
22 
23  // traits classes used to customize Transformer and FilterPredicate
24  // Define the types to to be used as baseclass, and as in- resp. output hanldes.
25  // In case a type is not specified in the traits struct, a default is used.
26  //
27  // The defaults are:
28  //
29  // using BaseClass = GaudiAlgorithm
30  // template <typename T> using InputHandle = DataObjectHandle<T>;
31  // template <typename T> using OutputHandle = DataObjectHandle<T>;
32  //
33 
34  // the best way to 'compose' traits is by inheriting them one-by-one...
35  template <typename... Base>
36  struct use_ : Base... {};
37 
38  // helper classes one can inherit from to specify a specific trait
39  template <typename Base>
40  struct BaseClass_t {
41  using BaseClass = Base;
42  };
43 
44  template <template <typename> class Handle>
45  struct InputHandle_t {
46  template <typename T>
47  using InputHandle = Handle<T>;
48  };
49 
50  template <template <typename> class Handle>
51  struct OutputHandle_t {
52  template <typename T>
53  using OutputHandle = Handle<T>;
54  };
55 
56  template <typename Data, typename View>
57  struct writeViewFor {
58  template <typename T>
59  using OutputHandle = std::enable_if_t<std::is_same_v<T, Data>, DataObjectWriteHandle<View, Data>>;
60  };
61 
62  // add support for objects that should reside in the TES for lifetime management, but should not
63  // be used explicitly and/or directly by downstream code.
64  template <typename Data>
65  struct WriteOpaqueFor {
66  struct OpaqueView {
67  OpaqueView() = default;
68  template <typename T>
69  OpaqueView( T const& ) {}
70  };
71 
72  template <typename T>
73  using OutputHandle = std::enable_if_t<std::is_same_v<T, Data>, DataObjectWriteHandle<OpaqueView, Data>>;
74  };
75 
76  // this uses the defaults -- and it itself is the default ;-)
78  } // namespace Traits
79 } // namespace Gaudi::Functional
DataObjectWriteHandle
Definition: DataObjectHandle.h:427
Gaudi::Functional::Traits::OutputHandle_t::OutputHandle
Handle< T > OutputHandle
Definition: utilities.h:53
Gaudi::Functional::Traits::WriteOpaqueFor
Definition: utilities.h:65
Gaudi::Functional::Traits::WriteOpaqueFor::OpaqueView
Definition: utilities.h:66
Gaudi::Functional::Traits::OutputHandle_t
Definition: utilities.h:51
Gaudi::Functional::Traits::use_
Definition: utilities.h:36
Gaudi::Functional
Definition: FunctionalUtilities.h:18
Gaudi::Functional::Traits::WriteOpaqueFor::OpaqueView::OpaqueView
OpaqueView(T const &)
Definition: utilities.h:69
Gaudi::Functional::Traits::InputHandle_t::InputHandle
Handle< T > InputHandle
Definition: utilities.h:47
Gaudi::Functional::Traits::writeViewFor::OutputHandle
std::enable_if_t< std::is_same_v< T, Data >, DataObjectWriteHandle< View, Data > > OutputHandle
Definition: utilities.h:59
Gaudi::Functional::Traits::BaseClass_t
Definition: utilities.h:40
Gaudi::Functional::Traits::WriteOpaqueFor::OutputHandle
std::enable_if_t< std::is_same_v< T, Data >, DataObjectWriteHandle< OpaqueView, Data > > OutputHandle
Definition: utilities.h:73
Gaudi::Functional::Traits::writeViewFor
Definition: utilities.h:57
SerializeSTL.h
Gaudi::Functional::Traits::BaseClass_t::BaseClass
Base BaseClass
Definition: utilities.h:41
DataObjectHandle.h
Gaudi::Functional::Traits::InputHandle_t
Definition: utilities.h:45
Gaudi::Functional::Traits::WriteOpaqueFor::OpaqueView::OpaqueView
OpaqueView()=default