Float.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2023-02-06
  7. *
  8. * */
  9. #ifndef LS_STD_FLOAT_HPP
  10. #define LS_STD_FLOAT_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. namespace ls::std::boxing
  16. {
  17. class LS_STD_DYNAMIC_GOAL Float : public ls::std::core::Class, public ls::std::core::interface_type::IBoxing
  18. {
  19. public:
  20. Float();
  21. explicit Float(float _value);
  22. ~Float() override;
  23. // conversion operator
  24. operator float() const; // do not make explicit!
  25. // assignment operators
  26. ls::std::boxing::Float &operator=(float _value);
  27. // arithmetic operators
  28. float operator-() const;
  29. float operator+(const ls::std::boxing::Float &_float) const;
  30. float operator+(float _value) const;
  31. float operator*(const ls::std::boxing::Float &_float) const;
  32. float operator*(float _value) const;
  33. float operator-(const ls::std::boxing::Float &_float) const;
  34. float operator-(float _value) const;
  35. float operator/(const ls::std::boxing::Float &_float) const;
  36. float operator/(float _value) const;
  37. // compound operators
  38. ls::std::boxing::Float &operator+=(const ls::std::boxing::Float &_float);
  39. ls::std::boxing::Float &operator+=(float _value);
  40. ls::std::boxing::Float &operator-=(const ls::std::boxing::Float &_float);
  41. ls::std::boxing::Float &operator-=(float _value);
  42. ls::std::boxing::Float &operator*=(const ls::std::boxing::Float &_float);
  43. ls::std::boxing::Float &operator*=(float _value);
  44. ls::std::boxing::Float &operator/=(const ls::std::boxing::Float &_float);
  45. ls::std::boxing::Float &operator/=(float _value);
  46. // comparison operators
  47. bool operator==(const ls::std::boxing::Float &_float) const;
  48. bool operator==(float _value) const;
  49. bool operator!=(const ls::std::boxing::Float &_float) const;
  50. bool operator!=(float _value) const;
  51. bool operator>(const ls::std::boxing::Float &_float) const;
  52. bool operator>(float _value) const;
  53. bool operator>=(const ls::std::boxing::Float &_float) const;
  54. bool operator>=(float _value) const;
  55. bool operator<(const ls::std::boxing::Float &_float) const;
  56. bool operator<(float _value) const;
  57. bool operator<=(const ls::std::boxing::Float &_float) const;
  58. bool operator<=(float _value) const;
  59. // increment / decrement operator
  60. void operator++();
  61. void operator--();
  62. // implementation
  63. void parse(::std::string _parseText) override;
  64. [[nodiscard]] ::std::string toString() override;
  65. // additional functionality
  66. [[nodiscard]] float getEpsilon();
  67. [[nodiscard]] float getValue();
  68. void setEpsilon(float _epsilon);
  69. private:
  70. float epsilon{};
  71. float value{};
  72. void _assignEpsilon(float _epsilon);
  73. };
  74. }
  75. #endif