All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
UniqueKey.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/UniqueKey.cpp
22 
23  \brief It describes a unique key (uk) constraint.
24 */
25 
26 // TerraLib
27 #include "../../datatype/Property.h"
28 #include "DataSetType.h"
29 #include "UniqueKey.h"
30 
32  : Constraint(id),
33  m_index(0)
34 {
35  if(dt)
36  dt->add(this);
37 }
38 
39 te::da::UniqueKey::UniqueKey(const std::string& name, DataSetType* dt, unsigned int id)
40  : Constraint(name, id),
41  m_index(0)
42 {
43  if(dt)
44  dt->add(this);
45 }
46 
48  : Constraint(rhs.getName(), 0),
49  m_index(rhs.m_index),
50  m_properties(rhs.m_properties)
51 {
52 }
53 
55 {
56  if(this != &rhs)
57  {
59 
60  m_index = rhs.m_index;
61 
62  m_properties = rhs.m_properties;
63  }
64 
65  return *this;
66 }
67 
69 {
70  std::size_t size = m_properties.size();
71 
72  for(std::size_t i = 0; i < size; ++i)
73  if(m_properties[i] == p)
74  return true;
75 
76  return false;
77 }
78 
80 {
81  std::size_t size = m_properties.size();
82 
83  for(std::size_t i = 0; i < size; ++i)
84  if(m_properties[i] == p)
85  {
86  m_properties[i] = pp;
87  break;
88  }
89 }
90 
92 {
93  return new UniqueKey(*this);
94 }
95 
96 
UniqueKey & operator=(const UniqueKey &rhs)
Assignment operator.
Definition: UniqueKey.cpp:54
A class that models the description of a dataset.
Definition: DataSetType.h:72
Constraint & operator=(const Constraint &rhs)
Assignment operator not allowed.
Definition: Constraint.cpp:52
bool has(const te::dt::Property *p) const
It verifies if Property is associated to the unique key.
Definition: UniqueKey.cpp:68
Constraint * clone()
It returns a clone of the object.
Definition: UniqueKey.cpp:91
It models a property definition.
Definition: Property.h:59
void replace(te::dt::Property *p, te::dt::Property *pp)
Definition: UniqueKey.cpp:79
It describes a unique key (uk) constraint.
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
void add(Constraint *c)
It adds a new constraint.
Index * m_index
A pointer to an associated index.
Definition: UniqueKey.h:177
A class that models the description of a dataset.
std::vector< te::dt::Property * > m_properties
The properties that are part of the unique key constraint.
Definition: UniqueKey.h:178
UniqueKey(DataSetType *dt=0, unsigned int id=0)
Constructor.
Definition: UniqueKey.cpp:31