27 #include "../../common/Globals.h" 28 #include "../../common/STLUtils.h" 29 #include "../../common/StringUtils.h" 30 #include "../../core/translator/Translator.h" 31 #include "../Exception.h" 49 if (ds.get() ==
nullptr)
50 throw Exception(
TE_TR(
"Could not create the required data source instance!"));
67 if (ds.get() ==
nullptr)
68 throw Exception(
TE_TR(
"Could not create the required data source instance!"));
82 if(ds.get() ==
nullptr)
83 throw Exception(
TE_TR(
"Could not create the required data source instance!"));
99 if (ds.get() ==
nullptr)
100 throw Exception(
TE_TR(
"Could not create the required data source instance!"));
117 if(it !=
m_dss.end())
122 if (newds.get() == 0)
123 throw Exception(
TE_TR(
"Could not create the required data source instance!"));
140 if (it !=
m_dss.end())
145 if (newds.get() == 0)
146 throw Exception(
TE_TR(
"Could not create the required data source instance!"));
162 if(it !=
m_dss.end())
170 if(ds.get() ==
nullptr)
171 throw Exception(
TE_TR(
"Please, specifify a non-null data source to be managed!"));
176 throw Exception(
TE_TR(
"There is already a data source with the given identification!"));
183 if(ds.get() ==
nullptr)
193 std::map<std::string, DataSourcePtr>::iterator it =
m_dss.find(
id);
195 if(it ==
m_dss.end())
209 std::map<std::string, DataSourcePtr>::iterator it =
m_dss.begin();
211 while(it !=
m_dss.end())
212 if(it->second->getType() == dsType)
~DataSourceManager()
Singleton destructor.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
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. ...
Base exception class for plugin module.
This is a singleton for managing all data source instances available in the system.
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 i...
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.
static te::dt::Date ds(2010, 01, 01)
#define TE_TR(message)
It marks a string in order to get translated.
A factory for data sources.
void insert(const DataSourcePtr &ds)
It stores the data source in the manager.
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockWrite
std::map< std::string, DataSourcePtr > m_dss
The data sources kept in the manager.
A class for representing an Uniform Resource Identifier (URI).
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...
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockRead
std::map< std::string, DataSourcePtr >::const_iterator const_iterator
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...