DataType.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/DataType.h
22 
23  \brief It stores information about a data type.
24 */
25 
26 #ifndef __TERRALIB_DATATYPE_INTERNAL_DATATYPE_H
27 #define __TERRALIB_DATATYPE_INTERNAL_DATATYPE_H
28 
29 // TerraLib
30 #include "Config.h"
31 
32 // STL
33 #include <string>
34 
35 namespace te
36 {
37  namespace dt
38  {
39  /*!
40  \class DataType
41 
42  \brief It stores information about a data type.
43 
44  TerraLib keeps information about all available data types
45  in the system in a singleton called DataTypeManager.
46  In this singleton you will find all supported data types.
47 
48  Some of the data type codes are reserved for the built-in data
49  types of TerraLib (they can be seen in defines).
50 
51  \ingroup datatype
52 
53  \sa DataTypeManager, AbstractData
54  */
56  {
57  public:
58 
59  /*! \brief Default constructor. */
60  DataType() {}
61 
62  /*!
63  \brief Constructor.
64 
65  \param name The data type name.
66  \param description Data type description.
67  */
68  DataType(const std::string& name, const std::string& description);
69 
70  /*! \brief Destructor. */
71  ~DataType() {}
72 
73  /*!
74  \brief It returns the data type id.
75 
76  \return The data type id.
77  */
78  int getId() const;
79 
80  /*!
81  \brief It returns the data type name.
82 
83  \return The data type name.
84  */
85  const std::string& getName() const;
86 
87  /*!
88  \brief It returns the data type description.
89 
90  \return The data type description.
91  */
92  const std::string& getDescription() const;
93 
94  /*!
95  \brief It compares two data types by their ids.
96 
97  \return True, if the id of this data type is less than the data type in the right-hand-side.
98  */
99  bool operator<(const DataType& rhs) const;
100 
101  private:
102 
103  /*!
104  \brief Constructor.
105 
106  \param id The data type id assigned by TerraLib.
107  \param name The data type name.
108  \param description Data type description.
109  */
110  DataType(int id, const std::string& name, const std::string& description);
111 
112  /*!
113  \brief This method can be called only by DataTypeManager.
114 
115  \param id The type code.
116  */
117  void setId(int id);
118 
119  private:
120 
121  int m_id; //!< Data type id assigned by TerraLib.
122  std::string m_name; //!< Data type name.
123  std::string m_description; //!< Data type description.
124 
125  friend class DataTypeManager;
126  };
127 
128  inline DataType::DataType(const std::string& name, const std::string& description)
129  : m_id(0), m_name(name), m_description(description)
130  {
131  }
132 
133  inline int DataType::getId() const
134  {
135  return m_id;
136  }
137 
138  inline const std::string& DataType::getName() const
139  {
140  return m_name;
141  }
142 
143  inline bool DataType::operator<(const DataType& rhs) const
144  {
145  return m_id < rhs.m_id;
146  }
147 
148  inline DataType::DataType(int id, const std::string& name, const std::string& description)
149  : m_id(id), m_name(name), m_description(description)
150  {
151  }
152 
153  inline void DataType::setId(int id)
154  {
155  m_id = id;
156  }
157 
158  } // end namespace dt
159 } // end namespace te
160 
161 #endif // __TERRALIB_DATATYPE_INTERNAL_DATATYPE_H
162 
TEDATAACCESSEXPORT te::da::Expression * operator<(const te::da::Expression &e1, const te::da::Expression &e2)
It stores information about a data type.
Definition: DataType.h:55
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
Configuration flags for the DataType module of TerraLib.
const std::string & getName() const
It returns the data type name.
Definition: DataType.h:138
void setId(int id)
This method can be called only by DataTypeManager.
Definition: DataType.h:153
URI C++ Library.
std::string m_description
Data type description.
Definition: DataType.h:123
bool operator<(const DataType &rhs) const
It compares two data types by their ids.
Definition: DataType.h:143
int getId() const
It returns the data type id.
Definition: DataType.h:133
std::string m_name
Data type name.
Definition: DataType.h:122
DataType()
Default constructor.
Definition: DataType.h:60
~DataType()
Destructor.
Definition: DataType.h:71
int m_id
Data type id assigned by TerraLib.
Definition: DataType.h:121