All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sequence.cpp
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.cpp
22 
23  \brief It describes a sequence (a number generator).
24 */
25 
26 // TerraLib
27 #include "../../datatype/Property.h"
28 #include "../datasource/DataSourceCatalog.h"
29 #include "DataSetType.h"
30 #include "Sequence.h"
31 
32 // STL
33 #include <climits>
34 
36  : m_increment(1),
37  m_minValue(INT_MIN),
38  m_maxValue(INT_MAX),
39  m_startValue(1),
40  m_cachedValues(1),
41  m_catalog(catalog),
42  m_ownedBy(0),
43  m_id(id),
44  m_cycled(false)
45 {
46  if(m_catalog)
47  m_catalog->add(this);
48 }
49 
50 te::da::Sequence::Sequence(const std::string& name,
51  boost::int64_t increment,
52  boost::int64_t startValue,
53  DataSourceCatalog* catalog,
54  unsigned int id)
55  : m_increment(increment),
56  m_minValue(INT_MIN),
57  m_maxValue(INT_MAX),
58  m_startValue(startValue),
59  m_cachedValues(1),
60  m_catalog(catalog),
61  m_ownedBy(0),
62  m_id(id),
63  m_cycled(false),
64  m_name(name)
65 {
66  if(m_catalog)
67  m_catalog->add(this);
68 }
69 
71  : m_increment(rhs.m_increment),
72  m_minValue(rhs.m_minValue),
73  m_maxValue(rhs.m_maxValue),
74  m_startValue(rhs.m_startValue),
75  m_cachedValues(rhs.m_cachedValues),
76  m_catalog(0),
77  m_ownedBy(rhs.m_ownedBy),
78  m_id(rhs.m_id),
79  m_cycled(rhs.m_cycled),
80  m_name(rhs.m_name)
81 {
82 }
83 
85 {
86  if(this != &rhs)
87  {
88  m_increment = rhs.m_increment;
89  m_minValue = rhs.m_minValue;
90  m_maxValue = rhs.m_maxValue;
91  m_startValue = rhs.m_startValue;
92  m_cachedValues = rhs.m_cachedValues;
93  m_catalog = 0;
94  m_ownedBy = rhs.m_ownedBy;
95  m_id = rhs.m_id;
96  m_cycled = rhs.m_cycled;
97  m_name = rhs.m_name;
98  }
99 
100  return *this;
101 }
102 
104 {
105  return new Sequence(*this);
106 }
std::string m_name
The sequence name.
Definition: Sequence.h:286
Sequence(DataSourceCatalog *catalog=0, unsigned int id=0)
It constructs a new sequence.
Definition: Sequence.cpp:35
It represents the system catalog of a DataSource.
Sequence & operator=(const Sequence &rhs)
Assignment operator.
Definition: Sequence.cpp:84
DataSourceCatalog * m_catalog
The DataSourceCatalog associated to this sequence.
Definition: Sequence.h:282
It describes a sequence (a number generator).
Definition: Sequence.h:56
unsigned int m_id
An identification number for the sequence.
Definition: Sequence.h:284
boost::int64_t m_maxValue
The maximum value that the sequence can generate.
Definition: Sequence.h:279
Sequence * clone()
It returns a clone of the object.
Definition: Sequence.cpp:103
boost::int64_t m_startValue
The sequence starting value.
Definition: Sequence.h:280
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
void add(const DataSetTypePtr &dt)
It adds a new dataset schema to the catalog.
boost::int64_t m_increment
The value to be added to the current sequence value to create the new value.
Definition: Sequence.h:277
boost::int64_t m_cachedValues
It specifies how many sequence numbers are to be preallocated for faster access.
Definition: Sequence.h:281
It describes a sequence (a number generator).
boost::int64_t m_minValue
The minimum value that the sequence can generate.
Definition: Sequence.h:278
A class that models the description of a dataset.
te::dt::Property * m_ownedBy
The sequence may be associated with a specific property type (owned by a property).
Definition: Sequence.h:283