This is a singleton for managing all data source instances available in the system. More...
#include <DataSourceManager.h>
Public Types | |
typedef std::map< std::string, DataSourcePtr >::const_iterator | const_iterator |
typedef std::map< std::string, DataSourcePtr >::iterator | iterator |
typedef ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > | LockRead |
typedef ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > | LockWrite |
typedef volatile DataSourceManager | VolatileType |
Public Member Functions | |
const_iterator | begin () const |
It returns an iterator to the beginning of the conteiner. More... | |
iterator | begin () |
It returns an iterator to the beginning of the conteiner. More... | |
void | detach (const DataSourcePtr &ds) |
It changes the ownership of the data source to the caller. More... | |
DataSourcePtr | detach (const std::string &id) |
It changes the ownership of the data source with the given identifier to the caller. More... | |
void | detachAll (const std::string &dsType) |
All data sources of the specified type are detached from the manager. More... | |
void | detachAll () |
All data sources are detached from the manager. More... | |
const_iterator | end () const |
It returns an iterator to the end of the conteiner. More... | |
iterator | end () |
It returns an iterator to the end of the conteiner. More... | |
DataSourcePtr | find (const std::string &id) const |
It returns the data source identified by the given id. More... | |
DataSourcePtr | get (const std::string &id, const std::string &dsType, const std::string &connInfo) |
It searches for an opened data source with the given id or it opens a new one if it doesn't exists. More... | |
DataSourcePtr | get (const std::string &id, const std::string &dsType, const te::core::URI &connInfo) |
It searches for an opened data source with the given id or it opens a new one if it doesn't exists. More... | |
void | insert (const DataSourcePtr &ds) |
It stores the data source in the manager. More... | |
DataSourcePtr | make (const std::string &id, const std::string &dsType, const std::string &connInfo) |
It creates a new data source, stores a reference to it in the manager and then returns a pointer to it. More... | |
DataSourcePtr | make (const std::string &id, const std::string &dsType, const te::core::URI &connInfo) |
It creates a new data source, stores a reference to it in the manager and then returns a pointer to it. More... | |
DataSourcePtr | open (const std::string &id, const std::string &dsType, const std::string &connInfo) |
It opens the data source, makes it ready for use, stores a reference to it in the manager and returns a pointer to it. More... | |
DataSourcePtr | open (const std::string &id, const std::string &dsType, const te::core::URI &connInfo) |
It opens the data source, makes it ready for use, stores a reference to it in the manager and returns a pointer to it. More... | |
std::size_t | size () const |
It returns the number of data sources that the manager are keeping track of. More... | |
Static Public Member Functions | |
static DataSourceManager & | getInstance () |
It returns a reference to the singleton instance. More... | |
Protected Member Functions | |
DataSourceManager () | |
It initializes the singleton instance of the data source manager. More... | |
~DataSourceManager () | |
Singleton destructor. More... | |
Private Attributes | |
std::map< std::string, DataSourcePtr > | m_dss |
The data sources kept in the manager. More... | |
Friends | |
class | te::common::Singleton< DataSourceManager > |
This is a singleton for managing all data source instances available in the system.
Prefer using the methods from this singleton instead of using the data source factory because it keeps track of the data sources available in the system.
Another reason to use it in your application is that the application can choose any strategy to label data sources, for examples, using a descriptive title provided by the user or using an unique-universal-identifier (uid) generated by an algorithm.
Definition at line 62 of file DataSourceManager.h.
typedef std::map<std::string, DataSourcePtr>::const_iterator te::da::DataSourceManager::const_iterator |
Definition at line 72 of file DataSourceManager.h.
typedef std::map<std::string, DataSourcePtr>::iterator te::da::DataSourceManager::iterator |
Definition at line 73 of file DataSourceManager.h.
|
inherited |
Definition at line 205 of file ThreadingPolicies.h.
|
inherited |
Definition at line 206 of file ThreadingPolicies.h.
|
inherited |
Definition at line 204 of file ThreadingPolicies.h.
|
protected |
It initializes the singleton instance of the data source manager.
|
protected |
Singleton destructor.
|
inline |
It returns an iterator to the beginning of the conteiner.
Definition at line 291 of file DataSourceManager.h.
References m_dss.
|
inline |
It returns an iterator to the beginning of the conteiner.
Definition at line 296 of file DataSourceManager.h.
References m_dss.
void te::da::DataSourceManager::detach | ( | const DataSourcePtr & | ds | ) |
It changes the ownership of the data source to the caller.
The memory used by the given data source will NOT BE released. In other words, you will take the ownership of the data source pointer.
ds | The data source to be detached. |
DataSourcePtr te::da::DataSourceManager::detach | ( | const std::string & | id | ) |
It changes the ownership of the data source with the given identifier to the caller.
id | The data source identifier. |
void te::da::DataSourceManager::detachAll | ( | const std::string & | dsType | ) |
All data sources of the specified type are detached from the manager.
void te::da::DataSourceManager::detachAll | ( | ) |
All data sources are detached from the manager.
|
inline |
It returns an iterator to the end of the conteiner.
Definition at line 301 of file DataSourceManager.h.
References m_dss.
|
inline |
It returns an iterator to the end of the conteiner.
Definition at line 306 of file DataSourceManager.h.
References m_dss.
DataSourcePtr te::da::DataSourceManager::find | ( | const std::string & | id | ) | const |
It returns the data source identified by the given id.
id | The data source identification. |
DataSourcePtr te::da::DataSourceManager::get | ( | const std::string & | id, |
const std::string & | dsType, | ||
const std::string & | connInfo | ||
) |
It searches for an opened data source with the given id or it opens a new one if it doesn't exists.
id | The data source identification. |
dsType | The data source type name (example: PostGIS, Oracle, WFS). |
connInfo | The set of parameters, as a valid URI string, used to set up the underlying access channel to the repository. |
Exception | It throws an exception if the data source can not be opened. |
DataSourcePtr te::da::DataSourceManager::get | ( | const std::string & | id, |
const std::string & | dsType, | ||
const te::core::URI & | connInfo | ||
) |
It searches for an opened data source with the given id or it opens a new one if it doesn't exists.
id | The data source identification. |
dsType | The data source type name (example: PostGIS, Oracle, WFS). |
connInfo | The set of parameters used to set up the underlying access channel to the repository. |
Exception | It throws an exception if the data source can not be opened. |
|
staticinherited |
It returns a reference to the singleton instance.
void te::da::DataSourceManager::insert | ( | const DataSourcePtr & | ds | ) |
It stores the data source in the manager.
The data source must have an identification in order to be inserted.
ds | The data source to be stored in the manager. |
Exception | It throws an exception if a data source with the same identification already exist or if the data source id is empty. |
DataSourcePtr te::da::DataSourceManager::make | ( | const std::string & | id, |
const std::string & | dsType, | ||
const std::string & | connInfo | ||
) |
It creates a new data source, stores a reference to it in the manager and then returns a pointer to it.
id | The identification to be assigned to the data source. |
dsType | The data source type name (example: PostGIS, Oracle, WFS). |
connInfo | The URI, as a valid string, used to set up the underlying access channel to the repository. |
Exception | It throws an exception if a data source with the same identification already exist. |
DataSourcePtr te::da::DataSourceManager::make | ( | const std::string & | id, |
const std::string & | dsType, | ||
const te::core::URI & | connInfo | ||
) |
It creates a new data source, stores a reference to it in the manager and then returns a pointer to it.
id | The identification to be assigned to the data source. |
dsType | The data source type name (example: PostGIS, Oracle, WFS). |
connInfo | The URI used to set up the underlying access channel to the repository. |
Exception | It throws an exception if a data source with the same identification already exist. |
DataSourcePtr te::da::DataSourceManager::open | ( | const std::string & | id, |
const std::string & | dsType, | ||
const std::string & | connInfo | ||
) |
It opens the data source, makes it ready for use, stores a reference to it in the manager and returns a pointer to it.
id | The identification to be assigned to the data source. |
dsType | The data source type name (example: PostGIS, Oracle, WFS). |
connInfo | The URI, as a valid string, used to set up the underlying access channel to the repository. |
Exception | It throws an exception if the data source can not be opened or if a data source with the same identification already exist. |
DataSourcePtr te::da::DataSourceManager::open | ( | const std::string & | id, |
const std::string & | dsType, | ||
const te::core::URI & | connInfo | ||
) |
It opens the data source, makes it ready for use, stores a reference to it in the manager and returns a pointer to it.
id | The identification to be assigned to the data source. |
dsType | The data source type name (example: PostGIS, Oracle, WFS). |
connInfo | The URI used to set up the underlying access channel to the repository. |
Exception | It throws an exception if the data source can not be opened or if a data source with the same identification already exist. |
|
inline |
It returns the number of data sources that the manager are keeping track of.
Definition at line 286 of file DataSourceManager.h.
References m_dss.
|
friend |
Definition at line 68 of file DataSourceManager.h.
|
private |
The data sources kept in the manager.
Definition at line 283 of file DataSourceManager.h.