LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
intervals_fhicl.h
Go to the documentation of this file.
1 
9 #ifndef LARDATAALG_UTILITIES_INTERVALS_FHICL_H
10 #define LARDATAALG_UTILITIES_INTERVALS_FHICL_H
11 
12 // LArSoft libraries
13 #include "larcorealg/CoreUtils/StdUtils.h" // util::to_string()
16 
17 // support libraries
18 #include "fhiclcpp/coding.h"
19 
20 // C++ libraries
21 #include <any>
22 #include <string>
23 #include <string_view>
24 
26 
27  // --- BEGIN -- FHiCL encoding ---------------------------------------------
30 
31  // these utilities need to be defined in the same namespace as `Quantity`
32 
45  template <typename... Args>
46  void decode(std::any const& src, Interval<Args...>& iv);
47 
60  template <typename... Args>
61  void decode(std::any const& src, Point<Args...>& p);
62 
74  template <typename... Args>
75  ::fhicl::detail::ps_atom_t encode(Interval<Args...> const& iv);
76 
88  template <typename... Args>
89  ::fhicl::detail::ps_atom_t encode(Point<Args...> const& pt);
90 
92  // --- END -- FHiCL encoding -----------------------------------------------
93 
94 } // namespace util::quantities::concepts
95 
96 // -----------------------------------------------------------------------------
97 // --- template implementation
98 // -----------------------------------------------------------------------------
99 template <typename... Args>
101 {
102  using interval_t = Interval<Args...>;
103  using quantity_t = typename interval_t::quantity_t;
104 
105  quantity_t q;
107  iv = interval_t{q};
108 
109 } // util::quantities::concepts::decode(Interval)
110 
111 // -----------------------------------------------------------------------------
112 template <typename... Args>
114 {
115  using point_t = Point<Args...>;
116  using quantity_t = typename point_t::quantity_t;
117 
118  quantity_t q;
120  pt = point_t{q};
121 
122 } // util::quantities::concepts::decode(Point)
123 
124 // -----------------------------------------------------------------------------
125 template <typename... Args>
127 {
129 } // util::quantities::concepts::encode(Interval)
130 
131 // -----------------------------------------------------------------------------
132 template <typename... Args>
134 {
136 } // util::quantities::concepts::encode(Point)
137 
138 // -----------------------------------------------------------------------------
139 
140 #endif // LARDATAALG_UTILITIES_INTERVALS_FHICL_H
::fhicl::detail::ps_atom_t encode(Point< Args... > const &pt)
Encodes a quantity point into a FHiCL parameter set atom.
::fhicl::detail::ps_atom_t encode(Interval< Args... > const &iv)
Encodes a quantity interval into a FHiCL parameter set atom.
Infrastructure for the quantities library.
Definition: intervals.h:25
Defines point and interval variables based on quantities.
Utilities to read and write quantities in FHiCL configuration.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
TMarker * pt
Definition: egs.C:25
An interval (duration, length, distance) between two quantity points.
Definition: intervals.h:106
void decode(std::any const &src, Interval< Args... > &iv)
Decodes an interval.
std::string ps_atom_t
Definition: coding.h:44
Functions pulling in STL customization if available.