1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 * BatchManagerCatalog.cxx :
23 * Auteur : Ivan DUTKA-MALEN - EDF R&D
24 * Date : Septembre 2004
32 #include "Batch_BatchManagerCatalog.hxx"
33 #include "Batch_FactBatchManager.hxx"
38 pthread_mutex_t BatchManagerCatalog::_mutex = PTHREAD_MUTEX_INITIALIZER;
39 std::map<string, FactBatchManager *> * BatchManagerCatalog::_p_catalog = 0;
40 BatchManagerCatalog BatchManagerCatalog::theCatalog;
43 BatchManagerCatalog::BatchManagerCatalog()
49 BatchManagerCatalog::~BatchManagerCatalog()
51 delete BatchManagerCatalog::_p_catalog;
55 FactBatchManager * BatchManagerCatalog::getFactBatchManager(const char * type)
57 return (* BatchManagerCatalog::_p_catalog)[type];
60 void BatchManagerCatalog::addFactBatchManager(const char * type, FactBatchManager * pFBM)
62 if (pFBM) { // *** section critique ***
63 pthread_mutex_lock(&_mutex);
65 if (! BatchManagerCatalog::_p_catalog) BatchManagerCatalog::_p_catalog = new std::map<string, FactBatchManager *>;
66 (*BatchManagerCatalog::_p_catalog)[type] = pFBM;
68 pthread_mutex_unlock(&_mutex);
72 FactBatchManager * BatchManagerCatalog::operator() (const char * type) const
74 return BatchManagerCatalog::getFactBatchManager(type);
77 std::map<string, FactBatchManager *> * BatchManagerCatalog::dict() const
82 string BatchManagerCatalog::__repr__() const
85 oss << "<BatchManagerCatalog contains {";
87 for(std::map<string, FactBatchManager *>::const_iterator it = (*_p_catalog).begin(); it != (*_p_catalog).end(); it++, sep=", ") {
88 oss << sep << "'" << (*it).first << "' : '" << (*it).second->__repr__() << "'";