abstract.hpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Boost.Units - A C++ library for zero-overhead dimensional analysis and
  2. // unit/quantity manipulation and conversion
  3. //
  4. // Copyright (C) 2003-2008 Matthias Christian Schabel
  5. // Copyright (C) 2008 Steven Watanabe
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See
  8. // accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_UNITS_ABSTRACT_HPP
  11. #define BOOST_UNITS_ABSTRACT_HPP
  12. #include <string>
  13. #include <boost/units/conversion.hpp>
  14. #include <boost/units/unit.hpp>
  15. #include <boost/units/make_system.hpp>
  16. #include <boost/units/base_unit.hpp>
  17. #include <boost/units/physical_dimensions/amount.hpp>
  18. #include <boost/units/physical_dimensions/current.hpp>
  19. #include <boost/units/physical_dimensions/length.hpp>
  20. #include <boost/units/physical_dimensions/luminous_intensity.hpp>
  21. #include <boost/units/physical_dimensions/mass.hpp>
  22. #include <boost/units/physical_dimensions/plane_angle.hpp>
  23. #include <boost/units/physical_dimensions/solid_angle.hpp>
  24. #include <boost/units/physical_dimensions/temperature.hpp>
  25. #include <boost/units/physical_dimensions/time.hpp>
  26. namespace boost {
  27. namespace units {
  28. namespace abstract {
  29. struct length_unit_tag : base_unit<length_unit_tag, length_dimension, -30> { };
  30. struct mass_unit_tag : base_unit<mass_unit_tag, mass_dimension, -29> { };
  31. struct time_unit_tag : base_unit<time_unit_tag, time_dimension, -28> { };
  32. struct current_unit_tag : base_unit<current_unit_tag, current_dimension, -27> { };
  33. struct temperature_unit_tag : base_unit<temperature_unit_tag, temperature_dimension, -26> { };
  34. struct amount_unit_tag : base_unit<amount_unit_tag, amount_dimension, -25> { };
  35. struct luminous_intensity_unit_tag : base_unit<luminous_intensity_unit_tag, luminous_intensity_dimension, -24> { };
  36. struct plane_angle_unit_tag : base_unit<plane_angle_unit_tag, plane_angle_dimension, -23> { };
  37. struct solid_angle_unit_tag : base_unit<solid_angle_unit_tag, solid_angle_dimension, -22> { };
  38. typedef make_system<
  39. length_unit_tag,
  40. mass_unit_tag,
  41. time_unit_tag,
  42. current_unit_tag,
  43. temperature_unit_tag,
  44. amount_unit_tag,
  45. luminous_intensity_unit_tag,
  46. plane_angle_unit_tag,
  47. solid_angle_unit_tag
  48. >::type system;
  49. typedef unit<length_dimension,system> length; ///< abstract unit of length
  50. typedef unit<mass_dimension,system> mass; ///< abstract unit of mass
  51. typedef unit<time_dimension,system> time; ///< abstract unit of time
  52. typedef unit<current_dimension,system> current; ///< abstract unit of current
  53. typedef unit<temperature_dimension,system> temperature; ///< abstract unit of temperature
  54. typedef unit<amount_dimension,system> amount; ///< abstract unit of amount
  55. typedef unit<luminous_intensity_dimension,system> luminous_intensity; ///< abstract unit of luminous intensity
  56. typedef unit<plane_angle_dimension,system> plane_angle; ///< abstract unit of plane angle
  57. typedef unit<solid_angle_dimension,system> solid_angle; ///< abstract unit of solid angle
  58. } // namespace abstract
  59. template<>
  60. struct base_unit_info<abstract::length_unit_tag>
  61. {
  62. static std::string name() { return "[Length]"; }
  63. static std::string symbol() { return "[L]"; }
  64. };
  65. template<>
  66. struct base_unit_info<abstract::mass_unit_tag>
  67. {
  68. static std::string name() { return "[Mass]"; }
  69. static std::string symbol() { return "[M]"; }
  70. };
  71. template<>
  72. struct base_unit_info<abstract::time_unit_tag>
  73. {
  74. static std::string name() { return "[Time]"; }
  75. static std::string symbol() { return "[T]"; }
  76. };
  77. template<>
  78. struct base_unit_info<abstract::current_unit_tag>
  79. {
  80. static std::string name() { return "[Electric Current]"; }
  81. static std::string symbol() { return "[I]"; }
  82. };
  83. template<>
  84. struct base_unit_info<abstract::temperature_unit_tag>
  85. {
  86. static std::string name() { return "[Temperature]"; }
  87. static std::string symbol() { return "[Theta]"; }
  88. };
  89. template<>
  90. struct base_unit_info<abstract::amount_unit_tag>
  91. {
  92. static std::string name() { return "[Amount]"; }
  93. static std::string symbol() { return "[N]"; }
  94. };
  95. template<>
  96. struct base_unit_info<abstract::luminous_intensity_unit_tag>
  97. {
  98. static std::string name() { return "[Luminous Intensity]"; }
  99. static std::string symbol() { return "[J]"; }
  100. };
  101. template<>
  102. struct base_unit_info<abstract::plane_angle_unit_tag>
  103. {
  104. static std::string name() { return "[Plane Angle]"; }
  105. static std::string symbol() { return "[QP]"; }
  106. };
  107. template<>
  108. struct base_unit_info<abstract::solid_angle_unit_tag>
  109. {
  110. static std::string name() { return "[Solid Angle]"; }
  111. static std::string symbol() { return "[QS]"; }
  112. };
  113. } // namespace units
  114. } // namespace boost
  115. #endif // BOOST_UNITS_ABSTRACT_HPP