-
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-
- SALOMEDS::GenericAttribute_var aFindAttr;
- bool hasAttr = aSObj->FindAttribute(aFindAttr, "AttributeString");
- if(VARIABLE_DEBUG)
- cout<<"Find Attribute "<<hasAttr<<endl;
-
- SALOMEDS::GenericAttribute_var anAttr;
- anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
- SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
-
- TCollection_AsciiString aNewParams;
- TCollection_AsciiString aOldParameters(aStringAttr->Value());
- TCollection_AsciiString anInputParams(ParseParameters(theParameters));
-
- if(!hasAttr)
- aNewParams = anInputParams;
- else
- aNewParams = aOldParameters+"|"+anInputParams;
+ CORBA::String_var anObjEntry = aSObj->GetID();
+ myLastObj = anObjEntry.in();
+
+ // get a string of variable names
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_wrap anAttr =
+ aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString" );
+ SALOMEDS::AttributeString_wrap aStringAttr = anAttr;
+ CORBA::String_var oldVars = aStringAttr->Value();
+ std::string varStr = oldVars.in();
+
+ // add new variables and find indices of variables
+ for ( size_t i = 0; i < myLastParameters.size(); ++i )
+ {
+ int varIndex = -1;
+ if ( !myLastParameters[i].empty() )
+ {
+ // find index of myLastParameters[i] in varStr
+ int curIndex = 0;
+ bool varFound = false;
+ size_t pos = 0;
+ // varStr can be "A|B::C;*=2|D"
+ const std::string separators(":|;*=");
+ while ( pos < varStr.size() && !varFound )
+ {
+ // skip separators
+ while ( separators.find( varStr[ pos ]) != std::string::npos )
+ if ( ++pos >= varStr.size() )
+ break;
+ // skip repetition number following '='
+ if ( varStr[ pos-1 ] == '=' )
+ {
+ while ( '0' <= varStr[ pos ] && varStr[ pos ] <= '9' )
+ ++pos;
+ continue; // to skip next separator
+ }
+ // compare variable name
+ if ( pos < varStr.size() )
+ {
+ varFound = ( varStr.compare( pos, myLastParameters[i].size(), myLastParameters[i] ) == 0 &&
+ // same string beginning but is length same?
+ ( pos + myLastParameters[i].size() >= varStr.size() ||
+ separators.find( varStr[ pos+1 ]) != std::string::npos ));
+ if ( varFound )
+ varIndex = curIndex;
+ else
+ pos = varStr.find_first_of( separators, pos ); // goto the next separator
+ ++curIndex;
+ }
+ }
+ // add new variable
+ if ( !varFound )
+ {
+ varStr += ":" + myLastParameters[i];
+ varIndex = curIndex;
+ }
+ }
+ myLastParamIndex.push_back( varIndex );
+ }
+ aStringAttr->SetValue( varStr.c_str() );
+}
+
+//================================================================================
+/*!
+ * \brief Return all variables used to create an object
+ * \param [in] theObjectEntry - an object entry in the current study
+ * \return std::vector< std::string > - all variable names (or values of removed variables)
+ */
+//================================================================================