Back to index

salome-kernel  6.5.0
Public Member Functions | Private Member Functions | Private Attributes
SALOMEDS_IParameters Class Reference

Class which an interface to store the parameters of the objects. More...

#include <SALOMEDS_IParameters.hxx>

Inheritance diagram for SALOMEDS_IParameters:
Inheritance graph
[legend]
Collaboration diagram for SALOMEDS_IParameters:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SALOMEDS_IParameters (const _PTR(AttributeParameter)&ap)
 Constructor.
virtual ~SALOMEDS_IParameters ()
virtual int append (const std::string &listName, const std::string &value)
 Appends a string value to a named list.
virtual int nbValues (const std::string &listName)
 Returns a number elements in the list.
virtual std::vector< std::string > getValues (const std::string &listName)
 Returns a list of values in the list.
virtual std::string getValue (const std::string &listName, int index)
 Returns a value with given index, where index is in range [0:nbValues-1].
virtual std::vector< std::string > getLists ()
 Returns a list all entries lists.
virtual void setParameter (const std::string &entry, const std::string &parameterName, const std::string &value)
 Sets a new named parameter value for the given entry.
virtual std::string getParameter (const std::string &entry, const std::string &parameterName)
 Gets a named parameter value for the given entry.
virtual void setIdParameter (const std::string &entry, const std::string &value)
 Sets an id parameter value for the given entry.
virtual std::string getIdParameter (const std::string &entry)
 Gets an id parameter value for the given entry.
virtual std::vector< std::string > getAllParameterNames (const std::string &entry)
 Returns all parameter names of the given entry.
virtual std::vector< std::string > getAllParameterValues (const std::string &entry)
 Returns all parameter values of the given entry.
virtual int getNbParameters (const std::string &entry)
 Returns a number of parameters of the given entry.
virtual std::vector< std::string > getEntries ()
 Returns a list all entries.
virtual void setProperty (const std::string &name, const std::string &value)
 Sets a global named property value.
virtual std::string getProperty (const std::string &name)
 Gets a value of global named property.
virtual std::vector< std::string > getProperties ()
 Returns a list all properties.
virtual std::vector< std::string > parseValue (const std::string &value, const char separator, bool fromEnd=true)
 Breaks a value string in two parts which is divided by separator.
virtual std::string encodeEntry (const std::string &entry, const std::string &compName)
 Returns encoded entry that is a relative entry for the component.
virtual std::string decodeEntry (const std::string &entry)
 Returns decoded entry that is an absolute entry.
virtual void setDumpPython (_PTR(Study) study, const std::string &theID="")
 Enables/Disables the dumping visual parameters.
virtual bool isDumpPython (_PTR(Study) study, const std::string &theID="")
 Returns whether there is the dumping visual parameters.
virtual std::string getDefaultVisualComponent ()
 Returns a default name of the component where the visula parameters are stored.

Private Member Functions

 _PTR (AttributeParameter) _ap
 _PTR (Study) _study

Private Attributes

std::map< std::string,
std::string > 
_compNames

Detailed Description

Class which an interface to store the parameters of the objects.

Definition at line 36 of file SALOMEDS_IParameters.hxx.


Constructor & Destructor Documentation

SALOMEDS_IParameters::SALOMEDS_IParameters ( const _PTR(AttributeParameter)&  ap)

Constructor.

Definition at line 45 of file SALOMEDS_IParameters.cxx.

{
  if(!ap) return;
  _ap = ap;
  _PTR(SObject) so = _ap->GetSObject();
  _study = so->GetStudy();
}

Here is the call graph for this function:

Definition at line 53 of file SALOMEDS_IParameters.cxx.

{
  _compNames.clear();
}

Member Function Documentation

SALOMEDS_IParameters::_PTR ( AttributeParameter  ) [private]

Here is the caller graph for this function:

SALOMEDS_IParameters::_PTR ( Study  ) [private]
int SALOMEDS_IParameters::append ( const std::string &  listName,
const std::string &  value 
) [virtual]

