3 #ifndef FALAISE_QUANTITY_H 4 #define FALAISE_QUANTITY_H 7 #include "CLHEP/Units/PhysicalConstants.h" 8 #include "CLHEP/Units/SystemOfUnits.h" 10 #include "boost/metaparse/string.hpp" 11 #include "boost/mpl/string.hpp" 40 #define FALAISE_ADD_DIMENSION_TAG(Tag) \ 44 typedef BOOST_METAPARSE_STRING(#Tag) label; \ 46 using Tag##_t = quantity_t<Tag>; \ 54 using std::logic_error::logic_error;
59 using std::logic_error::logic_error;
121 inline double operator()()
const {
return value_ * unit_scale; }
133 inline double value()
const {
return value_; }
149 inline std::string
const&
unit()
const {
return unit_name; }
152 inline std::string
const&
dimension()
const {
return dimension_name; }
156 std::string unit_name{
""};
157 std::string dimension_name{
""};
158 double unit_scale{1.0};
184 template <
typename Dimension>
195 boost::mpl::c_str<typename Dimension::label>::
value)) {}
206 if (boost::mpl::c_str<typename Dimension::label>::value !=
dimension()) {
208 boost::mpl::c_str<typename Dimension::label>::value +
"'");
double value() const
Return the value for the quantity in its units.
Definition: quantity.h:133
Class representing a value and physical unit.
Definition: quantity.h:90
std::string const & unit() const
Return datatools::units tag for the quantity's unit.
Definition: quantity.h:149
#define FALAISE_ADD_DIMENSION_TAG(Tag)
Register a dimension tag for use as a falaise::config::quantity_t template parameter.
Definition: quantity.h:40
Definition: metadata_utils.h:35
double operator()() const
Convert quantity to double value in the CLHEP::Units numeric scaling system.
Definition: quantity.h:121
Exception reporting wrong or incompatible dimensions.
Definition: quantity.h:53
quantity_t(quantity const &q)
Copy constructor from a raw quantity.
Definition: quantity.h:219
Template class for a physical value with a strict dimension.
Definition: quantity.h:185
Exception reporting unknown unit tags.
Definition: quantity.h:58
virtual ~quantity_t()=default
Destructor.
double value_in(std::string const &unit) const
Return value for the quantity in given units.
quantity_t()
Default constructor.
Definition: quantity.h:193
std::string const & dimension() const
Return datatools::unit tag for the quantity's dimension.
Definition: quantity.h:152
quantity_t(double value, std::string const &unit)
Construct a quantity from a value and unit.
Definition: quantity.h:205
quantity()=default
Default constructor.
virtual ~quantity()=default
Destructor.