Elements  5.8
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Storage.cpp
Go to the documentation of this file.
1 
21 #include "ElementsKernel/Storage.h"
22 
23 #include <map> // for map
24 #include <cstdint> // for int64_t
25 #include <cstddef> // for size_t
26 #include <cmath> // for pow, round, log10
27 #include <string> // for string
28 
29 using std::pow;
30 using std::map;
31 using std::int64_t;
32 using std::size_t;
33 
34 namespace Elements {
35 namespace Units {
36 
38  { StorageType::KiloByte, "KiB"},
39  { StorageType::MegaByte, "MiB"},
40  { StorageType::GigaByte, "GiB"},
41  { StorageType::TeraByte, "TiB"},
42  { StorageType::PetaByte, "PiB"},
47  { StorageType::MetricPetaByte, "PB"} };
48 
50  { StorageType::KiloByte, pow(2, 10)},
51  { StorageType::MegaByte, pow(2, 20)},
52  { StorageType::GigaByte, pow(2, 30)},
53  { StorageType::TeraByte, pow(2, 40)},
54  { StorageType::PetaByte, pow(2, 50)},
55  { StorageType::MetricKiloByte, pow(10, 3)},
56  { StorageType::MetricMegaByte, pow(10, 6)},
57  { StorageType::MetricGigaByte, pow(10, 9)},
58  { StorageType::MetricTeraByte, pow(10, 12)},
59  { StorageType::MetricPetaByte, pow(10, 15)} };
60 
61 // explicit instantiation: without the template<>. Otherwise this is a template specialization
62 template double roundToDigits<double>(const double& value, const size_t& max_digits);
63 template float roundToDigits<float>(const float& value, const size_t& max_digits);
64 
65 template double storageConvert<double>(const double& size, StorageType source_unit, StorageType target_unit);
66 template float storageConvert<float>(const float& size, StorageType source_unit, StorageType target_unit);
67 template int64_t storageConvert<int64_t>(const int64_t& size, StorageType source_unit, StorageType target_unit);
68 
69 } // namespace Units
70 } // namespace Elements
template ELEMENTS_API float storageConvert< float >(const float &size, StorageType source_unit, StorageType target_unit)
STL class.
ELEMENTS_API std::map< StorageType, std::string > StorageShortName
Definition: Storage.cpp:37
template ELEMENTS_API double roundToDigits< double >(const double &value, const std::size_t &max_digits)
template ELEMENTS_API double storageConvert< double >(const double &size, StorageType source_unit, StorageType target_unit)
T pow(T...args)
template int64_t storageConvert< int64_t >(const int64_t &size, StorageType source_unit, StorageType target_unit)
template ELEMENTS_API float roundToDigits< float >(const float &value, const std::size_t &max_digits)
ELEMENTS_API std::map< StorageType, std::int64_t > StorageFactor
Definition: Storage.cpp:49