diff --git a/src/systems/isq/CMakeLists.txt b/src/systems/isq/CMakeLists.txt index c7dffcfc..bb575c65 100644 --- a/src/systems/isq/CMakeLists.txt +++ b/src/systems/isq/CMakeLists.txt @@ -49,6 +49,7 @@ add_units_module( include/units/isq/dimensions/inductance.h include/units/isq/dimensions/length.h include/units/isq/dimensions/luminance.h + include/units/isq/dimensions/luminous_flux.h include/units/isq/dimensions/luminous_intensity.h include/units/isq/dimensions/magnetic_flux.h include/units/isq/dimensions/magnetic_induction.h diff --git a/src/systems/isq/include/units/isq/dimensions.h b/src/systems/isq/include/units/isq/dimensions.h index a4e8dd1d..4983390c 100644 --- a/src/systems/isq/include/units/isq/dimensions.h +++ b/src/systems/isq/include/units/isq/dimensions.h @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include diff --git a/src/systems/isq/include/units/isq/dimensions/luminous_flux.h b/src/systems/isq/include/units/isq/dimensions/luminous_flux.h new file mode 100644 index 00000000..a86a6285 --- /dev/null +++ b/src/systems/isq/include/units/isq/dimensions/luminous_flux.h @@ -0,0 +1,36 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include + +namespace units::isq { + +template +using dim_luminous_flux = dim_power; + +template +concept LuminousFlux = QuantityOfT; + +} // namespace units::isq diff --git a/src/systems/si/CMakeLists.txt b/src/systems/si/CMakeLists.txt index f591c780..052d6d3c 100644 --- a/src/systems/si/CMakeLists.txt +++ b/src/systems/si/CMakeLists.txt @@ -50,6 +50,7 @@ add_units_module( include/units/isq/si/inductance.h include/units/isq/si/length.h include/units/isq/si/luminance.h + include/units/isq/si/luminous_flux.h include/units/isq/si/luminous_intensity.h include/units/isq/si/magnetic_flux.h include/units/isq/si/magnetic_induction.h diff --git a/src/systems/si/include/units/isq/si/luminous_flux.h b/src/systems/si/include/units/isq/si/luminous_flux.h new file mode 100644 index 00000000..7d9592e3 --- /dev/null +++ b/src/systems/si/include/units/isq/si/luminous_flux.h @@ -0,0 +1,89 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +// IWYU pragma: begin_exports +#include +#include +#include +#include +// IWYU pragma: end_exports + +#include +#include + +namespace units::isq::si { + +// TODO Is this correct? Should we account for steradian here? How? + +struct lumen : named_scaled_unit {}; + +using dim_luminous_flux = dim_power; + +template U, Representation Rep = double> +using luminous_flux = power; + +#ifndef UNITS_NO_LITERALS + +inline namespace literals { + +// lm +constexpr auto operator"" _q_lm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_flux(static_cast(l)); +} +constexpr auto operator"" _q_lm(long double l) { return luminous_flux(l); } + +} // namespace literals + +#endif // UNITS_NO_LITERALS + +#ifndef UNITS_NO_REFERENCES + +namespace luminous_flux_references { + +inline constexpr auto lm = reference{}; + +} // namespace luminous_flux_references + +namespace references { + +using namespace luminous_flux_references; + +} // namespace references + +#endif // UNITS_NO_REFERENCES + +} // namespace units::isq::si + +#ifndef UNITS_NO_ALIASES + +namespace units::aliases::isq::si::inline luminous_flux { + +template +using lm = units::isq::si::luminous_flux; + +} // namespace units::aliases::isq::si::inline luminous_flux + +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/si.h b/src/systems/si/include/units/isq/si/si.h index d7095a6e..369d6f3d 100644 --- a/src/systems/si/include/units/isq/si/si.h +++ b/src/systems/si/include/units/isq/si/si.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index 5155f916..ff32ecc7 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -239,6 +239,12 @@ static_assert(gray::symbol == "Gy"); static_assert(milligray::symbol == "mGy"); static_assert(kilogray::symbol == "kGy"); +// luminous flux + +static_assert(683_q_lm == 1_q_W); + +static_assert(lumen::symbol == "lm"); + /* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ // speed