From b7580718472d885a7f66f9cdf8980e0bdc617df8 Mon Sep 17 00:00:00 2001 From: barate Date: Wed, 20 Apr 2011 15:35:28 +0000 Subject: [PATCH] Added method to test the presence of a BatchManager Factory --- src/Core/Batch_BatchManagerCatalog.cxx | 11 ++++++++++- src/Core/Batch_BatchManagerCatalog.hxx | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Core/Batch_BatchManagerCatalog.cxx b/src/Core/Batch_BatchManagerCatalog.cxx index c5fc992..3d6fc43 100644 --- a/src/Core/Batch_BatchManagerCatalog.cxx +++ b/src/Core/Batch_BatchManagerCatalog.cxx @@ -70,11 +70,20 @@ namespace Batch { } } + bool BatchManagerCatalog::hasFactBatchManager(const char * type) + { + pthread_mutex_lock(&_mutex); + bool result = (_catalog.find(type) != _catalog.end()); + pthread_mutex_unlock(&_mutex); + return result; + } + // Functor FactBatchManager * BatchManagerCatalog::operator() (const char * type) { + FactBatchManager * result = NULL; pthread_mutex_lock(&_mutex); - FactBatchManager * result = _catalog[type]; + if (_catalog.find(type) != _catalog.end()) result = _catalog[type]; pthread_mutex_unlock(&_mutex); return result; } diff --git a/src/Core/Batch_BatchManagerCatalog.hxx b/src/Core/Batch_BatchManagerCatalog.hxx index 7286c59..295ea27 100644 --- a/src/Core/Batch_BatchManagerCatalog.hxx +++ b/src/Core/Batch_BatchManagerCatalog.hxx @@ -48,6 +48,7 @@ namespace Batch { static BatchManagerCatalog& getInstance(); void addFactBatchManager(const char * type, Batch::FactBatchManager * pFBM); + bool hasFactBatchManager(const char * type); Batch::FactBatchManager * operator() (const char * type); virtual std::map * dict(); -- 2.39.2