Double.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2024-05-25
  7. *
  8. * */
  9. #ifndef LS_STD_DOUBLE_HPP
  10. #define LS_STD_DOUBLE_HPP
  11. #include <ls-std/core/Class.hpp>
  12. #include <ls-std/core/interface/IBoxing.hpp>
  13. #include <ls-std/os/dynamic-goal.hpp>
  14. #include <memory>
  15. /*
  16. * @class(name: 'Double', package: 'boxing')
  17. * */
  18. namespace ls::std::boxing
  19. {
  20. class LS_STD_DYNAMIC_GOAL Double : public ls::std::core::Class, public ls::std::core::interface_type::IBoxing
  21. {
  22. public:
  23. Double();
  24. explicit Double(double _value);
  25. ~Double() noexcept override;
  26. // assignment operators
  27. ls::std::boxing::Double &operator=(double _value);
  28. // arithmetic operators
  29. double operator-() const;
  30. double operator+(const ls::std::boxing::Double &_double) const;
  31. double operator+(double _value) const;
  32. double operator*(const ls::std::boxing::Double &_double) const;
  33. double operator*(double _value) const;
  34. double operator-(const ls::std::boxing::Double &_double) const;
  35. double operator-(double _value) const;
  36. double operator/(const ls::std::boxing::Double &_double) const;
  37. double operator/(double _value) const;
  38. // compound operators
  39. ls::std::boxing::Double &operator+=(const ls::std::boxing::Double &_double);
  40. ls::std::boxing::Double &operator+=(double _value);
  41. ls::std::boxing::Double &operator-=(const ls::std::boxing::Double &_double);
  42. ls::std::boxing::Double &operator-=(double _value);
  43. ls::std::boxing::Double &operator*=(const ls::std::boxing::Double &_double);
  44. ls::std::boxing::Double &operator*=(double _value);
  45. ls::std::boxing::Double &operator/=(const ls::std::boxing::Double &_double);
  46. ls::std::boxing::Double &operator/=(double _value);
  47. // comparison operators
  48. bool operator==(const ls::std::boxing::Double &_double) const;
  49. bool operator==(double _value) const;
  50. bool operator!=(const ls::std::boxing::Double &_double) const;
  51. bool operator!=(double _value) const;
  52. bool operator>(const ls::std::boxing::Double &_double) const;
  53. bool operator>(double _value) const;
  54. bool operator>=(const ls::std::boxing::Double &_double) const;
  55. bool operator>=(double _value) const;
  56. bool operator<(const ls::std::boxing::Double &_double) const;
  57. bool operator<(double _value) const;
  58. bool operator<=(const ls::std::boxing::Double &_double) const;
  59. bool operator<=(double _value) const;
  60. // increment / decrement operator
  61. void operator++();
  62. void operator--();
  63. // implementation
  64. void parse(const ::std::string &_parseText) override;
  65. [[nodiscard]] ::std::string toString() override;
  66. // additional functionality
  67. [[nodiscard]] double getEpsilon() const;
  68. [[nodiscard]] double getValue() const;
  69. void setEpsilon(double _epsilon);
  70. private:
  71. double epsilon{};
  72. double value{};
  73. void _assignEpsilon(double _epsilon);
  74. [[nodiscard]] static ::std::string _fetchClassName();
  75. };
  76. }
  77. #endif