src/core/utils/unit.h
System to support units in the framework. More…
Namespaces
Name |
---|
allpix Helper class to hold support layers for a detector model. |
Classes
Name | |
---|---|
class | allpix::Units Static class to access units. |
Detailed Description
System to support units in the framework.
Copyright: Copyright (c) 2017-2024 CERN and the Allpix Squared authors. This software is distributed under the terms of the MIT License, copied verbatim in the file “LICENSE.md”. In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any jurisdiction. SPDX-License-Identifier: MIT
Source code
#ifndef ALLPIX_UNIT_H
#define ALLPIX_UNIT_H
#include <initializer_list>
#include <limits>
#include <map>
#include <string>
#include <utility>
// TODO [doc] Check if this class can be constexpressed?
namespace allpix {
class Units {
public:
using UnitType = long double;
Units() = delete;
static void add(std::string str, UnitType value);
// TODO [doc] This function should likely be removed
static UnitType getSingle(std::string str);
// TODO [doc] This function should likely be removed
template <typename T> static T getSingle(T inp, std::string str);
// TODO [doc] This function should likely be removed
template <typename T> static T getSingleInverse(T inp, std::string str);
static UnitType get(const std::string& str);
template <typename T> static T get(T inp, const std::string& str);
// TODO [doc] This function should likely be removed
template <typename T> static T getInverse(T inp, const std::string& str);
// TODO [doc] This function should maybe be removed
// TODO [doc] Shall we change the name in something better here
static UnitType convert(UnitType input, std::string str);
static std::string display(UnitType input, std::initializer_list<std::string> units);
static std::string display(UnitType input, std::string unit);
template <typename T> static std::string display(T input, std::initializer_list<std::string> units);
private:
static std::map<std::string, UnitType> unit_map_;
};
} // namespace allpix
// Include template definitions
#include "unit.tpp"
#endif /* ALLPIX_UNIT_H */
Updated on 2024-12-13 at 08:31:37 +0000