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"
19 pthread_mutex_t BatchManagerCatalog::_mutex = PTHREAD_MUTEX_INITIALIZER;
20 std::map<string, FactBatchManager *> * BatchManagerCatalog::_p_catalog = 0;
23 BatchManagerCatalog::BatchManagerCatalog()
29 BatchManagerCatalog::~BatchManagerCatalog()
35 FactBatchManager * BatchManagerCatalog::getFactBatchManager(const char * type)
37 return (* BatchManagerCatalog::_p_catalog)[type];
40 void BatchManagerCatalog::addFactBatchManager(const char * type, FactBatchManager * pFBM)
42 if (pFBM) { // *** section critique ***
43 pthread_mutex_lock(&_mutex);
45 if (! BatchManagerCatalog::_p_catalog) BatchManagerCatalog::_p_catalog = new std::map<string, FactBatchManager *>;
46 (*BatchManagerCatalog::_p_catalog)[type] = pFBM;
48 pthread_mutex_unlock(&_mutex);
52 FactBatchManager * BatchManagerCatalog::operator() (const char * type) const
54 return BatchManagerCatalog::getFactBatchManager(type);
57 std::map<string, FactBatchManager *> * BatchManagerCatalog::dict() const
62 string BatchManagerCatalog::__repr__() const
65 oss << "<BatchManagerCatalog contains {";
67 for(std::map<string, FactBatchManager *>::const_iterator it = (*_p_catalog).begin(); it != (*_p_catalog).end(); it++, sep=", ") {
68 oss << sep << "'" << (*it).first << "' : '" << (*it).second->__repr__() << "'";