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