From: srn Date: Mon, 13 Feb 2006 09:35:23 +0000 (+0000) Subject: Modified methods encodeEntry and decodeEntry X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f9d696c8967ff884b0ec40a41a9c615a05049b05;p=modules%2Fkernel.git Modified methods encodeEntry and decodeEntry --- diff --git a/src/SALOMEDS/SALOMEDS_IParameters.cxx b/src/SALOMEDS/SALOMEDS_IParameters.cxx index 5fbe653b3..278adfb3b 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.cxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.cxx @@ -41,9 +41,16 @@ using namespace std; */ SALOMEDS_IParameters::SALOMEDS_IParameters(const _PTR(AttributeParameter)& ap) { + if(!ap) return; _ap = ap; + _PTR(SObject) so = _ap->GetSObject(); + _study = so->GetStudy(); } +SALOMEDS_IParameters::~SALOMEDS_IParameters() +{ + _compNames.clear(); +} int SALOMEDS_IParameters::append(const string& listName, const string& value) { @@ -224,14 +231,34 @@ bool SALOMEDS_IParameters::isDumpPython() return (bool)_ap->GetBool(_AP_DUMP_PYTHON_); } -string encodeEntry(const string& entry, const string& compName) +string SALOMEDS_IParameters::encodeEntry(const string& entry, const string& compName) { - return entry; + string tail(entry, 6, entry.length()-1); + string newEntry(compName); + newEntry+=("_"+tail); + return newEntry; } -string decodeEntry(const string& entry) +string SALOMEDS_IParameters::decodeEntry(const string& entry) { - return entry; + if(!_study) return entry; + int pos = entry.rfind("_"); + if(pos < 0 || pos >= entry.length()) return entry; + + string compName(entry, 0, pos), compID, tail(entry, pos+1, entry.length()-1); + + if(_compNames.find(compName) == _compNames.end()) { + _PTR(SObject) so = _study->FindComponent(compName); + if(!so) return entry; + compID = so->GetID(); + _compNames[compName] = compID; + } + else compID = _compNames[compName]; + + string newEntry(compID); + newEntry += (":"+tail); + + return newEntry; } diff --git a/src/SALOMEDS/SALOMEDS_IParameters.hxx b/src/SALOMEDS/SALOMEDS_IParameters.hxx index 42e74cc64..bbb8c4ec1 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.hxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.hxx @@ -21,6 +21,7 @@ #include #include +#include #include "SALOMEDSClient.hxx" @@ -32,6 +33,8 @@ class SALOMEDS_IParameters public: SALOMEDS_IParameters(const _PTR(AttributeParameter)& ap); + virtual ~SALOMEDS_IParameters(); + /*! Appends a string value to a named list. Returns a number of the added value. @@ -152,7 +155,8 @@ public: private: _PTR(AttributeParameter) _ap; - + _PTR(Study) _study; + std::map _compNames; };