CDoubleManip.h
Go to the documentation of this file.
1 #ifndef imath_CDoubleManip_included
2 #define imath_CDoubleManip_included
3 
4 
5 #include <imath/IDoubleManip.h>
6 
7 
8 namespace imath
9 {
10 
11 
15 class CDoubleManip: virtual public IDoubleManip
16 {
17 public:
18  CDoubleManip();
19 
23  char GetPointChar() const;
24 
28  void SetPointChar(char pointChar);
29 
30  // reimplemented (imath::IDoubleManip)
31  virtual int GetPrecision() const;
32 
33  // reimplemented (imath::TIValueManip)
34  virtual double GetRounded(const double& value) const;
35  virtual bool IsEqual(const double& value1, const double& value2) const;
36  virtual bool IsSmaller(const double& value1, const double& value2) const;
37  virtual bool IsSmallerEqual(const double& value1, const double& value2) const;
38  virtual double GetSmallerValue(const double& value) const;
39  virtual double GetBiggerValue(const double& value) const;
40  virtual QString GetString(const double& value) const;
41  virtual bool GetParsed(const QString& text, double& result) const;
42 
43 protected:
44  enum{
46  };
47 
48 private:
49  char m_pointChar;
50 };
51 
52 
53 // inline methods
54 
55 inline char CDoubleManip::GetPointChar() const
56 {
57  return m_pointChar;
58 }
59 
60 
61 inline void CDoubleManip::SetPointChar(char pointChar)
62 {
63  m_pointChar = pointChar;
64 }
65 
66 
67 // reimplemented (imath::TIValueManip)
68 
69 inline double CDoubleManip::GetRounded(const double& value) const
70 {
71  return value;
72 }
73 
74 
75 inline bool CDoubleManip::IsEqual(const double& value1, const double& value2) const
76 {
77  return value1 == value2;
78 }
79 
80 
81 inline bool CDoubleManip::IsSmaller(const double& value1, const double& value2) const
82 {
83  return value1 < value2;
84 }
85 
86 
87 inline bool CDoubleManip::IsSmallerEqual(const double& value1, const double& value2) const
88 {
89  return value1 <= value2;
90 }
91 
92 
93 inline double CDoubleManip::GetSmallerValue(const double& value) const
94 {
95  return value - 0.001;
96 }
97 
98 
99 inline double CDoubleManip::GetBiggerValue(const double& value) const
100 {
101  return value + 0.001;
102 }
103 
104 
105 } // namespace imath
106 
107 
108 #endif // !imath_CDoubleManip_included
109 
110 
virtual double GetBiggerValue(const double &value) const
Return smallest value bigger that specified one.
Definition: CDoubleManip.h:99
virtual bool IsEqual(const double &value1, const double &value2) const
Compare two values and check, if there are equal.
Definition: CDoubleManip.h:75
virtual bool IsSmaller(const double &value1, const double &value2) const
Compare two values and check, if first one is smaller as the second.
Definition: CDoubleManip.h:81
Simple implementation of imath::IDoubleManip interface for double values without rounding.
Definition: CDoubleManip.h:15
Interface for all manipulation using values represent as double.
Definition: IDoubleManip.h:20
virtual QString GetString(const double &value) const
Get this value as string.
virtual bool GetParsed(const QString &text, double &result) const
Get value converted from string.
char GetPointChar() const
Get point character.
Definition: CDoubleManip.h:55
virtual double GetSmallerValue(const double &value) const
Return biggest value smaller that specified one.
Definition: CDoubleManip.h:93
void SetPointChar(char pointChar)
Set point character.
Definition: CDoubleManip.h:61
virtual bool IsSmallerEqual(const double &value1, const double &value2) const
Compare two values and check, if first one is smaller or equal as the second.
Definition: CDoubleManip.h:87
virtual int GetPrecision() const
Get number of digits after point.
virtual double GetRounded(const double &value) const
Get the nearest value rounded used this arithmetik.
Definition: CDoubleManip.h:69

© 2007-2017 Witold Gantzke and Kirill Lepskiy