From: rnv Date: Mon, 17 Nov 2008 15:36:04 +0000 (+0000) Subject: ParseVariables() method added in the Study. X-Git-Tag: TG_DumpPython_Extension_3~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=be8973cc4c45ba4032c2411ede72fb617c2eb88d;p=modules%2Fkernel.git ParseVariables() method added in the Study. --- diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 32eb2463e..a52fbbda1 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -504,6 +504,14 @@ during each working session. \return Variable usage. */ boolean IsVariableUsed( in string theVarName ); + +/*! \brief Parse variables used for object creation + + \param string with variables, separated by special symbol. + \return Variables list. +*/ + ListOfStrings ParseVariables( in string theVars ); + }; //========================================================================== diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index fce5d225a..044722d2f 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -856,6 +856,22 @@ bool SALOMEDS_Study::IsVariableUsed(const string& theVarName) return aResult; } +vector SALOMEDS_Study::ParseVariables(const string& theVars) +{ + vector aResult; + if (_isLocal) { + SALOMEDS::Locker lock; + aResult = _local_impl->ParseVariables(theVars); + } + else { + SALOMEDS::ListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str()); + int aLength = aSeq->length(); + for (int i = 0; i < aLength; i++) + aResult.push_back( string(aSeq[i].in()) ); + } + return aResult; +} + std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject) { return _orb->object_to_string(theObject); diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index 3c885b64b..6c5a5ba9c 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -114,6 +114,7 @@ public: virtual bool RemoveVariable(const std::string& theVarName); virtual bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName); virtual bool IsVariableUsed(const std::string& theVarName); + virtual std::vector ParseVariables(const std::string& theVars); std::string ConvertObjectToIOR(CORBA::Object_ptr theObject); CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 22abc8a03..e8e908809 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -1001,6 +1001,26 @@ CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName) return _impl->IsVariableUsed(string(theVarName)); } + +//============================================================================ +/*! Function : ParseVariables + * Purpose : + */ +//============================================================================ +SALOMEDS::ListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName) +{ + vector aVarNames = _impl->ParseVariables(string(theVarName)); + SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; + + int aLen = aVarNames.size(); + aResult->length(aLen); + + for (int anInd = 0; anInd < aLen; anInd++) + aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str()); + + return aResult._retn(); +} + //============================================================================ /*! Function : GetDefaultScript * Purpose : diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 8466582ee..6ee2028d7 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -321,6 +321,8 @@ public: virtual CORBA::Boolean RenameVariable(const char* theVarName, const char* theNewVarName); virtual CORBA::Boolean IsVariableUsed(const char* theVarName); + + virtual SALOMEDS::ListOfStrings* ParseVariables(const char* theVars); virtual char* GetDefaultScript(const char* theModuleName, const char* theShift); diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index 2cb48ed4b..338b8f17c 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -111,6 +111,8 @@ public: virtual bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName) = 0; virtual bool IsVariableUsed(const std::string& theVarName) = 0; + + virtual std::vector ParseVariables(const std::string& theVars) = 0; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index ffedb4437..dca7d19da 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -1834,6 +1834,16 @@ void SALOMEDSImpl_Study::ReplaceVariableAttribute(const std::string& theSource, } } +//============================================================================ +/*! Function : EnableUseCaseAutoFilling + * Purpose : + */ +//============================================================================ +vector SALOMEDSImpl_Study::ParseVariables(const string& theVariables) const +{ + return SALOMEDSImpl_Tool::splitStringWithEmpty( theVariables, VARIABLE_SEPARATOR ); +} + //============================================================================ /*! Function : EnableUseCaseAutoFilling * Purpose : diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index 64ddce482..32f465bc8 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -293,6 +293,8 @@ public: const std::string& theDest); void ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest); + std::vector ParseVariables(const std::string& theVariables) const; + //Returns a callback SALOMEDSImpl_Callback* GetCallback() { return _cb; }