2 * BatchManagerCatalog.cxx :
4 * Auteur : Ivan DUTKA-MALEN - EDF R&D
5 * Date : Septembre 2004
13 #include "Batch_BatchManagerCatalog.hxx"
14 #include "Batch_FactBatchManager.hxx"
18 pthread_mutex_t BatchManagerCatalog::_mutex = PTHREAD_MUTEX_INITIALIZER;
19 map<string, FactBatchManager *> * BatchManagerCatalog::_p_catalog = 0;
22 BatchManagerCatalog::BatchManagerCatalog()
28 BatchManagerCatalog::~BatchManagerCatalog()
34 FactBatchManager * BatchManagerCatalog::getFactBatchManager(const char * type)
36 return (* BatchManagerCatalog::_p_catalog)[type];
39 void BatchManagerCatalog::addFactBatchManager(const char * type, FactBatchManager * pFBM)
41 if (pFBM) { // *** section critique ***
42 pthread_mutex_lock(&_mutex);
44 if (! BatchManagerCatalog::_p_catalog) BatchManagerCatalog::_p_catalog = new map<string, FactBatchManager *>;
45 (*BatchManagerCatalog::_p_catalog)[type] = pFBM;
47 pthread_mutex_unlock(&_mutex);
51 FactBatchManager * BatchManagerCatalog::operator() (const char * type) const
53 return BatchManagerCatalog::getFactBatchManager(type);
56 map<string, FactBatchManager *> * BatchManagerCatalog::dict() const
61 string BatchManagerCatalog::__repr__() const
64 oss << "<BatchManagerCatalog contains {";
66 for(map<string, FactBatchManager *>::const_iterator it = (*_p_catalog).begin(); it != (*_p_catalog).end(); it++, sep=", ") {
67 oss << sep << "'" << (*it).first << "' : '" << (*it).second->__repr__() << "'";