boolean IsVariable( in string theVarName );
ListOfStrings GetVariableNames();
+
+/*! \brief Removing variable
+
+ Remove variable with the specified name from the study with substitution of its value.
+
+ \param theVarName Name of the variable.
+ \return Status of operation.
+*/
+ boolean RemoveVariable( in string theVarName );
+
+/*! \brief Renaming variable
+
+ Rename variable with the specified name within the study.
+
+ \param theVarName Name of the variable.
+ \param theNewVarName New name for the variable.
+ \return Status of operation.
+*/
+ boolean RenameVariable( in string theVarName, in string theNewVarName );
+
+/*! \brief Checking variable usage
+
+ Check that variable is used in the study.
+
+ \param theVarName Name of the variable.
+ \return Variable usage.
+*/
+ boolean IsVariableUsed( in string theVarName );
};
//==========================================================================
return aVector;
}
+bool SALOMEDS_Study::RemoveVariable(const string& theVarName)
+{
+ bool aResult;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ aResult = _local_impl->RemoveVariable(theVarName);
+ }
+ else
+ aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str());
+ return aResult;
+}
+
+bool SALOMEDS_Study::RenameVariable(const string& theVarName, const string& theNewVarName)
+{
+ bool aResult;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ aResult = _local_impl->RenameVariable(theVarName, theNewVarName);
+ }
+ else
+ aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str());
+ return aResult;
+}
+
+bool SALOMEDS_Study::IsVariableUsed(const string& theVarName)
+{
+ bool aResult;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ aResult = _local_impl->IsVariableUsed(theVarName);
+ }
+ else
+ aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str());
+ return aResult;
+}
+
std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
{
return _orb->object_to_string(theObject);
virtual bool IsVariable(const std::string& theVarName);
virtual std::vector<std::string> GetVariableNames();
+ 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);
+
std::string ConvertObjectToIOR(CORBA::Object_ptr theObject);
CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR);
return aResult._retn();
}
+//============================================================================
+/*! Function : RemoveVariable
+ * Purpose :
+ */
+//============================================================================
+CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
+{
+ return _impl->RemoveVariable(string(theVarName));
+}
+
+//============================================================================
+/*! Function : RenameVariable
+ * Purpose :
+ */
+//============================================================================
+CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
+{
+ return _impl->RenameVariable(string(theVarName), string(theNewVarName));
+}
+
+//============================================================================
+/*! Function : IsVariableUsed
+ * Purpose :
+ */
+//============================================================================
+CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
+{
+ return _impl->IsVariableUsed(string(theVarName));
+}
+
//============================================================================
/*! Function : GetDefaultScript
* Purpose :
virtual SALOMEDS::ListOfStrings* GetVariableNames();
+ virtual CORBA::Boolean RemoveVariable(const char* theVarName);
+
+ virtual CORBA::Boolean RenameVariable(const char* theVarName, const char* theNewVarName);
+
+ virtual CORBA::Boolean IsVariableUsed(const char* theVarName);
+
virtual char* GetDefaultScript(const char* theModuleName, const char* theShift);
virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished);
virtual bool IsVariable(const std::string& theVarName) = 0;
virtual std::vector<std::string> GetVariableNames() = 0;
+ virtual bool RemoveVariable(const std::string& theVarName) = 0;
+ virtual bool RenameVariable(const std::string& theVarName,
+ const std::string& theNewVarName) = 0;
+ virtual bool IsVariableUsed(const std::string& theVarName) = 0;
+
};
_type = theType;
}
+//============================================================================
+/*! Function : setName
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDSImpl_GenericVariable::setName(const std::string& theName)
+{
+ _name = theName;
+}
+
//============================================================================
/*! Function : CheckLocked
* Purpose :
void setType(const VariableTypes theType);
+ void setName(const std::string& theName);
+
virtual void CheckLocked();
virtual void SetModifyFlag();
if(aGVar != NULL )
if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast<SALOMEDSImpl_ScalarVariable*>(aGVar))
return aSVar->getValue();
+
+ return 0;
}
//============================================================================
return aResult;
}
+//============================================================================
+/*! Function : RemoveVariable
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::RemoveVariable(const string& theVarName)
+{
+ SALOMEDSImpl_GenericVariable* aVariable = GetVariable( theVarName );
+ if( !aVariable )
+ return false;
+
+ string aValue = aVariable->SaveToScript();
+ ReplaceVariableAttribute( theVarName, aValue );
+
+ std::vector<SALOMEDSImpl_GenericVariable*>::iterator it = myNoteBookVars.begin(), itEnd = myNoteBookVars.end();
+ for( ; it != itEnd; it++ )
+ {
+ SALOMEDSImpl_GenericVariable* aVariableRef = *it;
+ if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 )
+ {
+ myNoteBookVars.erase( it );
+ break;
+ }
+ }
+
+ return true;
+}
+
+//============================================================================
+/*! Function : RenameVariable
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::RenameVariable(const string& theVarName, const string& theNewVarName)
+{
+ SALOMEDSImpl_GenericVariable* aVariable = GetVariable( theVarName );
+ if( !aVariable )
+ return false;
+
+ ReplaceVariableAttribute( theVarName, theNewVarName );
+
+ std::vector<SALOMEDSImpl_GenericVariable*>::iterator it = myNoteBookVars.begin(), itEnd = myNoteBookVars.end();
+ for( ; it != itEnd; it++ )
+ {
+ SALOMEDSImpl_GenericVariable* aVariableRef = *it;
+ if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 )
+ {
+ aVariableRef->setName( theNewVarName );
+ break;
+ }
+ }
+
+ return true;
+}
+
+//============================================================================
+/*! Function : IsVariableUsed
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::IsVariableUsed(const string& theVarName)
+{
+ return FindVariableAttribute( theVarName );
+}
+
+//============================================================================
+/*! Function : FindVariableAttribute
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::FindVariableAttribute(const std::string& theName)
+{
+ DF_Attribute* anAttr;
+ SALOMEDSImpl_StudyBuilder* aStudyBuilder = NewBuilder();
+ SALOMEDSImpl_SComponentIterator aCompIter = NewComponentIterator();
+ for( ; aCompIter.More(); aCompIter.Next() )
+ {
+ SALOMEDSImpl_SObject aComp = aCompIter.Value();
+
+ SALOMEDSImpl_ChildIterator anIter = NewChildIterator( aComp );
+ for( ; anIter.More(); anIter.Next() )
+ {
+ SALOMEDSImpl_SObject aSObject = anIter.Value();
+ if( aStudyBuilder->FindAttribute( aSObject, anAttr, "AttributeString" ) )
+ {
+ if( SALOMEDSImpl_AttributeString* aStringAttr = ( SALOMEDSImpl_AttributeString* )anAttr )
+ {
+ string aString = aStringAttr->Value();
+
+ vector<string> aVector = SALOMEDSImpl_Tool::splitString( aString, ':' );
+ for( int i = 0, len = aVector.size(); i < len; i++ )
+ {
+ string aStr = aVector[i];
+ if( aStr.compare( theName ) == 0 )
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
+//============================================================================
+/*! Function : ReplaceVariableAttribute
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDSImpl_Study::ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest)
+{
+ DF_Attribute* anAttr;
+ SALOMEDSImpl_StudyBuilder* aStudyBuilder = NewBuilder();
+ SALOMEDSImpl_SComponentIterator aCompIter = NewComponentIterator();
+ for( ; aCompIter.More(); aCompIter.Next() )
+ {
+ SALOMEDSImpl_SObject aComp = aCompIter.Value();
+
+ SALOMEDSImpl_ChildIterator anIter = NewChildIterator( aComp );
+ for( ; anIter.More(); anIter.Next() )
+ {
+ SALOMEDSImpl_SObject aSObject = anIter.Value();
+ if( aStudyBuilder->FindAttribute( aSObject, anAttr, "AttributeString" ) )
+ {
+ if( SALOMEDSImpl_AttributeString* aStringAttr = ( SALOMEDSImpl_AttributeString* )anAttr )
+ {
+ bool isChanged = false;
+ string aNewString, aCurrentString = aStringAttr->Value();
+
+ vector<string> aVector = SALOMEDSImpl_Tool::splitString( aCurrentString, ':' );
+ for( int i = 0, len = aVector.size(); i < len; i++ )
+ {
+ string aStr = aVector[i];
+ if( aStr.compare( theSource ) == 0 )
+ {
+ isChanged = true;
+ aStr = theDest;
+ }
+
+ aNewString.append( aStr );
+ if( i != len )
+ aNewString.append( ":" );
+ }
+
+ if( isChanged )
+ aStringAttr->SetValue( aNewString );
+ }
+ }
+ }
+ }
+}
+
//============================================================================
/*! Function : EnableUseCaseAutoFilling
* Purpose :
SALOMEDSImpl_GenericVariable* GetVariable(const std::string& theName) const;
+ bool RemoveVariable(const std::string& theVarName);
+
+ bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName);
+
+ bool IsVariableUsed(const std::string& theVarName);
+
+ bool FindVariableAttribute(const std::string& theName);
+ void ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest);
+
//Returns a callback
SALOMEDSImpl_Callback* GetCallback() { return _cb; }