Skip to content
Snippets Groups Projects
Commit 4acd9dfe authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Added the possibility to have global services. These are shared among threads...

Added the possibility to have global services. These are shared among threads and thus should be thread safe.
parent 5368c5d5
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @(#)$RCSfile: Services.cpp,v $ $Revision: 1.5 $ $Release$ $Date: 2004/06/30 14:28:43 $ $Author: sponcec3 $
* @(#)$RCSfile: Services.cpp,v $ $Revision: 1.6 $ $Release$ $Date: 2004/07/07 15:59:32 $ $Author: sponcec3 $
*
*
*
......@@ -38,6 +38,11 @@
#include "castor/exception/Exception.hpp"
#include "castor/exception/Internal.hpp"
//-----------------------------------------------------------------------------
// Global Services object for global services, like MsgSvcs
//-----------------------------------------------------------------------------
castor::Services* g_services = 0;
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
......@@ -84,6 +89,17 @@ castor::IService* castor::Services::service(const std::string name,
return m_services[name];
}
//-----------------------------------------------------------------------------
// globalService
//-----------------------------------------------------------------------------
castor::IService* castor::Services::globalService
(const std::string name, const unsigned int id) throw() {
if (0 == g_services) {
g_services = new Services();
}
return g_services->service(name, id);
}
//-----------------------------------------------------------------------------
// cnvService
//-----------------------------------------------------------------------------
......
......@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @(#)$RCSfile: Services.hpp,v $ $Revision: 1.7 $ $Release$ $Date: 2004/06/30 14:28:43 $ $Author: sponcec3 $
* @(#)$RCSfile: Services.hpp,v $ $Revision: 1.8 $ $Release$ $Date: 2004/07/07 15:59:32 $ $Author: sponcec3 $
*
*
*
......@@ -60,6 +60,15 @@ namespace castor {
IService* service (const std::string name,
const unsigned int id = 0) throw();
/**
* gets a global service by name. By global we mean
* that this service may be shared among threads.
* If id not 0 and the service does not exist, it
* is created.
*/
static IService* globalService (const std::string name,
const unsigned int id = 0) throw();
/**
* gets a conversion service by name.
* If id not 0 and the service does not exist, it
......@@ -167,6 +176,7 @@ namespace castor {
castor::ICnvSvc* cnvSvcFromAddress(castor::IAddress* address);
private:
/** the list of services, by name */
std::map<const std::string, IService*> m_services;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment