TBTK
Need a break? Support the development by playing Polarity Puzzles
Constants.h
1 /* Copyright 2019 Kristofer Björnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
17 
24 #ifndef COM_DAFER45_TBTK_QUANTITY_CONSTANTS
25 #define COM_DAFER45_TBTK_QUANTITY_CONSTANTS
26 
27 #include "TBTK/Quantity/Base.h"
28 #include "TBTK/Quantity/Constant.h"
29 #include "TBTK/Quantity/Derived.h"
30 #include "TBTK/TBTK.h"
31 #include "TBTK/UnitHandler.h"
32 
33 #include <cmath>
34 #include <map>
35 #include <string>
36 
37 namespace TBTK{
38 namespace Quantity{
39 
47 class Constants{
48 public:
52  static Constant get(const std::string &name);
53 private:
55  static std::map<std::string, Constant> constants;
56 
58  static void initialize();
59 
62  friend void TBTK::Initialize();
63 };
64 
65 inline Constant Constants::get(const std::string &name){
66  try{
67  return constants.at(name);
68  }
69  catch(const std::out_of_range &e){
70  TBTKExit(
71  "Constants::get()",
72  "Unknown constant '" << name << "'.",
73  ""
74  );
75  }
76 }
77 
78 }; //End of namesapce Quantity
79 }; //End of namesapce TBTK
80 
81 #endif
82 
Derived Quantity.
Handles conversions between different units.
TBTK initialization.
Definition: Boolean.h:32
void Initialize()
Base Quantity.