From f0050122eb322926c02381762d2d0c3999f3867d Mon Sep 17 00:00:00 2001 From: ribes Date: Thu, 21 Jan 2010 17:02:39 +0000 Subject: [PATCH] Adding RemoveResource --- idl/SALOME_ContainerManager.idl | 9 +++++++++ src/ResourcesManager/ResourcesManager.cxx | 6 +++++- src/ResourcesManager/SALOME_ResourcesManager.cxx | 13 +++++++++++++ src/ResourcesManager/SALOME_ResourcesManager.hxx | 4 ++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 917323813..f58603628 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -250,6 +250,15 @@ interface ResourcesManager */ void AddResource(in ResourceDefinition new_resource, in boolean write, in string xml_file) raises (SALOME::SALOME_Exception); + + //! Remove a new resource to the resource_manager + /*! + write -> true, resource manager will write a new xml_file + xml_file -> could be empty, in this case if write is true, resource manager will write + the resource in its first ResourceCatalog file + */ + void RemoveResource(in string resource_name, in boolean write, in string xml_file) + raises (SALOME::SALOME_Exception); }; diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 6a100a4c6..51669d669 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -277,7 +277,11 @@ ResourcesManager_cpp::AddResourceInCatalog(const ParserResourcesType & new_resou void ResourcesManager_cpp::DeleteResourceInCatalog(const char * name) { - _resourcesList.erase(name); + MapOfParserResourcesType_it it = _resourcesList.find(name); + if (it != _resourcesList.end()) + _resourcesList.erase(name); + else + RES_INFOS("You try to delete a resource that does not exist... : " << name); } //============================================================================= diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index d39882b96..8d6027142 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -369,6 +369,19 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso } } +void +SALOME_ResourcesManager::RemoveResource(const char * resource_name, + CORBA::Boolean write, + const char * xml_file) +{ + _rm.DeleteResourceInCatalog(resource_name); + if (write) + { + _rm.WriteInXmlFile(std::string(xml_file)); + _rm.ParseXmlFiles(); + } +} + std::string SALOME_ResourcesManager::getMachineFile(std::string hostname, CORBA::Long nb_procs, diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index 7573cdfb1..80927c207 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -72,6 +72,10 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager: CORBA::Boolean write, const char * xml_file); + void RemoveResource(const char * resource_name, + CORBA::Boolean write, + const char * xml_file); + // Cpp Methods void Shutdown(); ResourcesManager_cpp *GetImpl() { return &_rm; } -- 2.39.2