27 #include "../../common/Globals.h"
28 #include "../../common/STLUtils.h"
29 #include "../../common/StringUtils.h"
30 #include "../../common/Translator.h"
31 #include "../Exception.h"
47 throw Exception(
TR_DATAACCESS(
"Could not create the required data source instance!"));
62 throw Exception(
TR_DATAACCESS(
"Could not create the required data source instance!"));
64 ds->setConnectionInfo(connInfo);
76 std::map<std::string, std::string> connInfoMap;
80 return open(
id, dsType, connInfoMap);
94 newds->setConnectionInfo(connInfo);
111 if(it != m_dss.end())
120 throw Exception(
TR_DATAACCESS(
"Please, specifify a non-null data source to be managed!"));
124 if(m_dss.find(ds->getId()) != m_dss.end())
125 throw Exception(
TR_DATAACCESS(
"There is already a data source with the given identification!"));
127 m_dss[ds->getId()] = ds;
142 std::map<std::string, DataSourcePtr>::iterator it = m_dss.find(
id);
144 if(it == m_dss.end())
145 throw Exception(
TR_DATAACCESS(
"Invalid data source to detach!"));
158 std::map<std::string, DataSourcePtr>::iterator it = m_dss.begin();
160 while(it != m_dss.end())
161 if(it->second->getType() == dsType)
DataSourcePtr make(const std::string &id, const std::string &dsType)
It creates a new data source, stores a reference to it in the manager and then returns a pointer to i...
A factory for data sources.
void insert(const DataSourcePtr &ds)
It stores the data source in the manager.
DataSourcePtr open(const std::string &id, const std::string &dsType, const std::map< std::string, std::string > &connInfo)
It opens the data source, makes it ready for use, stores a reference to it in the manager and returns...
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
DataSourceManager()
It initializes the singleton instance of the data source manager.
static std::auto_ptr< DataSource > make(const std::string &dsType)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
void ExtractKVP(const std::string &kvpStr, std::map< std::string, std::string > &kvp, const std::string &kvpDelimiter="&", const std::string &kvDelimiter="=", bool toUpper=false)
It extracts a key-value map from a string.
void detachAll()
All data sources are detached from the manager.
void detach(const DataSourcePtr &ds)
It changes the ownership of the data source to the caller.
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockWrite
~DataSourceManager()
Singleton destructor.
boost::shared_ptr< DataSource > DataSourcePtr
DataSourcePtr get(const std::string &id, const std::string &dsType, const std::map< std::string, 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...
#define TR_DATAACCESS(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockRead
This is a singleton for managing all data source instances available in the system.
std::map< std::string, DataSourcePtr >::const_iterator const_iterator
DataSourcePtr find(const std::string &id) const
It returns the data source identified by the given id.