27 #include "../../common/Globals.h"
28 #include "../../common/STLUtils.h"
29 #include "../../common/StringUtils.h"
30 #include "../../common/Translator.h"
31 #include "../Exception.h"
50 throw Exception(
TE_TR(
"Could not create the required data source instance!"));
65 throw Exception(
TE_TR(
"Could not create the required data source instance!"));
67 ds->setConnectionInfo(connInfo);
79 std::map<std::string, std::string> connInfoMap;
83 return open(
id, dsType, connInfoMap);
97 newds->setConnectionInfo(connInfo);
114 if(it != m_dss.end())
123 throw Exception(
TE_TR(
"Please, specifify a non-null data source to be managed!"));
127 if(m_dss.find(ds->getId()) != m_dss.end())
128 throw Exception(
TE_TR(
"There is already a data source with the given identification!"));
130 m_dss[ds->getId()] = ds;
145 std::map<std::string, DataSourcePtr>::iterator it = m_dss.find(
id);
147 if(it == m_dss.end())
148 throw Exception(
TE_TR(
"Invalid data source to detach!"));
161 std::map<std::string, DataSourcePtr>::iterator it = m_dss.begin();
163 while(it != m_dss.end())
164 if(it->second->getType() == dsType)
~DataSourceManager()
Singleton destructor.
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...
void detach(const DataSourcePtr &ds)
It changes the ownership of the data source to the caller.
boost::shared_ptr< DataSource > DataSourcePtr
DataSourceManager()
It initializes the singleton instance of the data source manager.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
This is a singleton for managing all data source instances available in the system.
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.
DataSourcePtr find(const std::string &id) const
It returns the data source identified by the given id.
void detachAll()
All data sources are detached from the manager.
#define TE_TR(message)
It marks a string in order to get translated.
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...
static std::auto_ptr< DataSource > make(const std::string &dsType)
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
void insert(const DataSourcePtr &ds)
It stores the data source in the manager.
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockWrite
A factory for data sources.
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...
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockRead
std::map< std::string, DataSourcePtr >::const_iterator const_iterator