Loading...
Searching...
No Matches
Sequence.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/dataaccess/dataset/Sequence.h
22
23 \brief It describes a sequence (a number generator).
24*/
25
26#ifndef __TERRALIB_DATAACCESS_INTERNAL_SEQUENCE_H
27#define __TERRALIB_DATAACCESS_INTERNAL_SEQUENCE_H
28
29// TerraLib
30#include "../Config.h"
31
32// STL
33#include <string>
34
35// Boost
36#include <boost/cstdint.hpp>
37
38namespace te
39{
40// Forward declaration
41 namespace dt { class Property; }
42
43 namespace da
44 {
45// Forward declaration
46 class DataSetType;
47 class DataSourceCatalog;
48
49 /*!
50 \class Sequence
51
52 \brief It describes a sequence (a number generator).
53
54 \sa DataSourceCatalog, DataSetType, Property
55 */
57 {
58 public:
59
60 /*!
61 \brief It constructs a new sequence.
62
63 A sequence may belongs to the global catalog of a given data source,
64 and it can be associated to a given property of a specific dataset type.
65
66 \param catalog The catalog associated to the sequence.
67 \param id The sequence identifier.
68
69 \post If catalog is provided, the sequence will belong to the given DataSourceCatalog.
70
71 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
72 */
73 Sequence(DataSourceCatalog* catalog = 0, unsigned int id = 0);
74
75 /*!
76 \brief It creates a new sequence.
77
78 \param name The sequence name.
79 \param increment The value to be added to the current sequence value to create the new value (default = 1).
80 \param startValue The sequence starting value (default = 1).
81 \param catalog The catalog associated to the sequence.
82 \param id The sequence identifier.
83
84 \post If catalog is provided, the sequence will belong to the given DataSourceCatalog.
85
86 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
87 */
88 Sequence(const std::string& name,
89 boost::int64_t increment = 1,
90 boost::int64_t startValue = 1,
91 DataSourceCatalog* catalog = 0,
92 unsigned int id = 0);
93
94 /*!
95 \brief Copy constructor.
96
97 The new object will not have an associated catalog.
98
99 \param rhs Right-hand-side instance.
100 */
101 Sequence(const Sequence& rhs);
102
103 /*! \brief Destructor. */
105
106 /*!
107 \brief Assignment operator.
108
109 The new object will not have an associated catalog.
110
111 \param rhs Right-hand-side instance.
112
113 \return A reference to this object.
114 */
116
117 /*!
118 \brief It returns the sequence identifier.
119
120 \return A number that identifies the sequence.
121
122 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
123 */
124 unsigned int getId() const { return m_id; }
125
126 /*!
127 \brief It sets the sequence identifier.
128
129 \param id A number that identifies the sequence.
130
131 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
132 */
133 void setId(unsigned int id) { m_id = id; }
134
135 /*!
136 \brief It returns the sequence name.
137
138 \return The sequence name.
139 */
140 const std::string& getName() const { return m_name; }
141
142 /*!
143 \brief It sets the sequence name.
144
145 \param name The sequence name.
146 */
147 void setName(const std::string& name) { m_name = name; }
148
149 /*!
150 \brief It returns the increment value.
151
152 \return The increment value.
153 */
154 boost::int64_t getIncrement() const { return m_increment; }
155
156 /*!
157 \brief It sets the increment value.
158
159 \param n The increment value.
160 */
161 void setIncrement(boost::int64_t n) { m_increment = n; }
162
163 /*!
164 \brief It returns the minimum value that the sequence can generate.
165
166 \return The minimum value that the sequence can generate.
167 */
168 boost::int64_t getMinValue() const { return m_minValue; }
169
170 /*!
171 \brief It sets the minimum value that the sequence can generate.
172
173 \param value The minimum value that the sequence can generate.
174 */
175 void setMinValue(boost::int64_t value) { m_minValue = value; }
176
177 /*!
178 \brief It returns the maximum value that the sequence can generate.
179
180 \return The maximum value that the sequence can generate.
181 */
182 boost::int64_t getMaxValue() const { return m_maxValue; }
183
184 /*!
185 \brief It sets the maximum value that the sequence can generate.
186
187 \param value The maximum value that the sequence can generate.
188 */
189 void setMaxValue(boost::int64_t value) { m_maxValue = value; }
190
191 /*!
192 \brief It returns the initial value of the sequence.
193
194 \return the initial value of the sequence
195 */
196 boost::int64_t getStartValue() const { return m_startValue; }
197
198 /*!
199 \brief It sets the sequence starting value.
200
201 \param value The sequence starting value.
202 */
203 void setStartValue(boost::int64_t value) { m_startValue = value; }
204
205 /*!
206 \brief It returns how many sequence numbers are preallocated.
207
208 \return How many sequence numbers are preallocated.
209 */
210 boost::int64_t getCachedValues() const { return m_cachedValues; }
211
212 /*!
213 \brief It sets how many sequence numbers are to be preallocated.
214
215 \param value How many sequence numbers are to be preallocated.
216 */
217 void setCachedValues(boost::int64_t value) { m_cachedValues = value; }
218
219 /*!
220 \brief It returns true if the sequence can wrap, otherwise it returns false.
221
222 \return True if the sequence can wrap, otherwise it returns false.
223 */
224 bool isCycled() const { return m_cycled; }
225
226 /*! \brief It sets the sequence as cycled (it can wrap). */
227 void setAsCycle() { m_cycled = true; }
228
229 /*! \brief It sets the sequence as not cycled (it can't wrap). */
230 void setAsNoCycle() { m_cycled = false; }
231
232 /*!
233 \brief It returns the property type associated to the sequence.
234
235 \return The property type associated to the sequence.
236 */
237 te::dt::Property* getOwner() const { return m_ownedBy; }
238
239 /*!
240 \brief It causes the sequence to be associated with a specific property type.
241
242 When the dataset type is dropped (or its whole catalog), the sequence
243 will be automatically dropped as well.
244
245 \param owner The property type owner of this sequence.
246 */
247 void setOwner(te::dt::Property* owner) { m_ownedBy = owner; }
248
249 /*!
250 \brief It returns the catalog associated to the sequence.
251
252 \return The catalog associated to the sequence.
253 */
254 DataSourceCatalog* getCatalog() const { return m_catalog; }
255
256 /*!
257 \brief It sets the catalog associated to the sequence.
258
259 \param catalog The data source catalog to which this sequence belongs.
260
261 \warning Take care when calling this method. If the sequence belongs to a DataSourceCatalog
262 remember to detach it from the catalog before calling this method.
263 */
264 void setCatalog(DataSourceCatalog* catalog) { m_catalog = catalog; }
265
266 /*!
267 \brief It returns a clone of the object.
268
269 The new object will not have an associated catalog.
270
271 \return A clone of the object.
272 */
274
275 private:
276
277 boost::int64_t m_increment; //!< The value to be added to the current sequence value to create the new value.
278 boost::int64_t m_minValue; //!< The minimum value that the sequence can generate.
279 boost::int64_t m_maxValue; //!< The maximum value that the sequence can generate.
280 boost::int64_t m_startValue; //!< The sequence starting value.
281 boost::int64_t m_cachedValues; //!< It specifies how many sequence numbers are to be preallocated for faster access.
282 DataSourceCatalog* m_catalog; //!< The DataSourceCatalog associated to this sequence.
283 te::dt::Property* m_ownedBy; //!< The sequence may be associated with a specific property type (owned by a property).
284 unsigned int m_id; //!< An identification number for the sequence.
285 bool m_cycled; //!< If it is true, the sequence can wrap when it reaches the maximum value in the case of an ascendent sequence or wrap when it reaches the minimum value in the case of a descendant sequence.
286 std::string m_name; //!< The sequence name.
287 };
288
289 } // end namespace da
290} // end namespace te
291
292#endif // __TERRALIB_DATAACCESS_INTERNAL_SEQUENCE_H
293
294
It represents the system catalog of a DataSource.
It describes a sequence (a number generator).
Definition: Sequence.h:57
void setMaxValue(boost::int64_t value)
It sets the maximum value that the sequence can generate.
Definition: Sequence.h:189
Sequence(DataSourceCatalog *catalog=0, unsigned int id=0)
It constructs a new sequence.
te::dt::Property * m_ownedBy
The sequence may be associated with a specific property type (owned by a property).
Definition: Sequence.h:283
void setCatalog(DataSourceCatalog *catalog)
It sets the catalog associated to the sequence.
Definition: Sequence.h:264
void setStartValue(boost::int64_t value)
It sets the sequence starting value.
Definition: Sequence.h:203
Sequence(const Sequence &rhs)
Copy constructor.
void setMinValue(boost::int64_t value)
It sets the minimum value that the sequence can generate.
Definition: Sequence.h:175
void setOwner(te::dt::Property *owner)
It causes the sequence to be associated with a specific property type.
Definition: Sequence.h:247
DataSourceCatalog * m_catalog
The DataSourceCatalog associated to this sequence.
Definition: Sequence.h:282
std::string m_name
The sequence name.
Definition: Sequence.h:286
bool m_cycled
If it is true, the sequence can wrap when it reaches the maximum value in the case of an ascendent se...
Definition: Sequence.h:285
boost::int64_t getMaxValue() const
It returns the maximum value that the sequence can generate.
Definition: Sequence.h:182
boost::int64_t getMinValue() const
It returns the minimum value that the sequence can generate.
Definition: Sequence.h:168
const std::string & getName() const
It returns the sequence name.
Definition: Sequence.h:140
void setIncrement(boost::int64_t n)
It sets the increment value.
Definition: Sequence.h:161
boost::int64_t m_startValue
The sequence starting value.
Definition: Sequence.h:280
boost::int64_t getStartValue() const
It returns the initial value of the sequence.
Definition: Sequence.h:196
~Sequence()
Destructor.
Definition: Sequence.h:104
Sequence * clone()
It returns a clone of the object.
unsigned int getId() const
It returns the sequence identifier.
Definition: Sequence.h:124
boost::int64_t getIncrement() const
It returns the increment value.
Definition: Sequence.h:154
boost::int64_t m_maxValue
The maximum value that the sequence can generate.
Definition: Sequence.h:279
void setId(unsigned int id)
It sets the sequence identifier.
Definition: Sequence.h:133
boost::int64_t m_increment
The value to be added to the current sequence value to create the new value.
Definition: Sequence.h:277
DataSourceCatalog * getCatalog() const
It returns the catalog associated to the sequence.
Definition: Sequence.h:254
void setCachedValues(boost::int64_t value)
It sets how many sequence numbers are to be preallocated.
Definition: Sequence.h:217
boost::int64_t getCachedValues() const
It returns how many sequence numbers are preallocated.
Definition: Sequence.h:210
bool isCycled() const
It returns true if the sequence can wrap, otherwise it returns false.
Definition: Sequence.h:224
void setAsCycle()
It sets the sequence as cycled (it can wrap).
Definition: Sequence.h:227
void setName(const std::string &name)
It sets the sequence name.
Definition: Sequence.h:147
Sequence(const std::string &name, boost::int64_t increment=1, boost::int64_t startValue=1, DataSourceCatalog *catalog=0, unsigned int id=0)
It creates a new sequence.
boost::int64_t m_cachedValues
It specifies how many sequence numbers are to be preallocated for faster access.
Definition: Sequence.h:281
void setAsNoCycle()
It sets the sequence as not cycled (it can't wrap).
Definition: Sequence.h:230
Sequence & operator=(const Sequence &rhs)
Assignment operator.
unsigned int m_id
An identification number for the sequence.
Definition: Sequence.h:284
boost::int64_t m_minValue
The minimum value that the sequence can generate.
Definition: Sequence.h:278
te::dt::Property * getOwner() const
It returns the property type associated to the sequence.
Definition: Sequence.h:237
It models a property definition.
Definition: Property.h:60
TerraLib.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97