Appends a string value to a named list.

Returns a number of the added value. Note: the name of the list MUST be unique

Implements SALOMEDSClient_IParameters.

Definition at line 58 of file SALOMEDS_IParameters.cxx.

{
  if(!_ap) return -1;
  std::vector<std::string> v;
  if(!_ap->IsSet(listName, PT_STRARRAY)) {
    if(!_ap->IsSet(_AP_LISTS_LIST_, PT_STRARRAY)) _ap->SetStrArray(_AP_LISTS_LIST_, v);
    if(listName != _AP_ENTRIES_LIST_ && 
       listName != _AP_PROPERTIES_LIST_) {
      append(_AP_LISTS_LIST_, listName);
    }
    _ap->SetStrArray(listName, v);
  }
  v = _ap->GetStrArray(listName);
  v.push_back(value);
  _ap->SetStrArray(listName, v);
  return (v.size()-1);
}

Here is the caller graph for this function:

std::string SALOMEDS_IParameters::decodeEntry ( const std::string &  entry) [virtual]

Returns decoded entry that is an absolute entry.

Implements SALOMEDSClient_IParameters.

Definition at line 259 of file SALOMEDS_IParameters.cxx.

{
  if(!_study) return entry;
  int pos = entry.rfind("_");
  if(pos < 0 || pos >= entry.length()) return entry;

  std::string compName(entry, 0, pos), compID, tail(entry, pos+1, entry.length()-1);
  
  if(_compNames.find(compName) == _compNames.end()) {
    _PTR(SObject) so = _study->FindComponent(compName);
    if(!so) return entry;
    compID = so->GetID();
    _compNames[compName] = compID;
  }
  else compID = _compNames[compName];
 
  std::string newEntry(compID);
  newEntry += (":"+tail);
  
  return newEntry;
}

Here is the call graph for this function:

std::string SALOMEDS_IParameters::encodeEntry ( const std::string &  entry,
const std::string &  compName 
) [virtual]

Returns encoded entry that is a relative entry for the component.

Implements SALOMEDSClient_IParameters.

Definition at line 251 of file SALOMEDS_IParameters.cxx.

{
  std::string tail(entry, 6, entry.length()-1);
  std::string newEntry(compName);
  newEntry+=("_"+tail);
  return newEntry;
}
std::vector< std::string > SALOMEDS_IParameters::getAllParameterNames ( const std::string &  entry) [virtual]

Returns all parameter names of the given entry.

Implements SALOMEDSClient_IParameters.

Definition at line 137 of file SALOMEDS_IParameters.cxx.

{
  std::vector<std::string> v, names;
  if(!_ap) return v; 
  if(!_ap->IsSet(entry, PT_STRARRAY)) return v;
  v = _ap->GetStrArray(entry);
  int length = v.size();
  for(int i = 0; i<length; i+=2) {
    names.push_back(v[i]);
  }
  return names;
}
std::vector< std::string > SALOMEDS_IParameters::getAllParameterValues ( const std::string &  entry) [virtual]

Returns all parameter values of the given entry.

Implements SALOMEDSClient_IParameters.

Definition at line 177 of file SALOMEDS_IParameters.cxx.

{
  std::vector<std::string> v, values;
  if(!_ap) return v; 
  if(!_ap->IsSet(entry, PT_STRARRAY)) return v;
  v = _ap->GetStrArray(entry);
  int length = v.size();
  for(int i = 1; i<length; i+=2) {
    values.push_back(v[i]);
  }
  return values; 
}

Returns a default name of the component where the visula parameters are stored.

Implements SALOMEDSClient_IParameters.

Definition at line 303 of file SALOMEDS_IParameters.cxx.

{
  return "Interface Applicative";
}

Here is the caller graph for this function:

std::vector< std::string > SALOMEDS_IParameters::getEntries ( ) [virtual]

Returns a list all entries.

