feat: luminous_flux support added

This commit is contained in:
Mateusz Pusz
2022-05-13 14:31:13 +02:00
parent 10f8254cc8
commit 13f03bfe70
7 changed files with 135 additions and 0 deletions

View File

@@ -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

View File

@@ -48,6 +48,7 @@
#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>

View File

@@ -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 <units/concepts.h>
#include <units/isq/dimensions/power.h>
namespace units::isq {
template<typename Child, Unit U, typename... Dims>
using dim_luminous_flux = dim_power<Child, U, Dims...>;
template<typename T>
concept LuminousFlux = QuantityOfT<T, dim_luminous_flux>;
} // namespace units::isq

View File

@@ -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

View File

@@ -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 <units/isq/si/power.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
#include <units/isq/si/prefixes.h>
#include <units/unit.h>
namespace units::isq::si {
// TODO Is this correct? Should we account for steradian here? How?
struct lumen : named_scaled_unit<lumen, "lm", ratio(1, 683), watt> {};
using dim_luminous_flux = dim_power;
template<UnitOf<dim_luminous_flux> U, Representation Rep = double>
using luminous_flux = power<U, Rep>;
#ifndef UNITS_NO_LITERALS
inline namespace literals {
// lm
constexpr auto operator"" _q_lm(unsigned long long l)
{
gsl_ExpectsAudit(std::in_range<std::int64_t>(l));
return luminous_flux<lumen, std::int64_t>(static_cast<std::int64_t>(l));
}
constexpr auto operator"" _q_lm(long double l) { return luminous_flux<lumen, long double>(l); }
} // namespace literals
#endif // UNITS_NO_LITERALS
#ifndef UNITS_NO_REFERENCES
namespace luminous_flux_references {
inline constexpr auto lm = reference<dim_luminous_flux, lumen>{};
} // 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<Representation Rep = double>
using lm = units::isq::si::luminous_flux<units::isq::si::lumen, Rep>;
} // namespace units::aliases::isq::si::inline luminous_flux
#endif // UNITS_NO_ALIASES

View File

@@ -47,6 +47,7 @@
#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>

View File

@@ -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