Loading...
Searching...
No Matches
DataSource.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/stmemory/DataSource.h
22
23 \brief Implements a DataSource that contains st memory DataSets indexed by space and time.
24*/
25
26#ifndef __TERRALIB_STMEMORY_INTERNAL_DATASOURCE_H
27#define __TERRALIB_STMEMORY_INTERNAL_DATASOURCE_H
28
29// TerraLib
30#include "../dataaccess/datasource/DataSource.h"
31#include "../dataaccess/datasource/DataSourceCapabilities.h"
32#include "../dataaccess/query/SQLDialect.h"
33#include "Config.h"
34
35// STL
36#include <map>
37#include <vector>
38
39namespace te { namespace da { class DataSetType; } }
40namespace te { namespace dt { class DateTimePeriod; } }
41
42namespace te
43{
44 namespace stmem
45 {
46// Forward declaration
47 class DataSet;
48 class Transactor;
49
50 /*!
51 \class DataSource
52
53 \brief Implements a DataSource that contains In-Memory DataSets indexed by space and time.
54
55 \sa te::da::DataSource
56 */
58 {
59 friend class Transactor;
60
61 public:
62
63 /*! \brief Constructor */
64 DataSource(const std::string& connInfo);
65
66 /*! \brief Constructor */
68
69 /*! \brief Destructor */
71
72 /*! \name DataSource inherited methods */
73 //@{
74 std::string getType() const;
75
76 std::unique_ptr<te::da::DataSourceTransactor> getTransactor();
77
78 void open();
79
80 void close();
81
82 bool isOpened() const;
83
84 bool isValid() const;
85
87
89 //@}
90
91 /*!
92 \brief It adds a new DataSet and DataSetType into the DataSource.
93
94 \param name The DataSet name.
95 \param t The DataSet Type.
96 \param d The DataSet.
97
98 \note It will take the ownership of the given pointers.
99 \note It can throw an Exception if there is already a DataSet with the given name
100 */
101 void add(const std::string& name, te::da::DataSetType* t, DataSet* d);
102
103 /*!
104 \brief It returns a data set with observations whose phenomenon times satisfy a
105 given temporal relation.
106
107 The possible temporal relations are: 1. AFTER;
108 2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
109
110 \param name The DataSet name.
111 \param dt A given datetime.
112 \param r A given temporal relation.
113 \param travType The traverse type associated to the returned dataset.
114 \param connected If the returned DataSet is connecet or not.
115
116 \return A pointer to a new DataSet that shares the intenal content.
117
118 \note The caller will take the ownership of the returned pointer.
119 \note When the temporal relation is DURING, dt must be a time period.
120 \note It can throw an Exception when internal errors occur.
121 */
122 std::unique_ptr<te::da::DataSet> getDataSet(const std::string& name,
125 bool connected = false,
126 const te::common::AccessPolicy accessPolicy = te::common::RAccess);
127
128 /*!
129 \brief It returns a data set with observations whose observed geometries satisfy a
130 given spatial relation and phenomenon times satisfy a given temporal relation.
131
132 The possible spatial relations are: INTERSECTS
133 The possible temporal relations are: 1. AFTER;
134 2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
135
136 \param name The DataSet name.
137 \param geom A given geometry.
138 \param sr A given spatial relation.
139 \param dt A given datetime.
140 \param tr A given temporal relation.
141 \param travType The traverse type associated to the returned dataset.
142 \param connected If the returned DataSet is connecet or not.
143
144 \return A pointer to a new DataSet that shares the intenal content.
145
146 \note The caller will take the ownership of the returned pointer.
147 \note It will NOT take the ownership of the given pointers.
148 \note When the temporal relation is DURING, dt must be a time period.
149 \note It can throw an Exception when internal errors occur.
150 */
151 std::unique_ptr<te::da::DataSet> getDataSet(const std::string& name,
155 bool connected = false,
156 const te::common::AccessPolicy accessPolicy = te::common::RAccess);
157
158 /*!
159 \brief It returns a data set with observations whose observed geometries satisfy a
160 given spatial relation and phenomenon times satisfy a given temporal relation.
161
162 The possible spatial relations are: INTERSECTS
163 The possible temporal relations are: 1. AFTER;
164 2. AFTER | EQUALS; 3. BEFORE; 4. BEFORE | EQUALS; 5. DURING; 6. EQUALS
165
166 \param name The DataSet name.
167 \param e A given envelope.
168 \param sr A given spatial relation.
169 \param dt A given datetime.
170 \param tr A given temporal relation.
171 \param travType The traverse type associated to the returned dataset.
172 \param connected If the returned DataSet is connecet or not.
173
174 \return A pointer to a new DataSet that shares the intenal content.
175
176 \note The caller will take the ownership of the returned pointer.
177 \note It will NOT take the ownership of the given pointers.
178 \note When the temporal relation is DURING, dt must be a time period.
179 \note It can throw an Exception when internal errors occur.
180 */
181 std::unique_ptr<te::da::DataSet> getDataSet(const std::string& name,
185 bool connected = false,
186 const te::common::AccessPolicy accessPolicy = te::common::RAccess);
187
188 /*!
189 \brief It returns the temporal extent associated to a DataSet.
190
191 \param name The DataSet name.
192
193 \return A pointer to its temporal extent.
194
195 \note The caller will take the ownership of the returned pointer.
196 \note It can throw an Exception when internal errors occur.
197 */
198 std::unique_ptr<te::dt::DateTimePeriod> getTemporalExtent(const std::string& name);
199
200 protected:
201
202 void create(const std::string& connInfo);
203
204 void drop(const std::string& connInfo);
205
206 bool exists(const std::string& connInfo);
207
208 std::vector<std::string> getDataSourceNames(const std::string& connInfo);
209
210 private:
211
212 std::map<std::string, DataSet* > m_datasets; //!< The set of datasets stored in memory.
213 std::map<std::string, te::da::DataSetType* > m_schemas; //!< The set of dataset schemas.
214 std::size_t m_maxdatasets; //!< The maximum number of datasets to be handled by the data source.
215 bool m_isOpened; //!< A flag to control the state of the data source.
216 bool m_deepCopy; //!< If true each dataset is cloned in the getDataSet method.
217 std::unique_ptr<Transactor> m_transactor; //!< A transactor
218
219 static te::da::DataSourceCapabilities sm_capabilities; //!< The Memory data source capabilities.
220 static const te::da::SQLDialect sm_dialect; //!< A dummy dialect.
221 };
222
223 } // end namespace stmem
224} // end namespace te
225
226#endif // __TERRALIB_STMEMORY_INTERNAL_DATASOURCE_H
227
A class to store the proxy information that must be used to access data located in URIs.
Definition: URI.h:50
A class that models the description of a dataset.
Definition: DataSetType.h:73
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:56
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
Implementation of a in-memory data set that contains spatiotemporal observations indexed by time and ...
Definition: DataSet.h:62
Implements a DataSource that contains In-Memory DataSets indexed by space and time.
Definition: DataSource.h:58
void close()
It closes the data source and clears all the resources used by its internal communication channel.
bool m_deepCopy
If true each dataset is cloned in the getDataSet method.
Definition: DataSource.h:216
bool isValid() const
It checks if the data source is valid (available for using).
std::unique_ptr< te::da::DataSet > getDataSet(const std::string &name, const te::dt::DateTime *dt, te::dt::TemporalRelation r=te::dt::DURING, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It returns a data set with observations whose phenomenon times satisfy a given temporal relation.
std::unique_ptr< te::da::DataSet > getDataSet(const std::string &name, const te::gm::Envelope *e, te::gm::SpatialRelation sr, const te::dt::DateTime *dt, te::dt::TemporalRelation tr=te::dt::DURING, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It returns a data set with observations whose observed geometries satisfy a given spatial relation an...
std::unique_ptr< te::da::DataSet > getDataSet(const std::string &name, const te::gm::Geometry *geom, te::gm::SpatialRelation sr, const te::dt::DateTime *dt, te::dt::TemporalRelation tr=te::dt::DURING, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It returns a data set with observations whose observed geometries satisfy a given spatial relation an...
static te::da::DataSourceCapabilities sm_capabilities
The Memory data source capabilities.
Definition: DataSource.h:219
DataSource(const te::core::URI &uri)
Constructor.
std::unique_ptr< te::da::DataSourceTransactor > getTransactor()
It returns the set of parameters used to set up the access channel to the underlying repository.
std::map< std::string, DataSet * > m_datasets
The set of datasets stored in memory.
Definition: DataSource.h:212
std::size_t m_maxdatasets
The maximum number of datasets to be handled by the data source.
Definition: DataSource.h:214
DataSource(const std::string &connInfo)
Constructor.
bool exists(const std::string &connInfo)
Check the existence of a data source in a driver.
static const te::da::SQLDialect sm_dialect
A dummy dialect.
Definition: DataSource.h:220
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS,...
std::map< std::string, te::da::DataSetType * > m_schemas
The set of dataset schemas.
Definition: DataSource.h:213
std::vector< std::string > getDataSourceNames(const std::string &connInfo)
It gets the data source names available in a driver.
void open()
It opens the data source and makes it ready for using.
std::unique_ptr< Transactor > m_transactor
A transactor.
Definition: DataSource.h:217
void create(const std::string &connInfo)
It creates a new data source.
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
~DataSource()
Destructor.
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
void drop(const std::string &connInfo)
It removes the data source with the connection information from a driver.
std::unique_ptr< te::dt::DateTimePeriod > getTemporalExtent(const std::string &name)
It returns the temporal extent associated to a DataSet.
bool m_isOpened
A flag to control the state of the data source.
Definition: DataSource.h:215
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
void add(const std::string &name, te::da::DataSetType *t, DataSet *d)
It adds a new DataSet and DataSetType into the DataSource.
An implementation of DataSourceTransactor class for the ST in-memory driver.
Definition: Transactor.h:50
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:54
@ FORWARDONLY
Definition: Enums.h:55
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
@ RAccess
Definition: Enums.h:43
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
Definition: Enums.h:141
@ DURING
Definition: Enums.h:145
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:128
TerraLib.
#define TESTMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
Proxy configuration file for TerraView (see terraview_config.h).