Implements SALOMEDSClient_IParameters.

Definition at line 197 of file SALOMEDS_IParameters.cxx.

{
  std::vector<std::string> v;
  if(!_ap) return v;
  if(!_ap->IsSet(_AP_ENTRIES_LIST_, PT_STRARRAY)) return v;
  return _ap->GetStrArray(_AP_ENTRIES_LIST_);
}
std::string SALOMEDS_IParameters::getIdParameter ( const std::string &  entry) [virtual]

Gets an id parameter value for the given entry.

Implements SALOMEDSClient_IParameters.

Definition at line 151 of file SALOMEDS_IParameters.cxx.

{
  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 > SALOMEDS_IParameters::getLists ( ) [virtual]

Returns a list all entries lists.

Implements SALOMEDSClient_IParameters.

Definition at line 102 of file SALOMEDS_IParameters.cxx.

{
  std::vector<std::string> v;
  if(!_ap->IsSet(_AP_LISTS_LIST_, PT_STRARRAY)) return v;
  return _ap->GetStrArray(_AP_LISTS_LIST_);
}
int SALOMEDS_IParameters::getNbParameters ( const std::string &  entry) [virtual]

Returns a number of parameters of the given entry.

Implements SALOMEDSClient_IParameters.

Definition at line 190 of file SALOMEDS_IParameters.cxx.

{
  if(!_ap) return -1;
  if(!_ap->IsSet(entry, PT_STRARRAY)) return -1;
  return  _ap->GetStrArray(entry).size()/2;
}
std::string SALOMEDS_IParameters::getParameter ( const std::string &  entry,
const std::string &  parameterName 
) [virtual]

Gets a named parameter value for the given entry.

Implements SALOMEDSClient_IParameters.

Definition at line 124 of file SALOMEDS_IParameters.cxx.

{
  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] == parameterName) return v[i+1];
  }
  return "";
}
std::vector< std::string > SALOMEDS_IParameters::getProperties ( ) [virtual]

Returns a list all properties.

Implements SALOMEDSClient_IParameters.

Definition at line 221 of file SALOMEDS_IParameters.cxx.

{
  std::vector<std::string> v;
  if(!_ap) return v;
  if(!_ap->IsSet(_AP_PROPERTIES_LIST_, PT_STRARRAY)) return v;
  return _ap->GetStrArray(_AP_PROPERTIES_LIST_);
}
std::string SALOMEDS_IParameters::getProperty ( const std::string &  name) [virtual]

Gets a value of global named property.

Implements SALOMEDSClient_IParameters.

Definition at line 214 of file SALOMEDS_IParameters.cxx.

{
  if(!_ap) return "";
  if(!_ap->IsSet(name, PT_STRING)) return "";
  return _ap->GetString(name);
}
std::string SALOMEDS_IParameters::getValue ( const std::string &  listName,
int  index 
) [virtual]

Returns a value with given index, where index is in range [0:nbValues-1].

Implements SALOMEDSClient_IParameters.

Definition at line 93 of file SALOMEDS_IParameters.cxx.

{
  if(!_ap) return "";
  if(!_ap->IsSet(listName, PT_STRARRAY)) return "";
  std::vector<std::string> v = _ap->GetStrArray(listName);
  if(index >= v.size()) return ""; 
  return v[index];
}
std::vector< std::string > SALOMEDS_IParameters::getValues ( const std::string &  listName) [virtual]

Returns a list of values in the list.

Implements SALOMEDSClient_IParameters.

Definition at line 84 of file SALOMEDS_IParameters.cxx.

{
  std::vector<std::string> v;
  if(!_ap) return v;
  if(!_ap->IsSet(listName, PT_STRARRAY)) return v;
  return _ap->GetStrArray(listName);
}
bool SALOMEDS_IParameters::isDumpPython ( _PTR(Study)  study,
const std::string &  theID = "" 
) [virtual]

Returns whether there is the dumping visual parameters.

