27 #include "../../common/STLUtils.h"
28 #include "../../common/Translator.h"
29 #include "../Exception.h"
37 #include <boost/foreach.hpp>
38 #include <boost/format.hpp>
42 std::map<std::string, DataSourceInfoPtr>::const_iterator it =
m_datasources.find(
id);
50 throw Exception(
TR_DATAACCESS(
"Can not insert a NULL data source into the manager!"));
52 if(m_datasources.find(ds->getId()) != m_datasources.end())
53 throw Exception((boost::format(
TR_DATAACCESS(
"There is already a data source with the given id (%1%) in data source manager!")) % ds->getId()).str());
55 m_datasources[ds->getId()] = ds;
60 std::map<std::string, DataSourceInfoPtr>::iterator it = m_datasources.find(
id);
62 if(it == m_datasources.end())
63 throw Exception((boost::format(
TR_DATAACCESS(
"There isn't a data source with the given id (%1%) in data source manager!")) %
id).str());
65 m_datasources.erase(it);
70 std::map<std::string, DataSourceInfoPtr>::iterator it = m_datasources.begin();
72 while(it!=m_datasources.end())
73 if(it->second->getType() == dsTypeName)
74 m_datasources.erase(it++);
82 std::map<std::string, DataSourceInfoPtr>::const_iterator it = m_datasources.begin();
83 std::map<std::string, DataSourceInfoPtr>::const_iterator itend = m_datasources.end();
87 if(it->second->getType() == dsTypeName)
88 datasources.push_back(it->second);
96 return m_datasources.size();
101 return m_datasources.begin();
106 return m_datasources.begin();
111 return m_datasources.end();
116 return m_datasources.end();
DataSourceInfoPtr get(const std::string &id) const
std::map< std::string, DataSourceInfoPtr >::iterator iterator
const_iterator begin() const
void removeByType(const std::string &dsTypeName)
std::map< std::string, DataSourceInfoPtr >::const_iterator const_iterator
void remove(const std::string &id)
A singleton to keep all the registered data sources.
void add(const DataSourceInfoPtr &ds)
const_iterator end() const
std::map< std::string, DataSourceInfoPtr > m_datasources
#define TR_DATAACCESS(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
void getByType(const std::string &dsTypeName, std::vector< DataSourceInfoPtr > &datasources) const
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
A conteiner class for keeping information about a data source.