#define _AP_PROPERTIES_LIST_ "AP_PROPERTIES_LIST"
#define _AP_DUMP_PYTHON_ "AP_DUMP_PYTHON"
+#define _PT_ID_ "_PT_OBJECT_ID_"
+
+
/*!
Constructor
*/
return names;
}
+
+std::string SALOMEDS_IParameters::getIdParameter(const std::string& entry)
+{
+ if(!_ap) return "";
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return "";
+ std::vector<std::string> v = _ap->GetStrArray(entry);
+ int length = v.size();
+ for(int i = 0; i<length; i+=1) {
+ if(v[i] == _PT_ID_) return v[i+1];
+ }
+ return "";
+}
+
+void SALOMEDS_IParameters::setIdParameter(const std::string& entry, const std::string& value)
+{
+ if(!_ap) return;
+ std::vector<std::string> v;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) {
+ append(_AP_ENTRIES_LIST_, entry); //Add the entry to the internal list of entries
+ _ap->SetStrArray(entry, v);
+ }
+ v = _ap->GetStrArray(entry);
+ v.push_back(_PT_ID_);
+ v.push_back(value);
+ _ap->SetStrArray(entry, v);
+}
+
std::vector<std::string> SALOMEDS_IParameters::getAllParameterValues(const std::string& entry)
{
std::vector<std::string> v, values;
*/
virtual std::string getParameter(const std::string& entry, const std::string& parameterName);
+ /*!
+ Sets an id parameter value for the given entry.
+ */
+ virtual void setIdParameter(const std::string& entry, const std::string& value);
+
+ /*!
+ Gets an id parameter value for the given entry
+ */
+ virtual std::string getIdParameter(const std::string& entry);
+
/*!
Returns all parameter names of the given entry
*/
*/
virtual std::string getParameter(const std::string& entry, const std::string& parameterName) = 0;
+ /*!
+ Sets an id parameter value for the given entry.
+ */
+ virtual void setIdParameter(const std::string& entry, const std::string& value) = 0;
+
+ /*!
+ Gets an id parameter value for the given entry
+ */
+ virtual std::string getIdParameter(const std::string& entry) = 0;
+
/*!
Returns all parameter names of the given entry
*/
#define _AP_PROPERTIES_LIST_ "AP_PROPERTIES_LIST"
#define _AP_DUMP_PYTHON_ "AP_DUMP_PYTHON"
+#define _PT_ID_ "_PT_OBJECT_ID_"
+
/*!
Constructor
*/
}
+void SALOMEDSImpl_IParameters::setIdParameter(const std::string& entry, const std::string& value)
+{
+ if(!_ap) return;
+ std::vector<std::string> v;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) {
+ append(_AP_ENTRIES_LIST_, entry); //Add the entry to the internal list of entries
+ _ap->SetStrArray(entry, v);
+ }
+ v = _ap->GetStrArray(entry);
+ v.push_back(_PT_ID_);
+ v.push_back(value);
+ _ap->SetStrArray(entry, v);
+}
+
+
+std::string SALOMEDSImpl_IParameters::getIdParameter(const std::string& entry)
+{
+ if(!_ap) return "";
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return "";
+ std::vector<std::string> v = _ap->GetStrArray(entry);
+ int length = v.size();
+ for(int i = 0; i<length; i+=1) {
+ if(v[i] == _PT_ID_) return v[i+1];
+ }
+ return "";
+}
+
std::vector<std::string> SALOMEDSImpl_IParameters::getAllParameterNames(const std::string& entry)
{
std::vector<std::string> v, names;
SALOMEDSImpl_SObject so = study->FindObjectID(decodedEntry);
std::string so_name("");
if(so) so_name = so.GetName();
- dump += shift + "# set up entry " + v[i] +" ("+so_name+")" + " parameters" + "\n";
- for(int j = 0; j < names.size() && j < values.size(); j++)
- dump += shift + "ipar.setParameter(\"" + v[i] + "\", \"" + names[j] + "\", \"" + values[j] + "\")\n";
+
+ //Try to find id parameter
+ std::vector<std::string>::iterator it = std::find(names.begin(), names.end(), _PT_ID_ );
+ bool hasId = it != names.end();
+ bool onlyId = hasId && names.size() == 1;
+
+ if(!onlyId) {
+ dump += shift + "# set up entry " + v[i] +" ("+so_name+")" + " parameters" + "\n";
+ if(hasId) {
+ int idIndex = std::distance(names.begin(), it);
+ dump += shift + "objId = " + values[idIndex] + "\n";
+ }
+
+ for(int j = 0; j < names.size() && j < values.size(); j++) {
+ if(names[j] == _PT_ID_) continue;
+ if(hasId)
+ dump += shift + "ipar.setParameter(" + "objId" + ", \"" + names[j] + "\", \"" + values[j] + "\")\n";
+ else
+ dump += shift + "ipar.setParameter(\"" + v[i] + "\", \"" + names[j] + "\", \"" + values[j] + "\")\n";
+ }
+ }
}
}
*/
virtual std::string getParameter(const std::string& entry, const std::string& parameterName);
+ /*!
+ Sets an id parameter value for the given entry.
+ */
+ virtual void setIdParameter(const std::string& entry, const std::string& value);
+
+ /*!
+ Gets an id parameter value for the given entry
+ */
+ virtual std::string getIdParameter(const std::string& entry);
+
/*!
Returns all parameter names of the given entry
*/
//============================================================================
SALOMEDSImpl_AttributeParameter* SALOMEDSImpl_Study::GetCommonParameters(const char* theID, int theSavePoint)
{
- if (theSavePoint < 0) return NULL;
+ if (theSavePoint < -1) return NULL;
SALOMEDSImpl_StudyBuilder* builder = NewBuilder();
SALOMEDSImpl_SObject so = FindComponent((char*)theID);
if (!so) so = builder->NewComponent((char*)theID);
SALOMEDSImpl_AttributeParameter* attParam = NULL;
+ if (theSavePoint == -1) {
+ int ctag = 1;
+ DF_Label savePointLabel = so.GetLabel().FindChild( ctag, /*create=*/0 );
+ DF_Label prevPointLabel;
+ while ( !savePointLabel.IsNull() ) {
+ ctag++;
+ prevPointLabel = savePointLabel;
+ savePointLabel = so.GetLabel().FindChild( ctag, /*create=*/0 );
+ }
+ if ( !prevPointLabel.IsNull() )
+ so = GetSObject( prevPointLabel );
+ }
if (theSavePoint > 0) { // Try to find SObject that contains attribute parameter ...
DF_Label savePointLabel = so.GetLabel().FindChild( theSavePoint, /*create=*/0 );
if ( !savePointLabel.IsNull() )
const char* theModuleName,
int theSavePoint)
{
- if(theSavePoint <= 0) return NULL;
+ if(theSavePoint < -1) return NULL;
SALOMEDSImpl_AttributeParameter* main_ap = GetCommonParameters(theID, theSavePoint);
SALOMEDSImpl_SObject main_so = main_ap->GetSObject();
SALOMEDSImpl_AttributeParameter* par = NULL;