Float.hpp 2.7 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: 2020-09-04
  7. *
  8. * */
  9. #ifndef LS_STD_FLOAT_HPP
  10. #define LS_STD_FLOAT_HPP
  11. #include <memory>
  12. #include "../base/Class.hpp"
  13. #include "IBoxing.hpp"
  14. #include "../serialization/ISerializable.hpp"
  15. namespace ls_std {
  16. class Float : public Class, public IBoxing, public ISerializable {
  17. public:
  18. Float();
  19. explicit Float(float _value);
  20. ~Float() = default;
  21. // conversion operator
  22. operator float() const; // do not make explicit!
  23. // assignment operators
  24. Float& operator=(float _value);
  25. // arithmetic operators
  26. float operator-() const;
  27. float operator+(const Float& _float) const;
  28. float operator+(float _value) const;
  29. float operator*(const Float& _float) const;
  30. float operator*(float _value) const;
  31. float operator-(const Float& _float) const;
  32. float operator-(float _value) const;
  33. float operator/(const Float& _float) const;
  34. float operator/(float _value) const;
  35. // compound operators
  36. Float& operator+=(const Float& _float);
  37. Float& operator+=(float _value);
  38. Float& operator-=(const Float& _float);
  39. Float& operator-=(float _value);
  40. Float& operator*=(const Float& _float);
  41. Float& operator*=(float _value);
  42. Float& operator/=(const Float& _float);
  43. Float& operator/=(float _value);
  44. // comparison operators
  45. bool operator==(const Float& _float) const;
  46. bool operator==(float _value) const;
  47. bool operator!=(const Float& _float) const;
  48. bool operator!=(float _value) const;
  49. bool operator>(const Float& _float) const;
  50. bool operator>(float _value) const;
  51. bool operator>=(const Float& _float) const;
  52. bool operator>=(float _value) const;
  53. bool operator<(const Float& _float) const;
  54. bool operator<(float _value) const;
  55. bool operator<=(const Float& _float) const;
  56. bool operator<=(float _value) const;
  57. // increment / decrement operator
  58. void operator++();
  59. void operator--();
  60. // implementation
  61. ls_std::byte_field marshal() override;
  62. void parse(std::string _parseText) override;
  63. std::string toString() override;
  64. void unmarshal(const ls_std::byte_field& _data) override;
  65. // additional functionality
  66. float getEpsilon();
  67. float getValue();
  68. void setEpsilon(float _epsilon);
  69. void setSerializable(std::shared_ptr<ISerializable> _serializable);
  70. private:
  71. std::shared_ptr<ISerializable> serializable {};
  72. float value {};
  73. float epsilon {};
  74. };
  75. }
  76. #endif