All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SimpleProperty.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/SimpleProperty.cpp
22 
23  \brief An atomic property like an integer or double.
24 */
25 
26 // TerraLib
27 #include "SimpleProperty.h"
28 
30  int datatype,
31  bool isRequired,
32  std::string* defaultValue,
33  unsigned int id,
34  Property* parent)
35  : Property(name, datatype, id, parent),
36  m_isRequired(isRequired),
37  m_isAutoNumber(false),
38  m_defaultValue(defaultValue)
39 {
40 }
41 
43  : Property(rhs),
44  m_isRequired(rhs.m_isRequired),
45  m_isAutoNumber(rhs.m_isAutoNumber),
46  m_defaultValue(0)
47 {
48  m_defaultValue = rhs.m_defaultValue ? new std::string(*(rhs.m_defaultValue)) : 0;
49 }
50 
52 {
53  delete m_defaultValue;
54 }
55 
57 {
58  if(this != &rhs)
59  {
61 
62  m_isRequired = rhs.m_isRequired;
63 
64  m_isAutoNumber = rhs.m_isAutoNumber;
65 
66  delete m_defaultValue;
67 
68  m_defaultValue = rhs.m_defaultValue ? new std::string(*(rhs.m_defaultValue)) : 0;
69  }
70 
71  return *this;
72 }
73 
75 {
76  delete m_defaultValue;
77  m_defaultValue = d;
78 }
79 
81 {
82  return false;
83 }
84 
86 {
87  return new SimpleProperty(*this);
88 }
89 
An atomic property like an integer or double.
bool has(Property *p) const
It checks if the Property "p" is associated to this property or any other parent. ...
Property & operator=(const Property &rhs)
Assignment operator.
Definition: Property.cpp:51
bool m_isRequired
This flag indicates if the attribute is required or not.
It models a property definition.
Definition: Property.h:59
void setDefaultValue(std::string *d)
It sets the default value associated to the property, or NULL if none is associated.
virtual ~SimpleProperty()
Destructor.
SimpleProperty & operator=(const SimpleProperty &rhs)
Assignment operator.
std::string * m_defaultValue
Default value.
virtual Property * clone() const
It returns a clone of the object.
An atomic property like an integer or double.
SimpleProperty(const std::string &name, int datatype, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new simple property.
bool m_isAutoNumber
A flag that indicates if this is an autonumber or serial type.