Loading...
Searching...
No Matches
DataSourceCatalogManager.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/dataaccess/datasource/DataSourceCatalogManager.h
22
23 \brief This is a singleton for managing all the data source catalog instances available in the system.
24*/
25
26#ifndef __TERRALIB_DATAACCESS_INTERNAL_DATASOURCECATALOGMANAGER_H
27#define __TERRALIB_DATAACCESS_INTERNAL_DATASOURCECATALOGMANAGER_H
28
29// TerraLib
30#include "../../common/Comparators.h"
31#include "../../common/Singleton.h"
32#include "../../common/ThreadingPolicies.h"
33#include "DataSource.h"
34#include "DataSourceCatalog.h"
35
36// STL
37#include <map>
38#include <string>
39
40namespace te
41{
42 namespace da
43 {
44 /*!
45 \class DataSourceCatalogManager
46
47 \brief This is a singleton for managing all the data source catalog instances available in the system.
48
49 \ingroup dataaccess
50
51 \sa DataSource, DataSourceCatalog, te::common::Singleton
52 */
54 ::boost::recursive_mutex,
55 ::boost::lock_guard< ::boost::recursive_mutex>,
56 ::boost::lock_guard< ::boost::recursive_mutex> >,
57 public te::common::Singleton<DataSourceCatalogManager>
58 {
60
61 public:
62
63 typedef std::map<DataSourcePtr, DataSourceCatalogPtr>::const_iterator const_iterator;
64 typedef std::map<DataSourcePtr, DataSourceCatalogPtr>::iterator iterator;
65
66 /*!
67 \brief It creates a catalog for the given data source, loads their sequences and the information
68 about the schemas of the datasets contained in the data source. The catalog created is
69 registered into the manager and it is returned to the caller.
70
71 \param ds The data source whose catalog will be created.
72
73 \return A pointer to the new data source catalog.
74
75 \exception Exception It throws an exception if there is already a catalog to the given data source.
76
77 \note Thread-safe!
78 */
80
81 /*!
82 \brief It gets the catalog associated to the given data source. If there is no catalog registered
83 in the manager, a catalog is created and registered in the manager.
84
85 \param ds The data source whose catalog is to be retrieved.
86
87 \return The catalog associated to the data source.
88
89 \note Thread-safe!
90 */
92
93 /*!
94 \brief It tries to find the catalog associated to the given data source.
95
96 \param ds The data source whose catalog is to be found.
97
98 \return True, if the catalog associated to the data source is found; otherwise, it returns false.
99
100 \note Thread-safe!
101 */
102 bool find(const DataSourcePtr& ds) const;
103
104 /*!
105 \brief It inserts the data source catalog into the manager.
106 The catalog must have a data source in order to be inserted.
107
108 \param catalog The catalog to be inserted into the manager.
109
110 \note The manager will take the ownership of the catalog.
111
112 \exception Exception It throws an exception, if already exists a catalog for the data source of the given catalog.
113
114 \note Thread-safe!
115 */
116 void insert(const DataSourceCatalogPtr& catalog);
117
118 /*!
119 \brief It changes the ownership of the data source catalog to the caller.
120
121 The memory used by the given data source catalog will NOT BE released.
122 In other words, you will take the ownership of the data source catalog.
123
124 \param ds The data source catalog to be detached.
125
126 \note Thread-safe!
127 */
129
130 /*!
131 \brief It changes the ownership of the data source catalog associated to the given data source.
132
133 \param ds The data source.
134
135 \return The catalog associated to the given data source. The caller will take the ownership of
136 this catalog.
137
138 \note Thread-safe!
139 */
141
142 /*!
143 \brief All the catalogs whose data sources are of the specified type are detached from the manager.
144
145 \note Thread-safe!
146 */
147 void detachAll(const std::string& dsType);
148
149 /*!
150 \brief All the catalogs are detached from the manager.
151
152 \note Thread-safe!
153 */
154 void detachAll();
155
156 /*!
157 \brief It returns the number of data source catalogs that the manager are keeping track of.
158
159 \return The number of tracked data source catalogs.
160 */
161 std::size_t size() const;
162
163 /*!
164 \brief It returns an iterator to the beginning of the container.
165
166 \return A constant iterator to the beginning of the container.
167 */
168 const_iterator begin() const;
169
170 /*!
171 \brief It returns an iterator to the beginning of the container.
172
173 \return An iterator to the beginning of the container.
174 */
175 iterator begin();
176
177 /*!
178 \brief It returns an iterator to the end of the container.
179
180 \return An iterator to the beginning of the container.
181 */
182 const_iterator end() const;
183
184 /*!
185 \brief It returns an iterator to the end of the container.
186
187 \return An iterator to the beginning of the container.
188 */
189 iterator end();
190
191 protected:
192
193 /*! \brief It initializes the singleton instance of the data source catalog manager. */
195
196 /*! \brief Singleton destructor. */
198
199 private:
200
201 std::map<DataSourcePtr, DataSourceCatalogPtr> m_catalogs; //!< The catalogs registered in the manager.
202 };
203
204 inline std::size_t DataSourceCatalogManager::size() const
205 {
206 return m_catalogs.size();
207 }
208
210 {
211 return m_catalogs.begin();
212 }
213
215 {
216 return m_catalogs.begin();
217 }
218
220 {
221 return m_catalogs.end();
222 }
223
225 {
226 return m_catalogs.end();
227 }
228
229 } // end namespace da
230} // end namespace te
231
232
233#endif // __TERRALIB_DATAACCESS_INTERNAL_DATASOURCECATALOGMANAGER_H
It represents the system catalog of a DataSource.
This policy assures an object-level locking scheme for a derived class.
Template support for singleton pattern.
Definition: Singleton.h:101
This is a singleton for managing all the data source catalog instances available in the system.
const_iterator begin() const
It returns an iterator to the beginning of the container.
const_iterator end() const
It returns an iterator to the end of the container.
std::map< DataSourcePtr, DataSourceCatalogPtr >::const_iterator const_iterator
DataSourceCatalogPtr detach(const DataSourcePtr &ds)
It changes the ownership of the data source catalog associated to the given data source.
void detachAll(const std::string &dsType)
All the catalogs whose data sources are of the specified type are detached from the manager.
std::map< DataSourcePtr, DataSourceCatalogPtr >::iterator iterator
void detach(DataSourceCatalogPtr catalog)
It changes the ownership of the data source catalog to the caller.
DataSourceCatalogPtr get(DataSourcePtr ds)
It gets the catalog associated to the given data source. If there is no catalog registered in the man...
std::size_t size() const
It returns the number of data source catalogs that the manager are keeping track of.
std::map< DataSourcePtr, DataSourceCatalogPtr > m_catalogs
The catalogs registered in the manager.
bool find(const DataSourcePtr &ds) const
It tries to find the catalog associated to the given data source.
void detachAll()
All the catalogs are detached from the manager.
DataSourceCatalogPtr create(DataSourcePtr ds)
It creates a catalog for the given data source, loads their sequences and the information about the s...
~DataSourceCatalogManager()
Singleton destructor.
DataSourceCatalogManager()
It initializes the singleton instance of the data source catalog manager.
void insert(const DataSourceCatalogPtr &catalog)
It inserts the data source catalog into the manager. The catalog must have a data source in order to ...
boost::shared_ptr< DataSourceCatalog > DataSourceCatalogPtr
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1449
TerraLib.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97
Data Source for WS OGC WMS.