LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
AssnsTraits.h
Go to the documentation of this file.
1 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_ASSNSTRAITS_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_ASSNSTRAITS_H
13 
14 // LArSoft libraries
15 #include "larcorealg/CoreUtils/MetaUtils.h" // util::is_not_same<>
16 
17 // framework libraries
20 
21 // C/C++ standard
22 #include <utility> // std::pair
23 
24 namespace lar {
25 
26  namespace util {
27 
28  //--- BEGIN Traits for art associations ------------------------------------
38 
40  //--------------------------------------------------------------------------
41  // was proxy::details::hasMetadata
43  template <typename Assns>
45 
46  // was: proxy::details::AssnWithMetadata_v
48  template <typename Assns>
50 
51  // was: proxy::details::AssnsMetadataTypeStruct, proxy::details::AssnNodeMetadataType
53  template <typename Assns>
55 
56  // was: proxy::details::AssnsMetadata_t, proxy::details::AssnNodeMetadata_t
58  template <typename Assns>
60 
61  //--------------------------------------------------------------------------
62  // FIXME simplify this code if issue #18769 is accepted
63  // was: proxy::details::AssnsIteratorTypeStruct
65  template <typename Assns>
67 
69  // was: proxy::details::AssnsIterator_t
70  template <typename Assns>
72 
73  //--------------------------------------------------------------------------
74  // was: proxy::details::AssnsNodeTraits
97  template <typename Assns>
98  struct assns_traits;
99 
100  //--------------------------------------------------------------------------
101 
103  //--- END Traits for art associations --------------------------------------
104 
105  } // namespace util
106 
107 } // namespace lar
108 
109 //------------------------------------------------------------------------------
110 //--- template implementation
111 //------------------------------------------------------------------------------
112 namespace lar {
113 
114  namespace util {
115 
116  namespace details {
117 
118  // was: proxy::details::isAssnMetadata
119  template <typename T>
121 
122  template <typename Assns>
123  struct node_of;
124 
125  template <typename Assns>
126  using node_of_t = typename node_of<Assns>::type;
127 
128  template <typename L, typename R, typename D>
129  struct node_of<art::Assns<L, R, D>> {
131  };
132 
133  template <typename L, typename R>
134  struct node_of<art::Assns<L, R, void>> {
135  using type = std::pair<art::Ptr<L>, art::Ptr<R>>;
136  };
137 
138  } // namespace details
139 
140  //--------------------------------------------------------------------------
141  template <typename L, typename R, typename D>
142  struct assns_metadata_type<art::Assns<L, R, D>> {
143  using type = D;
144  };
145 
146  template <typename L, typename R, typename D>
147  struct assns_metadata_type<art::AssnsNode<L, R, D>> {
148  using type = D;
149  };
150 
151  template <typename L, typename R>
152  struct assns_metadata_type<std::pair<art::Ptr<L>, art::Ptr<R>>> {
153  using type = void;
154  };
155 
156  //--------------------------------------------------------------------------
157  template <typename Assns>
158  struct assns_has_metadata : details::isAssnMetadata<assns_metadata_t<Assns>> {};
159 
160  //--------------------------------------------------------------------------
161  template <typename L, typename R, typename D>
162  struct assns_iterator_type<art::Assns<L, R, D>> {
164  }; // struct assns_iterator_type
165 
166  template <typename L, typename R>
167  struct assns_iterator_type<art::Assns<L, R, void>> {
169  };
170 
171  //--------------------------------------------------------------------------
172  // was proxy::details::AssnsNodeTraitsBase
173  template <typename L, typename R, typename D>
174  struct assns_traits<art::Assns<L, R, D>> {
175 
176  using left_t = L;
177  using right_t = R;
178  using data_t = D;
181  using dataptr_t = data_t const*;
182 
184 
187 
190 
192  static constexpr bool hasMetadata = details::isAssnMetadata<data_t>();
193 
194  }; // struct assns_traits<Assns<L,R,D>>
195 
196  template <typename L, typename R, typename D>
197  struct assns_traits<art::AssnsNode<L, R, D>> : public assns_traits<art::Assns<L, R, D>> {};
198 
199  template <typename L, typename R>
200  struct assns_traits<std::pair<art::Ptr<L>, art::Ptr<R>>>
201  : public assns_traits<art::Assns<L, R>> {};
202 
203  //--------------------------------------------------------------------------
204 
205  } // namespace util
206 
207 } // namespace lar
208 
209 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_ASSNSTRAITS_H
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
Basic C++ metaprogramming utilities.
::util::is_not_same< T, void > isAssnMetadata
Definition: AssnsTraits.h:120
typename assns_metadata_type< Assns >::type assns_metadata_t
Trait: type of metadata in Assns (association or its node).
Definition: AssnsTraits.h:59
STL namespace.
Trait: type is metadata in Assns (association or its node).
Definition: AssnsTraits.h:54
details::node_of_t< assns_t > art_assns_node_t
Type of a node (element) in the association.
Definition: AssnsTraits.h:189
typename assns_iterator_type< Assns >::type assns_iterator_t
Trait: type of iterator of Assns.
Definition: AssnsTraits.h:71
Trait: value true if Assns (association or its node) has metadata.
Definition: AssnsTraits.h:44
L left_t
Type at the left side of the association.
Definition: AssnsTraits.h:176
std::negation< std::is_same< A, B >> is_not_same
The negation of std::is_same.
Definition: MetaUtils.h:166
constexpr bool assns_has_metadata_v
Trait: true if Assns (association or its node) has metadata.
Definition: AssnsTraits.h:49
R right_t
Type at the right side of the association.
Definition: AssnsTraits.h:177
D data_t
Type of data bound to the association.
Definition: AssnsTraits.h:178
Data types for the specified association type (or its node).
Definition: AssnsTraits.h:98
typename assns_iterator_type< assns_t >::type assns_iterator_t
Type of the association iterator.
Definition: AssnsTraits.h:186
LArSoft-specific namespace.
data_t const * dataptr_t
Pointer to the bound metadata.
Definition: AssnsTraits.h:181
Definition: MVAAlg.h:12
typename node_of< Assns >::type node_of_t
Definition: AssnsTraits.h:126
typename art::const_AssnsIter< L, R, D, Direction::Forward > const_iterator
Definition: Assns.h:239
Trait: type is iterator of Assns.
Definition: AssnsTraits.h:66