* Purpose :
*/
//============================================================================
-void SALOMEDSImpl_GenericVariable::setType(const SALOMEDSImpl_GenericVariable::VariableTypes theType)
+bool SALOMEDSImpl_GenericVariable::setType(const SALOMEDSImpl_GenericVariable::VariableTypes theType)
{
+ if(_type == theType)
+ return false;
+
_type = theType;
+ return true;
}
//============================================================================
* Purpose :
*/
//============================================================================
-void SALOMEDSImpl_GenericVariable::setName(const std::string& theName)
+bool SALOMEDSImpl_GenericVariable::setName(const std::string& theName)
{
- _name = theName;
-}
+ if(_name.compare(theName) == 0)
+ return false;
-//============================================================================
-/*! Function : CheckLocked
- * Purpose :
- */
-//============================================================================
-void SALOMEDSImpl_GenericVariable::CheckLocked()
-{
- DF_Label aLabel = DF_Label();
- if(aLabel.IsNull()) return;
-
- SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(aLabel);
- if(!aStudy) return;
- if(aStudy->IsLocked()) {
- aStudy->_errorCode = "LockProtection";
- throw LockProtection("LockProtection");
- }
-}
-
-//============================================================================
-/*! Function : SetModifyFlag
- * Purpose :
- */
-//============================================================================
-void SALOMEDSImpl_GenericVariable::SetModifyFlag()
-{
- DF_Label aLabel = DF_Label();
- if(aLabel.IsNull()) return;
-
- SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(aLabel);
- if(aStudy) aStudy->Modify();
+ _name = theName;
+ return true;
}
-
//============================================================================
/*! Function : String2VariableType
* Purpose :
static VariableTypes String2VariableType(const std::string& theStrType);
- void setType(const VariableTypes theType);
+ bool setType(const VariableTypes theType);
- void setName(const std::string& theName);
-
- virtual void CheckLocked();
-
- virtual void SetModifyFlag();
+ bool setName(const std::string& theName);
virtual std::string Save() const;
virtual std::string SaveToScript() const;
const double theValue,
const SALOMEDSImpl_GenericVariable::VariableTypes theType)
{
-
+ bool modified = false;
SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName);
if( aGVar == NULL ) {
aSVar->setValue(theValue);
myNoteBookVars.push_back(aSVar);
+ modified = true;
}
else {
if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast<SALOMEDSImpl_ScalarVariable*>(aGVar)) {
- aSVar->setValue(theValue);
- if(aSVar->Type() != theType)
- aSVar->setType(theType);
+ modified = aSVar->setValue(theValue) || modified;
+ modified = aSVar->setType(theType) || modified;
}
}
+ if(modified)
+ Modify();
}
//============================================================================
if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 )
{
myNoteBookVars.erase( it );
+ Modify();
break;
}
}
if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 )
{
aVariableRef->setName( theNewVarName );
+ Modify();
break;
}
}