All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ArrayProperty.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/datatype/ArrayProperty.cpp
22 
23  \brief The type for variable-length multidimensional arrays.
24 */
25 
26 // TerraLib
27 #include "ArrayProperty.h"
28 #include "Enums.h"
29 
30 // STL
31 #include <cassert>
32 
33 te::dt::ArrayProperty::ArrayProperty(const std::string& name,
34  Property* elementType,
35  bool isRequired,
36  std::string* defaultValue,
37  unsigned int id,
38  Property* parent)
39  : SimpleProperty(name, ARRAY_TYPE, isRequired, defaultValue, id, parent),
40  m_elementType(elementType)
41 {
42  if(m_elementType)
43  m_elementType->setParent(this);
44 }
45 
47  : SimpleProperty(rhs),
48  m_elementType(0)
49 {
50  if(rhs.m_elementType)
51  {
53  m_elementType->setParent(this);
54  }
55 }
56 
58 {
59  delete m_elementType;
60 }
61 
63 {
64  if(this != &rhs)
65  {
67 
68  delete m_elementType;
69 
70  m_elementType = 0;
71 
72  if(rhs.m_elementType)
73  {
74  m_elementType = rhs.m_elementType->clone();
75 
76  m_elementType->setParent(this);
77  }
78  }
79 
80  return *this;
81 }
82 
84 {
85  assert(t);
86 
87  delete m_elementType;
88  m_elementType = t;
89  m_elementType->setParent(this);
90 }
91 
93 {
94  return new ArrayProperty(*this);
95 }
96 
An atomic property like an integer or double.
virtual Property * clone() const =0
It returns a clone of the object.
ArrayProperty & operator=(const ArrayProperty &rhs)
Assignment operator.
Property * m_elementType
The data type of array elements.
~ArrayProperty()
Destructor.
It models a property definition.
Definition: Property.h:59
ArrayProperty(const std::string &name, Property *elementType, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new property for array data type.
SimpleProperty & operator=(const SimpleProperty &rhs)
Assignment operator.
void setElementType(Property *t)
It sets the type of array elements.
The type for variable-length multidimensional arrays.
The type for variable-length multidimensional arrays.
Definition: ArrayProperty.h:45
General enumerations for the data type module.
Property * clone() const
It returns a clone of the object.
void setParent(Property *p)
It associate this property to the informed parent.
Definition: Property.h:177