All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Index.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/Index.cpp
22 
23  \brief It describes an index associated to a DataSetType.
24 */
25 
26 // TerraLib
27 #include "../../datatype/Property.h"
28 #include "DataSetType.h"
29 #include "Index.h"
30 
31 te::da::Index::Index(DataSetType* dt, unsigned int id)
32  : m_id(id),
33  m_type(B_TREE_TYPE),
34  m_dt(dt)
35 {
36  if(m_dt)
37  m_dt->add(this);
38 }
39 
40 te::da::Index::Index(const std::string& name, IndexType t, DataSetType* dt, unsigned int id)
41  : m_id(id),
42  m_type(t),
43  m_dt(dt),
44  m_name(name)
45 {
46  if(m_dt)
47  m_dt->add(this);
48 }
49 
50 te::da::Index::Index(const std::string& name,
51  IndexType t,
52  const std::vector<te::dt::Property*>& properties,
53  DataSetType* dt,
54  unsigned int id)
55  : m_id(id),
56  m_type(t),
57  m_dt(dt),
58  m_name(name),
59  m_properties(properties)
60 {
61  if(m_dt)
62  m_dt->add(this);
63 }
64 
66  : m_id(rhs.m_id),
67  m_type(rhs.m_type),
68  m_dt(0),
69  m_name(rhs.m_name),
70  m_properties(rhs.m_properties)
71 {
72 }
73 
75 {
76  if(this != &rhs)
77  {
78  m_id = rhs.m_id;
79  m_type = rhs.m_type;
80  m_dt = 0;
81  m_name = rhs.m_name;
82  m_properties = rhs.m_properties;
83  }
84 
85  return *this;
86 }
87 
89 {
90  size_t size = m_properties.size();
91 
92  for(size_t i = 0; i < size; ++i)
93  if(m_properties[i] == p)
94  return true;
95 
96  return false;
97 }
98 
100 {
101  std::size_t size = m_properties.size();
102 
103  for(std::size_t i = 0; i < size; ++i)
104  if(m_properties[i] == p)
105  {
106  m_properties[i] = pp;
107  break;
108  }
109 }
110 
112 {
113  return new Index(*this);
114 }
bool has(te::dt::Property *p)
It verifies if Property is associated to the index.
Definition: Index.cpp:88
DataSetType * m_dt
The parent DataSetType.
Definition: Index.h:248
IndexType m_type
The index type.
Definition: Index.h:247
A class that models the description of a dataset.
Definition: DataSetType.h:72
Index * clone()
It returns a clone of the object.
Definition: Index.cpp:111
It models a property definition.
Definition: Property.h:59
unsigned int m_id
An identification number for the index.
Definition: Index.h:246
Index & operator=(const Index &rhs)
Assignment operator.
Definition: Index.cpp:74
It describes an index associated to a DataSetType.
void replace(te::dt::Property *p, te::dt::Property *pp)
It changes the reference to property p to pp.
Definition: Index.cpp:99
IndexType
Index type.
Definition: Enums.h:107
std::string m_name
The index name.
Definition: Index.h:249
void add(Constraint *c)
It adds a new constraint.
A class that models the description of a dataset.
std::vector< te::dt::Property * > m_properties
The list of properties that form the index.
Definition: Index.h:250
It describes an index associated to a DataSetType.
Definition: Index.h:54
Index(DataSetType *parent=0, unsigned int id=0)
Constructor.
Definition: Index.cpp:31