Implements SALOMEDSClient_IParameters.

Definition at line 291 of file SALOMEDS_IParameters.cxx.

{
  std::string anID;
  if(theID == "") anID = getDefaultVisualComponent();
  else anID = theID;

  _PTR(AttributeParameter) ap = study->GetCommonParameters(anID, 0);
  if(!ap) return false;
  if(!ap->IsSet(_AP_DUMP_PYTHON_, PT_BOOLEAN)) return false;
  return (bool)ap->GetBool(_AP_DUMP_PYTHON_);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int SALOMEDS_IParameters::nbValues ( const std::string &  listName) [virtual]

Returns a number elements in the list.

Implements SALOMEDSClient_IParameters.

Definition at line 76 of file SALOMEDS_IParameters.cxx.

{
  if(!_ap) return -1;
  if(!_ap->IsSet(listName, PT_STRARRAY)) return 0;
  std::vector<std::string> v = _ap->GetStrArray(listName);
  return v.size();
}
std::vector< std::string > SALOMEDS_IParameters::parseValue ( const std::string &  value,
const char  separator,
bool  fromEnd = true 
) [virtual]

Breaks a value string in two parts which is divided by separator.

If fromEnd is True the search of separator starts from the end of the string

Implements SALOMEDSClient_IParameters.

Definition at line 230 of file SALOMEDS_IParameters.cxx.

{
  std::string val(value);
  std::vector<std::string> v;
  int pos;
  if(fromEnd) pos = val.rfind(separator);
  else pos = val.find(separator);

  if(pos < 0) {
    v.push_back(value);
    return v;
  }

  std::string part1, part2;
  part1 = val.substr(0, pos);
  part2 = val.substr(pos+1, val.size());
  v.push_back(part1);
  v.push_back(part2);
  return v;
}
void SALOMEDS_IParameters::setDumpPython ( _PTR(Study)  study,
const std::string &  theID = "" 
) [virtual]

Enables/Disables the dumping visual parameters.

Implements SALOMEDSClient_IParameters.

Definition at line 281 of file SALOMEDS_IParameters.cxx.

{
  std::string anID;
  if(theID == "") anID = getDefaultVisualComponent();
  else anID = theID;

  _PTR(AttributeParameter) ap = study->GetCommonParameters(anID, 0);
  ap->SetBool(_AP_DUMP_PYTHON_, !isDumpPython(study, theID));
}

Here is the call graph for this function:

void SALOMEDS_IParameters::setIdParameter ( const std::string &  entry,
const std::string &  value 
) [virtual]

Sets an id parameter value for the given entry.

Implements SALOMEDSClient_IParameters.

Definition at line 163 of file SALOMEDS_IParameters.cxx.

{
  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);
}

Here is the call graph for this function:

void SALOMEDS_IParameters::setParameter ( const std::string &  entry,
const std::string &  parameterName,
const std::string &  value 
) [virtual]

Sets a new named parameter value for the given entry.

Implements SALOMEDSClient_IParameters.

Definition at line 109 of file SALOMEDS_IParameters.cxx.

{
  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(parameterName);
  v.push_back(value);
  _ap->SetStrArray(entry, v);
}

Here is the call graph for this function:

void SALOMEDS_IParameters::setProperty ( const std::string &  name,
const std::string &  value 
) [virtual]

Sets a global named property value.

Implements SALOMEDSClient_IParameters.

Definition at line 205 of file SALOMEDS_IParameters.cxx.

{
  if(!_ap) return;
  if(!_ap->IsSet(name, PT_STRING)) {
    append(_AP_PROPERTIES_LIST_, name); //Add the property to the internal list of properties
  }
  _ap->SetString(name, value);
}

Here is the call graph for this function:


Member Data Documentation

std::map<std::string, std::string> SALOMEDS_IParameters::_compNames [private]

Definition at line 160 of file SALOMEDS_IParameters.hxx.


The documentation for this class was generated from the following files: