Double.hpp 2.8 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: 2020-09-04
  7. *
  8. * */
  9. #ifndef LS_STD_DOUBLE_HPP
  10. #define LS_STD_DOUBLE_HPP
  11. #include <memory>
  12. #include "../base/Class.hpp"
  13. #include "IBoxing.hpp"
  14. #include "../serialization/ISerializable.hpp"
  15. namespace ls_std {
  16. class Double : public Class, public IBoxing, public ISerializable {
  17. public:
  18. Double();
  19. explicit Double(double _value);
  20. ~Double() = default;
  21. // conversion operator
  22. operator double() const; // do not make explicit!
  23. // assignment operators
  24. Double& operator=(double _value);
  25. // arithmetic operators
  26. double operator-() const;
  27. double operator+(const Double& _double) const;
  28. double operator+(double _value) const;
  29. double operator*(const Double& _double) const;
  30. double operator*(double _value) const;
  31. double operator-(const Double& _double) const;
  32. double operator-(double _value) const;
  33. double operator/(const Double& _double) const;
  34. double operator/(double _value) const;
  35. // compound operators
  36. Double& operator+=(const Double& _double);
  37. Double& operator+=(double _value);
  38. Double& operator-=(const Double& _double);
  39. Double& operator-=(double _value);
  40. Double& operator*=(const Double& _double);
  41. Double& operator*=(double _value);
  42. Double& operator/=(const Double& _double);
  43. Double& operator/=(double _value);
  44. // comparison operators
  45. bool operator==(const Double& _double) const;
  46. bool operator==(double _value) const;
  47. bool operator!=(const Double& _double) const;
  48. bool operator!=(double _value) const;
  49. bool operator>(const Double& _double) const;
  50. bool operator>(double _value) const;
  51. bool operator>=(const Double& _double) const;
  52. bool operator>=(double _value) const;
  53. bool operator<(const Double& _double) const;
  54. bool operator<(double _value) const;
  55. bool operator<=(const Double& _double) const;
  56. bool operator<=(double _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. double getEpsilon();
  67. double getValue();
  68. void setEpsilon(double _epsilon);
  69. void setSerializable(std::shared_ptr<ISerializable> _serializable);
  70. private:
  71. double epsilon {};
  72. std::shared_ptr<ISerializable> serializable {};
  73. double value {};
  74. };
  75. }
  76. #endif