ComplexData.h
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/ComplexData.h
22 
23  \brief This file contains several implementations for complex data types.
24 */
25 
26 #ifndef __TERRALIB_VP_INTERNAL_COMPLEXDATA_H
27 #define __TERRALIB_VP_INTERNAL_COMPLEXDATA_H
28 
29 // TerraLib
30 #include "../datatype/AbstractData.h"
31 #include "../datatype/Enums.h"
32 #include "Config.h"
33 
34 namespace te
35 {
36  namespace vp
37  {
38  /*!
39  \class ComplexData
40 
41  \brief A template for complex data types.
42 
43  Requirements on type T:
44  <ul>
45  <li> T must be a copy constructible type.</li>
46  </ul>
47 
48  \ingroup datatype
49 
50  \sa AbstractData, CompositeData, DataType, DateTime, ByteArray
51  */
52  template<class T> class ComplexData : public te::dt::AbstractData
53  {
54  public:
55 
56  /*!
57  \brief Constructor.
58 
59  \param value The value associated.
60  */
61  ComplexData(T value)
62  : m_val(value)
63  {
64  }
65 
66  /*!
67  \brief Copy constructor.
68 
69  \param rhs The right-hand-side data.
70  */
72  : m_val(rhs.m_val)
73  {
74  }
75 
76  /*! \brief Virtual destructor. */
77  virtual ~ComplexData() { }
78 
79  /*!
80  \brief Copy constructor.
81 
82  \param rhs The right-hand-side data.
83  */
85  {
86  if(this != &rhs)
87  {
88  m_val = rhs.m_val;
89  }
90 
91  return *this;
92  }
93 
94  /*!
95  \brief It returns a clone of this object.
96 
97  \return A clone of this object.
98  */
99  ComplexData* clone() const
100  {
101  return new ComplexData(*this);
102  }
103 
104  /*!
105  \brief It returns the data type code associated to the data value.
106 
107  \return The data type code associated to the data value.
108  */
109  virtual int getTypeCode() const
110  {
111  return te::dt::UNKNOWN_TYPE;
112  }
113 
114  /*!
115  \brief It returns the data value in a string representation.
116 
117  \return The data value in a string representation.
118  */
119  virtual std::string toString() const
120  {
121  return "";
122  }
123 
124  /*!
125  \brief It returns the associated value.
126 
127  \return The associated value.
128  */
129  T getValue() const
130  {
131  return m_val;
132  }
133 
134  private:
135 
136  T m_val; //!< The data value.
137  };
138 
139  } // end namespace dt
140 } // end namespace te
141 
142 #endif // __TERRALIB_VP_INTERNAL_COMPLEXDATA_H
143 
T m_val
The data value.
Definition: ComplexData.h:136
ComplexData(const ComplexData &rhs)
Copy constructor.
Definition: ComplexData.h:71
virtual int getTypeCode() const
It returns the data type code associated to the data value.
Definition: ComplexData.h:109
virtual std::string toString() const
It returns the data value in a string representation.
Definition: ComplexData.h:119
virtual ~ComplexData()
Virtual destructor.
Definition: ComplexData.h:77
T getValue() const
It returns the associated value.
Definition: ComplexData.h:129
ComplexData(T value)
Constructor.
Definition: ComplexData.h:61
ComplexData & operator=(const ComplexData &rhs)
Copy constructor.
Definition: ComplexData.h:84
A template for complex data types.
Definition: ComplexData.h:52
URI C++ Library.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
ComplexData * clone() const
It returns a clone of this object.
Definition: ComplexData.h:99
Configuration flags for the Terrralib Vector Processing module.