te::da::DataSourceManager Class Reference

This is a singleton for managing all data source instances available in the system. More...

#include <DataSourceManager.h>

Inheritance diagram for te::da::DataSourceManager:
te::common::ObjectLevelLockable< DataSourceManager,::boost::recursive_mutex,::boost::lock_guard< ::boost::recursive_mutex >,::boost::lock_guard< ::boost::recursive_mutex > > te::common::Singleton< DataSourceManager >

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 DataSourceManagergetInstance ()
 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, DataSourcePtrm_dss
 The data sources kept in the manager. More...
 

Friends

class te::common::Singleton< DataSourceManager >
 

Detailed Description

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.

See also
DataSource, DataSourceFactory, te::common::Singleton, ConnectionPoolManager
Warning
Developers: take care when adding new methods to this class as it uses synchronization primitives!

Definition at line 62 of file DataSourceManager.h.

Member Typedef Documentation

Definition at line 72 of file DataSourceManager.h.

Definition at line 73 of file DataSourceManager.h.

typedef ObjectLevelLockingPolicy<::boost::lock_guard< ::boost::recursive_mutex > > te::common::ObjectLevelLockable< DataSourceManager , ::boost::recursive_mutex , ::boost::lock_guard< ::boost::recursive_mutex > , ::boost::lock_guard< ::boost::recursive_mutex > >::LockRead
inherited

Definition at line 205 of file ThreadingPolicies.h.

typedef ObjectLevelLockingPolicy<::boost::lock_guard< ::boost::recursive_mutex > > te::common::ObjectLevelLockable< DataSourceManager , ::boost::recursive_mutex , ::boost::lock_guard< ::boost::recursive_mutex > , ::boost::lock_guard< ::boost::recursive_mutex > >::LockWrite
inherited

Definition at line 206 of file ThreadingPolicies.h.

typedef volatile DataSourceManager te::common::ObjectLevelLockable< DataSourceManager , ::boost::recursive_mutex , ::boost::lock_guard< ::boost::recursive_mutex > , ::boost::lock_guard< ::boost::recursive_mutex > >::VolatileType
inherited

Definition at line 204 of file ThreadingPolicies.h.

Constructor & Destructor Documentation

te::da::DataSourceManager::DataSourceManager ( )
protected

It initializes the singleton instance of the data source manager.

te::da::DataSourceManager::~DataSourceManager ( )
protected

Singleton destructor.

Member Function Documentation

DataSourceManager::const_iterator te::da::DataSourceManager::begin ( ) const
inline

It returns an iterator to the beginning of the conteiner.

Returns
An iterator to the beginning of the conteiner.

Definition at line 291 of file DataSourceManager.h.

References m_dss.

DataSourceManager::iterator te::da::DataSourceManager::begin ( )
inline

It returns an iterator to the beginning of the conteiner.

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.

Parameters
dsThe data source to be detached.
Note
Thread-safe!
DataSourcePtr te::da::DataSourceManager::detach ( const std::string &  id)

It changes the ownership of the data source with the given identifier to the caller.

Parameters
idThe data source identifier.
Returns
The data source identified by id. The caller takes the data source ownership.
Note
Thread-safe!
void te::da::DataSourceManager::detachAll ( const std::string &  dsType)

All data sources of the specified type are detached from the manager.

Note
Thread-safe!
void te::da::DataSourceManager::detachAll ( )

All data sources are detached from the manager.

Note
Thread-safe!
DataSourceManager::const_iterator te::da::DataSourceManager::end ( ) const
inline

It returns an iterator to the end of the conteiner.

Returns
An iterator to the beginning of the conteiner.

Definition at line 301 of file DataSourceManager.h.

References m_dss.

DataSourceManager::iterator te::da::DataSourceManager::end ( )
inline

It returns an iterator to the end of the conteiner.

Returns
An iterator to the beginning 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.

Parameters
idThe data source identification.
Returns
The data source with the given id, or NULL if none is found.
Note
Thread-safe!
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.

Parameters
idThe data source identification.
dsTypeThe data source type name (example: PostGIS, Oracle, WFS).
connInfoThe set of parameters, as a valid URI string, used to set up the underlying access channel to the repository.
Returns
A pointer to the new opened data source.
Exceptions
ExceptionIt throws an exception if the data source can not be opened.
Note
This method doesn't load the data source catalog.
Thread-safe!
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.

Parameters
idThe data source identification.
dsTypeThe data source type name (example: PostGIS, Oracle, WFS).
connInfoThe set of parameters used to set up the underlying access channel to the repository.
Returns
A pointer to the new opened data source.
Exceptions
ExceptionIt throws an exception if the data source can not be opened.
Note
This method doesn't load the data source catalog.
Thread-safe!
static DataSourceManager & te::common::Singleton< DataSourceManager >::getInstance ( )
staticinherited

It returns a reference to the singleton instance.

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.

Parameters
dsThe data source to be stored in the manager.
Note
The manager will take the ownership of the data source.
Exceptions
ExceptionIt throws an exception if a data source with the same identification already exist or if the data source id is empty.
Note
Thread-safe!
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.

Parameters
idThe identification to be assigned to the data source.
dsTypeThe data source type name (example: PostGIS, Oracle, WFS).
connInfoThe URI, as a valid string, used to set up the underlying access channel to the repository.
Returns
A pointer to the new data source.
Exceptions
ExceptionIt throws an exception if a data source with the same identification already exist.
Note
Thread-safe!
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.

Parameters
idThe identification to be assigned to the data source.
dsTypeThe data source type name (example: PostGIS, Oracle, WFS).
connInfoThe URI used to set up the underlying access channel to the repository.
Returns
A pointer to the new data source.
Exceptions
ExceptionIt throws an exception if a data source with the same identification already exist.
Note
Thread-safe!
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.

Parameters
idThe identification to be assigned to the data source.
dsTypeThe data source type name (example: PostGIS, Oracle, WFS).
connInfoThe URI, as a valid string, used to set up the underlying access channel to the repository.
Returns
A pointer to the new opened data source.
Exceptions
ExceptionIt throws an exception if the data source can not be opened or if a data source with the same identification already exist.
Note
This method doesn't load the data source catalog.
Thread-safe!
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.

Parameters
idThe identification to be assigned to the data source.
dsTypeThe data source type name (example: PostGIS, Oracle, WFS).
connInfoThe URI used to set up the underlying access channel to the repository.
Returns
A pointer to the new opened data source.
Exceptions
ExceptionIt throws an exception if the data source can not be opened or if a data source with the same identification already exist.
Note
This method doesn't load the data source catalog.
Thread-safe!
std::size_t te::da::DataSourceManager::size ( ) const
inline

It returns the number of data sources that the manager are keeping track of.

Returns
The number of tracked data sources.
Note
Thread-safe: but take care when relying on this value in a multi-threaded environment!

Definition at line 286 of file DataSourceManager.h.

References m_dss.

Friends And Related Function Documentation

friend class te::common::Singleton< DataSourceManager >
friend

Definition at line 68 of file DataSourceManager.h.

Member Data Documentation

std::map<std::string, DataSourcePtr> te::da::DataSourceManager::m_dss
private

The data sources kept in the manager.

Definition at line 283 of file DataSourceManager.h.

Referenced by begin(), end(), and size().


The documentation for this class was generated from the following file: