NumericProperty.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/datatype/NumericProperty.h
22 
23  \brief The type for arbitrary precision numbers, like numeric(p, q).
24 */
25 
26 #ifndef __TERRALIB_DATATYPE_INTERNAL_NUMERICPROPERTY_H
27 #define __TERRALIB_DATATYPE_INTERNAL_NUMERICPROPERTY_H
28 
29 // TerraLib
30 #include "SimpleProperty.h"
31 
32 namespace te
33 {
34  namespace dt
35  {
36  /*!
37  \class NumericProperty
38 
39  \brief The type for arbitrary precison numbers, like numeric(p, q).
40 
41  \ingroup datatype
42 
43  \sa SimpleProperty, Property, StringProperty, ArrayProperty, DateTimeProperty, CompositeProperty
44  */
46  {
47  public:
48 
49 
50  /*!
51  \brief It constructs a new NumericProperty.
52 
53  \param name The attribute name.
54  \param precision The total count of significant digits in the whole number, that is, the number of digits to both sides of the decimal point.
55  \param scale The count of decimal digits in the fractional part, to the right of the decimal point.
56  \param isRequired Indicates if the the property is required (mandatory) or not.
57  \param defaultValue The default value to be used, if none is informed.
58  \param id The property identifier.
59  \param parent A reference to the parent Property of the new object if it has one.
60 
61  \post The NumericProperty will take the ownership of the defaultValue.
62 
63  \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
64  */
65  NumericProperty(const std::string& name,
66  unsigned int precision,
67  unsigned int scale,
68  bool isRequired = false,
69  std::string* defaultValue = 0,
70  unsigned int id = 0,
71  Property* parent = 0);
72 
73  /*!
74  \brief Copy constructor.
75 
76  \param rhs The right-hand-side copy used to copy from.
77  */
78  NumericProperty(const NumericProperty& rhs);
79 
80  /*! \brief Destructor. */
82 
83  /*!
84  \brief Assignment operator.
85 
86  \param rhs The right-hand-side copy used to copy from.
87 
88  \return A reference to this object.
89  */
90  NumericProperty& operator=(const NumericProperty& rhs);
91 
92  /*!
93  \brief It returns the total count of significant digits in the whole number,
94  that is, the number of digits to both sides of the decimal point.
95 
96  \return The total number of digits of the numeric type.
97  */
98  unsigned int getPrecision() const { return m_precision; }
99 
100  /*!
101  \brief Sets the total count of significant digits in the whole number,
102  that is, the number of digits to both sides of the decimal point.
103  */
104  void setPrecision(unsigned int precision) { m_precision = precision; }
105 
106  /*!
107  \brief It returns the count of decimal digits in the fractional part, to the right of the decimal point.
108 
109  \return The count of decimal digits in the fractional part, to the right of the decimal point.
110  */
111  unsigned int getScale() const { return m_scale; }
112 
113  /*!
114  \brief Sets the count of decimal digits in the fractional part, to the right of the decimal point.
115  */
116  void setScale(unsigned int scale) { m_scale = scale; }
117 
118  /*!
119  \brief It returns a clone of the object.
120 
121  The new property will NOT have associations to other properties.
122 
123  \return A clone of the object.
124  */
125  Property* clone() const;
126 
127  protected:
128 
129  unsigned int m_precision; //!< Total number of digits of a numeric value.
130  unsigned int m_scale; //!< Number of digits for the right of the decimal point of a numeric value.
131  };
132 
133  } // end namespace dt
134 } // end namespace te
135 
136 #endif // __TERRALIB_DATATYPE_INTERNAL_NUMERICPROPERTY_H
137 
unsigned int m_scale
Number of digits for the right of the decimal point of a numeric value.
An atomic property like an integer or double.
unsigned int m_precision
Total number of digits of a numeric value.
void setScale(unsigned int scale)
Sets the count of decimal digits in the fractional part, to the right of the decimal point...
It models a property definition.
Definition: Property.h:59
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
The type for arbitrary precison numbers, like numeric(p, q).
URI C++ Library.
~NumericProperty()
Destructor.
unsigned int getPrecision() const
It returns the total count of significant digits in the whole number, that is, the number of digits t...
An atomic property like an integer or double.
void setPrecision(unsigned int precision)
Sets the total count of significant digits in the whole number, that is, the number of digits to both...
unsigned int getScale() const
It returns the count of decimal digits in the fractional part, to the right of the decimal point...