DSInfo.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 DSInfo.h
22 
23  \brief Data Source Informations tool
24  */
25 
26 #ifndef __TERRALIB_TOOLS_DSINFO_DSINFO_H
27 #define __TERRALIB_TOOLS_DSINFO_DSINFO_H
28 
29 // DSInfo
30 #include <Utils.h>
31 
32 // TerraLib
33 #include <terralib/common.h>
36 #include <terralib/plugin/Plugin.h>
38 #include <terralib/dataaccess.h>
40 #include <terralib/datatype.h>
41 
42 // STL
43 #include <iostream>
44 
45 struct PKInfo;
46 struct FKInfo;
47 struct UKInfo;
48 struct IdxInfo;
49 struct CCInfo;
50 struct DataSetStruct;
51 struct DataSourceHeader;
52 
53 /*!
54  \class DSInfo
55 
56  \brief Class with methods to manage the application
57 */
58 class DSInfo
59 {
60  public:
61 
62  /*!
63  \brief Class Constructor
64  */
65  DSInfo();
66 
67  /*!
68  \brief Init the application
69 
70  \param dstype Data Source Type
71  \param connstr Data Source Connection String
72 
73  \return True if successfully
74  */
75  bool init(std::string dstype, std::string connstr);
76 
77  /*!
78  \brief Get the Data Source Capabilities
79 
80  \return String/String Map with the Data Source Capabilities
81  */
82  std::map<std::string, std::string> getCapabilities();
83 
84  /*!
85  \brief Get the Data Source Header
86 
87  \return Data Source Header struct
88  */
90 
91  /*!
92  \brief Get all Data Sets informations
93 
94  \return DataSetStruct Vector
95  */
96  std::vector<DataSetStruct> getDataSetsInfo();
97 
98  /*!
99  \brief Get all Data Sets names
100 
101  \return String vector with the Names
102  */
103  std::vector<std::string*> getDataSetNameList();
104 
105  /*!
106  \brief Get Data Source Types connection parameters
107 
108  \param dataSourceType Data Source Type, if passed by the user
109 
110  \return String/String Vector Map with the Data Source Types connection parameters
111  */
112  std::map<std::string, std::vector<std::string>> getDataSourceParameters(std::string dataSourceType);
113 
114  /*!
115  \brief Get specific Data Set information
116 
117  \param dataSetName Data Set Name
118 
119  \return DataSetStruct with the informations
120  */
121  DataSetStruct getDataSetInfo(std::string dataSetName);
122  private:
123 
124  /*!
125  \brief Get primary key information
126 
127  \param dataSetName Data Set Name
128 
129  \return PKInfo struct
130  */
131  PKInfo getPrimaryKeyInfo(std::string dataSetName);
132 
133  /*!
134  \brief Get foreign keys information
135 
136  \param dataSetName Data Set Name
137 
138  \return FKInfo struct vector
139  */
140  std::vector<FKInfo> getForeignKeyInfo(std::string dataSetName);
141 
142  /*!
143  \brief Get unique keys information
144 
145  \param dataSetName Data Set Name
146 
147  \return UKInfo struct vector
148  */
149  std::vector<UKInfo> getUniqueKeyInfo(std::string dataSetName);
150 
151  /*!
152  \brief Get indexes information
153 
154  \param dataSetName Data Set Name
155 
156  \return IdxInfo struct vector
157  */
158  std::vector<IdxInfo> getIndexesKeyInfo(std::string dataSetName);
159 
160  /*!
161  \brief Get check constraint information
162 
163  \param dataSetName Data Set Name
164 
165  \return CCInfo struct vector
166  */
167  std::vector<CCInfo> getCheckConstraintInfo(std::string dataSetName);
168 
169 
170  private:
171  std::string m_dataSourceType; //!< The Data Source Type
172  std::string m_connStr; //!< The Data Source Connection String
173  te::da::DataSource* m_dataSource; //!< The Data Source
174 
175 };
176 
177 /*!
178  \brief Struct that stores information about a primary key using the most common data types
179 */
180 struct PKInfo
181 {
182  std::string name; //!< Primary Key Name
183  std::vector<std::string> porperties; //!< Primary Key Properties in a string vector
184 };
185 
186 /*!
187  \brief Struct that stores information about a foreign key using the most common data types
188 */
189 struct FKInfo
190 {
191  std::string name; //!< Foreign Key Name
192  std::vector<std::string> porperties; //!< Foreign Key Properties in a string vector
193 };
194 
195 /*!
196  \brief Struct that stores information about a unique key using the most common data types
197 */
198 struct UKInfo
199 {
200  std::string name; //!< Unique Key Name
201  std::vector<std::string> porperties; //!< Unique Key Properties in a string vector
202 };
203 
204 /*!
205  \brief Struct that stores information about a index using the most common data types
206 */
207 struct IdxInfo
208 {
209  std::string name; //!< Index Name
210  std::string type; //!< Index Type
211  std::vector<std::string> porperties; //!< Index Properties in a string vector
212 };
213 
214 /*!
215  \brief Struct that stores information about a check constraint using the most common data types
216 */
217 struct CCInfo
218 {
219  std::string name; //!< Check Constraint Name
220  std::string expression; //!< Check Constraint Expression
221 };
222 
223 /*!
224  \brief Struct that stores information about a data set using the most common data types
225 */
227 {
228  std::string name; //!< Data Set Name
229  bool hasPk; //!< If has Primary key
230  PKInfo pkInfo; //!< Primary Key struct
231  std::vector<FKInfo> vecFkInfo; //!< Foreign Key struct vector
232  std::vector<UKInfo> vecUkInfo; //!< Unique Key struct vector
233  std::vector<IdxInfo> vecIdxInfo; //!< Index struct vector
234  std::vector<CCInfo> vecCcInfo; //!< Check Constraint struct vector
235 };
236 
237 /*!
238  \brief Struct that stores information about a data source header
239 */
241 {
242  std::string name; //!< Data Source Name
243  std::string type; //!< Data Source Type
244 };
245 
246 #endif // __TERRALIB_TOOLS_DSINFO_DSINFO_H
This file contains include headers for the Data Type module of TerraLib.
A base class for plugin types.
Struct that stores information about a index using the most common data types.
Definition: DSInfo.h:207
Struct that stores information about a data source header.
Definition: DSInfo.h:240
bool init(std::string dstype, std::string connstr)
Init the application.
std::vector< std::string > porperties
Foreign Key Properties in a string vector.
Definition: DSInfo.h:192
std::vector< UKInfo > vecUkInfo
Unique Key struct vector.
Definition: DSInfo.h:232
std::string m_connStr
The Data Source Connection String.
Definition: DSInfo.h:172
An utility class to control the startup and cleanup of the TerraLib Platform and its resources...
std::vector< std::string > porperties
Unique Key Properties in a string vector.
Definition: DSInfo.h:201
std::string type
Data Source Type.
Definition: DSInfo.h:243
DataSetStruct getDataSetInfo(std::string dataSetName)
Get specific Data Set information.
std::map< std::string, std::string > getCapabilities()
Get the Data Source Capabilities.
std::vector< std::string > porperties
Primary Key Properties in a string vector.
Definition: DSInfo.h:183
Struct that stores information about a check constraint using the most common data types...
Definition: DSInfo.h:217
std::vector< std::string > porperties
Index Properties in a string vector.
Definition: DSInfo.h:211
std::vector< IdxInfo > vecIdxInfo
Index struct vector.
Definition: DSInfo.h:233
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:118
std::string type
Index Type.
Definition: DSInfo.h:210
std::string name
Index Name.
Definition: DSInfo.h:209
std::vector< UKInfo > getUniqueKeyInfo(std::string dataSetName)
Get unique keys information.
Struct that stores information about a primary key using the most common data types.
Definition: DSInfo.h:180
std::string name
Primary Key Name.
Definition: DSInfo.h:182
std::vector< CCInfo > getCheckConstraintInfo(std::string dataSetName)
Get check constraint information.
Class with methods to manage the application.
Definition: DSInfo.h:58
std::string m_dataSourceType
The Data Source Type.
Definition: DSInfo.h:171
DataSourceHeader getDataSourceHeader()
Get the Data Source Header.
std::string expression
Check Constraint Expression.
Definition: DSInfo.h:220
A class that defines the interface of an abstract factory.
std::vector< CCInfo > vecCcInfo
Check Constraint struct vector.
Definition: DSInfo.h:234
std::vector< std::string * > getDataSetNameList()
Get all Data Sets names.
Struct that stores information about a data set using the most common data types. ...
Definition: DSInfo.h:226
std::string name
Check Constraint Name.
Definition: DSInfo.h:219
Struct that stores information about a unique key using the most common data types.
Definition: DSInfo.h:198
std::vector< FKInfo > getForeignKeyInfo(std::string dataSetName)
Get foreign keys information.
std::vector< IdxInfo > getIndexesKeyInfo(std::string dataSetName)
Get indexes information.
std::string name
Foreign Key Name.
Definition: DSInfo.h:191
A factory for data sources.
PKInfo getPrimaryKeyInfo(std::string dataSetName)
Get primary key information.
std::string name
Data Source Name.
Definition: DSInfo.h:242
A singleton for managing plugins.
te::da::DataSource * m_dataSource
The Data Source.
Definition: DSInfo.h:173
std::vector< FKInfo > vecFkInfo
Foreign Key struct vector.
Definition: DSInfo.h:231
This file contains include headers for the TerraLib Common Runtime module.
DSInfo()
Class Constructor.
Struct that stores information about a foreign key using the most common data types.
Definition: DSInfo.h:189
bool hasPk
If has Primary key.
Definition: DSInfo.h:229
This file contains include headers for the Data Access module of TerraLib.
std::map< std::string, std::vector< std::string > > getDataSourceParameters(std::string dataSourceType)
Get Data Source Types connection parameters.
std::string name
Unique Key Name.
Definition: DSInfo.h:200
std::vector< DataSetStruct > getDataSetsInfo()
Get all Data Sets informations.
std::string name
Data Set Name.
Definition: DSInfo.h:228
PKInfo pkInfo
Primary Key struct.
Definition: DSInfo.h:230