Float.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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-22
  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() noexcept override;
  23. // assignment operators
  24. ls::std::boxing::Float &operator=(float _value);
  25. // arithmetic operators
  26. float operator-() const;
  27. float operator+(const ls::std::boxing::Float &_float) const;
  28. float operator+(float _value) 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. // compound operators
  36. ls::std::boxing::Float &operator+=(const ls::std::boxing::Float &_float);
  37. ls::std::boxing::Float &operator+=(float _value);
  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. // comparison operators
  45. bool operator==(const ls::std::boxing::Float &_float) const;
  46. bool operator==(float _value) const;
  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. // increment / decrement operator
  58. void operator++();
  59. void operator--();
  60. // implementation
  61. void parse(::std::string _parseText) override;
  62. [[nodiscard]] ::std::string toString() override;
  63. // additional functionality
  64. [[nodiscard]] float getEpsilon() const;
  65. [[nodiscard]] float getValue() const;
  66. void setEpsilon(float _epsilon);
  67. private:
  68. float epsilon{};
  69. float value{};
  70. void _assignEpsilon(float _epsilon);
  71. };
  72. }
  73. #endif