LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 
25 namespace lar {
26 
27  namespace util {
28 
29  //--- BEGIN Traits for art associations ------------------------------------
39 
41 
42  //--------------------------------------------------------------------------
43  // was proxy::details::hasMetadata
45  template <typename Assns>
47 
48  // was: proxy::details::AssnWithMetadata_v
50  template <typename Assns>
52 
53 
54  // was: proxy::details::AssnsMetadataTypeStruct, proxy::details::AssnNodeMetadataType
56  template <typename Assns>
58 
59  // was: proxy::details::AssnsMetadata_t, proxy::details::AssnNodeMetadata_t
61  template <typename Assns>
63 
64 
65  //--------------------------------------------------------------------------
66  // FIXME simplify this code if issue #18769 is accepted
67  // was: proxy::details::AssnsIteratorTypeStruct
69  template <typename Assns>
71 
73  // was: proxy::details::AssnsIterator_t
74  template <typename Assns>
76 
77  //--------------------------------------------------------------------------
78  // was: proxy::details::AssnsNodeTraits
101  template <typename Assns>
102  struct assns_traits;
103 
104 
105  //--------------------------------------------------------------------------
106 
108  //--- END Traits for art associations --------------------------------------
109 
110  } // namespace util
111 
112 } // namespace lar
113 
114 
115 
116 //------------------------------------------------------------------------------
117 //--- template implementation
118 //------------------------------------------------------------------------------
119 namespace lar {
120 
121  namespace util {
122 
123  namespace details {
124 
125  // was: proxy::details::isAssnMetadata
126  template <typename T>
128 
129 
130  template <typename Assns>
131  struct node_of;
132 
133  template <typename Assns>
134  using node_of_t = typename node_of<Assns>::type;
135 
136  template <typename L, typename R, typename D>
137  struct node_of<art::Assns<L, R, D>> {
139  };
140 
141  template <typename L, typename R>
142  struct node_of<art::Assns<L, R, void>> {
143  using type = std::pair<art::Ptr<L>, art::Ptr<R>>;
144  };
145 
146  } // namespace details
147 
148  //--------------------------------------------------------------------------
149  template <typename L, typename R, typename D>
150  struct assns_metadata_type<art::Assns<L, R, D>> {
151  using type = D;
152  };
153 
154  template <typename L, typename R, typename D>
155  struct assns_metadata_type<art::AssnsNode<L, R, D>> {
156  using type = D;
157  };
158 
159  template <typename L, typename R>
160  struct assns_metadata_type<std::pair<art::Ptr<L>, art::Ptr<R>>> {
161  using type = void;
162  };
163 
164 
165  //--------------------------------------------------------------------------
166  template <typename Assns>
167  struct assns_has_metadata
168  : details::isAssnMetadata<assns_metadata_t<Assns>>
169  {};
170 
171 
172  //--------------------------------------------------------------------------
173  template <typename L, typename R, typename D>
174  struct assns_iterator_type<art::Assns<L, R, D>> {
176  }; // struct assns_iterator_type
177 
178 
179  template <typename L, typename R>
180  struct assns_iterator_type<art::Assns<L, R, void>> {
182  };
183 
184 
185  //--------------------------------------------------------------------------
186  // was proxy::details::AssnsNodeTraitsBase
187  template <typename L, typename R, typename D>
188  struct assns_traits<art::Assns<L, R, D>> {
189 
190  using left_t = L;
191  using right_t = R;
192  using data_t = D;
195  using dataptr_t = data_t const*;
196 
198 
201 
204 
206  static constexpr bool hasMetadata = details::isAssnMetadata<data_t>();
207 
208  }; // struct assns_traits<Assns<L,R,D>>
209 
210 
211  template <typename L, typename R, typename D>
212  struct assns_traits<art::AssnsNode<L, R, D>>
213  : public assns_traits<art::Assns<L, R, D>>
214  {};
215 
216  template <typename L, typename R>
217  struct assns_traits<std::pair<art::Ptr<L>, art::Ptr<R>>>
218  : public assns_traits<art::Assns<L, R>>
219  {};
220 
221 
222  //--------------------------------------------------------------------------
223 
224  } // namespace util
225 
226 } // namespace lar
227 
228 
229 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_ASSNSTRAITS_H
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:17
Basic C++ metaprogramming utilities.
::util::is_not_same< T, void > isAssnMetadata
Definition: AssnsTraits.h:127
typename art::Assns< L, R, D >::const_iterator type
Definition: AssnsTraits.h:175
typename assns_metadata_type< Assns >::type assns_metadata_t
Trait: type of metadata in Assns (association or its node).
Definition: AssnsTraits.h:62
STL namespace.
Trait: type is metadata in Assns (association or its node).
Definition: AssnsTraits.h:57
details::node_of_t< assns_t > art_assns_node_t
Type of a node (element) in the association.
Definition: AssnsTraits.h:203
typename assns_iterator_type< Assns >::type assns_iterator_t
Trait: type of iterator of Assns.
Definition: AssnsTraits.h:75
Trait: value true if Assns (association or its node) has metadata.
Definition: AssnsTraits.h:46
L left_t
Type at the left side of the association.
Definition: AssnsTraits.h:190
constexpr bool assns_has_metadata_v
Trait: true if Assns (association or its node) has metadata.
Definition: AssnsTraits.h:51
R right_t
Type at the right side of the association.
Definition: AssnsTraits.h:191
Double_t R
D data_t
Type of data bound to the association.
Definition: AssnsTraits.h:192
Data types for the specified association type (or its node).
Definition: AssnsTraits.h:102
typename assns_iterator_type< assns_t >::type assns_iterator_t
Type of the association iterator.
Definition: AssnsTraits.h:200
negation< std::is_same< A, B >> is_not_same
Definition: MetaUtils.h:178
LArSoft-specific namespace.
data_t const * dataptr_t
Pointer to the bound metadata.
Definition: AssnsTraits.h:195
HLT enums.
std::pair< art::Ptr< L >, art::Ptr< R >> type
Definition: AssnsTraits.h:143
typename node_of< Assns >::type node_of_t
Definition: AssnsTraits.h:134
typename art::Assns< L, R, void >::assn_iterator type
Definition: AssnsTraits.h:181
typename art::const_AssnsIter< L, R, D, Direction::Forward > const_iterator
Definition: Assns.h:217
Trait: type is iterator of Assns.
Definition: AssnsTraits.h:70