Class that stores all the units, prefixes and names of base units used.
The UnitTable encapsulates all the containers that are needed to store all the Units defined. Those containers are:
- A table (hash map) that stores all the Units
- A hash map that stores all the Prefixes
- An array to store the base units names
The names and the design is based on the corresponding ones of MOD2C. The table is a hash map that uses as key the name of the Unit and as objects a shared_ptr to a Unit. This is needed as the parser passes to the UnitTable shared_ptrs, so that there is no need to allocate more space for the units or take care of the deallocation of the memory, which is done automatically by the smart pointer. A shared_ptr to a UnitTable is kept by the UnitDriver, to be able to populate the UnitTable by using multiple sources (files and strings). The UnitTable takes care of inserting Units, Prefixes and base units to the table calculating or the needed factors and dimensions.
Definition at line 240 of file units.hpp.
|
| UnitTable ()=default |
| Default constructor for UnitTable. More...
|
|
void | calc_nominator_dims (const std::shared_ptr< Unit > &unit, std::string nominator_name) |
| Calculate unit's dimensions based on its nominator unit named nominator_name which is stored in the UnitTable's table. More...
|
|
void | calc_denominator_dims (const std::shared_ptr< Unit > &unit, std::string denominator_name) |
| Calculate unit's dimensions based on its denominator unit named denominator_name which is stored in the UnitTable's table. More...
|
|
void | insert (const std::shared_ptr< Unit > &unit) |
| Insert a unit to the UnitTable table and calculate its dimensions and factor based on the previously stored units in the UnitTable The unit can be a normal unit or unit based on just a base unit. More...
|
|
void | insert_prefix (const std::shared_ptr< Prefix > &prfx) |
| Insert a prefix to the prefixes of the UnitTable. More...
|
|
const std::shared_ptr< Unit > & | get_unit (const std::string &unit_name) const |
| Get the unit_name of the UnitTable's table. More...
|
|
void | print_units_sorted (std::ostream &units_details) const |
| Print the details of the units that are stored in the UnitTable to the output stream units_details in ascending order to be printed in tests in specific order. More...
|
|
void | print_base_units (std::ostream &base_units_details) const |
| Print the base units that are stored in the UnitTable to the output stream base_units_details. More...
|
|
const std::string & | get_base_unit_name (int id) const noexcept |
| Get base unit name based on the ID number of the dimension. More...
|
|