Back to index

salome-gui  6.5.0
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
DDS_Dictionary Class Reference

This class provides an information about used datums, reading them from XML file. More...

#include <DDS_Dictionary.h>

Collaboration diagram for DDS_Dictionary:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Standard_EXPORT void GetKeys (const TCollection_AsciiString &, TColStd_SequenceOfAsciiString &) const
 Fill given string container seq with keys belonging to group with name theComponent.
Standard_EXPORT Handle (DDS_DicItem) GetDicItem(const TCollection_AsciiString &) const
Standard_EXPORT Handle (DDS_DicItem) GetDicItem(const TCollection_AsciiString &
Standard_EXPORT void GetUnitSystems (TColStd_SequenceOfAsciiString &) const
 Get the names of defined units systems from all components.
Standard_EXPORT void GetUnitSystems (TColStd_SequenceOfAsciiString &, const TCollection_AsciiString &) const
 Get the names of defined units systems from the specified component theComponent.
Standard_EXPORT
TCollection_ExtendedString 
GetUnitSystemLabel (const TCollection_AsciiString &) const
 Get the label of the units system theSystem.
Standard_EXPORT
TCollection_ExtendedString 
GetUnitSystemLabel (const TCollection_AsciiString &, const TCollection_AsciiString &) const
 Get the label of the units system theSystem from the component theComponent.
Standard_EXPORT
TCollection_AsciiString 
GetActiveUnitSystem () const
 Get the name of active units system from the first found component.
Standard_EXPORT
TCollection_AsciiString 
GetActiveUnitSystem (const TCollection_AsciiString &) const
 Get the name of active units system from the component theComponent.
Standard_EXPORT void SetActiveUnitSystem (const TCollection_AsciiString &)
 Set the active units system.
Standard_EXPORT void SetActiveUnitSystem (const TCollection_AsciiString &, const TCollection_AsciiString &)
 Set the active units system for the component theComponent.

Static Public Member Functions

static Standard_EXPORT Handle (DDS_Dictionary) Get()
static Standard_EXPORT
Standard_Boolean 
Load (const TCollection_AsciiString)
 Load datum definitions in the dictionary from the XML file theFileName.
static Standard_EXPORT
Standard_Real 
ToSI (const Standard_Real, const Standard_CString)
 Convert numeric value theValue from specified measure units theUnits to "SI" measure units (mm for Length, radians for Angles, etc).
static Standard_EXPORT
Standard_Real 
FromSI (const Standard_Real, const Standard_CString)
 Convert numeric value theValue to specified measure units theUnits from "SI" measure units (mm for Length, radians for Angles, etc).
static Standard_EXPORT LDOMString KeyWord (const TCollection_AsciiString &)
 Get XML keyword as LDOMString by specified key.

Public Attributes

Standard_EXPORT const
TCollection_AsciiString & 
const

Private Member Functions

 DDS_Dictionary ()
 Constructor.
 DDS_Dictionary (const DDS_Dictionary &)
 Copy constructor (put in private section to prevent object copying).
void operator= (const DDS_Dictionary &)
 Assignment operator (put in private section to prevent object copying).
void FillDataMap (const LDOM_Element &, const LDOM_Element &)
 Fill the internal data structures from the XML node.

Private Attributes

DDS_IndexedDataMapOfDicGroups myGroupMap

Detailed Description

This class provides an information about used datums, reading them from XML file.

There is the only instance of the class DDS_Dictionary in the application which can be retrieved by method Get().

Datum is a set of parameters describing a phisical characteristic. These parameters are loaded from the XML file which has the following format:

  <D_URI>
  <COMPONENT COMPONENT_NAME="component_name">
    <UNIT_SYSTEMS>
      <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
      <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
      ...
      <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
    </UNIT_SYSTEMS>

    <DATUM DATUM_UNITS="[base_system_internal_name]" DATUM_FORMAT="[sprintf_format_specification]"
           DATUM_ID="[datum_id]" DATUM_LABEL="[datum_label]" DATUM_REQUIRED="[requred_value]"
           DATUM_FILTER="[string_regular_expression]">
      <DY_DOMAIN>
        <VALUE_DESCR VD_DEFV="[default_value]" VD_MAXV="[max_value]" VD_MINV="[min_value]" VD_TYPE="[value_type]"/>
        <VALUE_LIST_REF VLR_LIST="[referenced_list_id]"/>
      </DY_DOMAIN>
      <DESCR>
        <SHORT_D>[brief_desription_text]</SHORT_D>
        <LONG_D>[full_description_text]</LONG_D>
      </DESCR>
      <OPTIONS>
        <OPTION OPTION_NAME="[option_name_1]">[option_value_1]</OPTION>
        <OPTION OPTION_NAME="[option_name_2]">[option_value_2]</OPTION>
        ...
        <OPTION OPTION_NAME="[option_name_n]">[option_value_n]</OPTION>
      </OPTIONS>
    </DATUM>

    ...

    <VALUE_LIST VALUE_LIST_ID="[list_id]" VALUE_LIST_NAME="[list_name]">
      <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
      <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
      ...
      <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
    </VALUE_LIST>

    ...

    </COMPONENT>
  </D_URI>

In above description of the datum XML file format internal keys are used as XML tags and attributes names. Real XML keywords are defined by DDS_KeyWords class.

XML file should have one main tag named "dictionary" (key "D_URI"). This tag should contain one or several components. Component is an independent set of datums and units systems. Components are defined by XML tag named "component" (key "COMPONENT") with attribute "name" (key COMPONENT_NAME). Component name is used as component identifier and should be unique.

Component tag can contain:

Tag "datum" can have child subtags "description" and "options".

Each tag "datum" defines most common parameters of phisical characteristic. These parameters are placed in two groups:

  1. Domain parameters under the tag "domain" (key DY_DOMAIN). This tag can contain value description tag (key VALUE_DESCR) for descrete data which is described by following parameters:
    • default value (key VD_DEFV)
    • maximum value (key VD_MAXV)
    • minimum value (key VD_MINV)
    • type of value (key VD_TYPE), possible values are String, Integer, Float, List
  2. list reference tag (key VALUE_LIST_REF) for enumerable data described by "list reference" attribute (key VLR_LIST) which references to the list (see "list definition" tag) by list id.

Below is an example of the XML file using default keywords.

  <datadictionary version="1.0">
    <component name="My Component">

      <!-- specify two unit systems -->

      <unitSystems>
        <system name="SI" label="System international">
        <system name="AS" label="Anglo - sacson system">
      </unitSystems>

      <!-- specify datum -->
      <!-- units of measure for SI - meters (m), for AS - inches (in) -->
      <datum SIunits="m" ASunits="in" format="%.25f" id="X" label="X coordinate" required="">
        <domain>
          <!-- default value not specified -->
          <valueDescr default="" max="999999999.999" min="0.000" type="Float"/>
        </domain>
        <description>
          <shortDescr>X coordinate for object</shortDescr>
          <longDescr>X multiplier of object coordinates. Describe position of object in direction of X axis</longDescr>
        </description>
      </datum>

      <datum SIunits="m" ASunits="in" format="%.25f" id="Y" label="Y coordinate" required="">
        <domain>
          <valueDescr default="" max="999999999.999" min="0.000" type="Float"/>
        </domain>
        <description>
          <shortDescr>Y coordinate for object</shortDescr>
          <longDescr>Y multiplier of object coordinates. Describe position of object in direction of Y axis</longDescr>
        </description>
      </datum>

      <!-- datum for object name with filter which not allow to input more that 8 letters,
           numbers or unerscores with first letter only -->
      <datum format="%.8us" id="ObjectName" label="Name" required="yes"
             filter="^([A-Z]+)([A-Z,0-9,_]*)$">
        <domain>
          <!-- limits and default not specified, type is string -->
          <valueDescr default="" max="" min="" type="String" />
        </domain>
        <description>
          <!-- long description not specified -->
          <shortDescr>Name of object</shortDescr>
        </description>
      </datum>


      <!-- datum for enumeration of side -->
      <datum format="" id="Side" label="Side" required="">
        <domain>
          <!-- default list item is item with id 0 -->
          <valueDescr default="0" type="List"/>
          <!-- list reference on list named "side_list" -->
          <listRef list="side_list"/>
        </domain>
        <description>
          <shortDescr>Side of object</shortDescr>
        </description>
      </datum>

      <!-- list definition for enumeration of side -->
      <valueList listid="side_list" name="Side">
        <value id="1">left</value>
        <value id="2">right</value>
        <value id="3">top</value>
        <value id="4">bottom</value>
        <value id="0">undefined</value>
      </valueList>

    </component>
  </datadictionary>

Definition at line 37 of file DDS_Dictionary.h.


Constructor & Destructor Documentation

Constructor.

Create an instance of the dictionary. Can not be used directly. Use Get() method instead.

Definition at line 262 of file DDS_Dictionary.cxx.

: MMgt_TShared()
{
}

Copy constructor (put in private section to prevent object copying).

Definition at line 270 of file DDS_Dictionary.cxx.

{
}

Member Function Documentation

void DDS_Dictionary::FillDataMap ( const LDOM_Element &  theComponentData,
const LDOM_Element &  theDocElement 
) [private]

Fill the internal data structures from the XML node.

Parameters:
theComponentDatacomponent XML node
theDocElementdocument XML node

Definition at line 533 of file DDS_Dictionary.cxx.

{
  TCollection_AsciiString aCompName = theComponentData.getAttribute( KeyWord( "COMPONENT_NAME" ) );
  if ( !myGroupMap.Contains( aCompName ) )
    myGroupMap.Add( aCompName, new DDS_DicGroup( aCompName ) );
  Handle(DDS_DicGroup) aDicGroup = myGroupMap.FindFromKey( aCompName );
  aDicGroup->FillDataMap( theComponentData, theDocElement );
  myGroupMap.Add( aCompName, aDicGroup );
}

Here is the call graph for this function:

Standard_Real DDS_Dictionary::FromSI ( const Standard_Real  theValue,
const Standard_CString  theUnits 
) [static]

Convert numeric value theValue to specified measure units theUnits from "SI" measure units (mm for Length, radians for Angles, etc).

Parameters:
theValuevalue being converted
theUnitsmeasure units
Returns:
converted value

Definition at line 577 of file DDS_Dictionary.cxx.

{
  Standard_Real aRetValue = theValue;
  if ( theUnits && *theUnits && strcmp( theUnits, "%" ) )
  {
    try {
#if OCC_VERSION_LARGE > 0x06010000
      OCC_CATCH_SIGNALS;
#endif
      aRetValue = UnitsAPI::AnyFromSI( theValue, theUnits );
    }
    catch( Standard_Failure ) {
    }
  }
  else if ( theUnits && *theUnits )
    aRetValue = theValue * 100.0;

  return aRetValue;
}

Here is the caller graph for this function:

TCollection_AsciiString DDS_Dictionary::GetActiveUnitSystem ( ) const

Get the name of active units system from the first found component.

If at least one component exists, then its active units system name is returned. Otherwise, empty string is returned.

Returns:
active units system name

Definition at line 368 of file DDS_Dictionary.cxx.

{
  TCollection_AsciiString aSystem;
  if ( myGroupMap.Extent() )
    aSystem = myGroupMap.FindFromIndex( 1 )->GetActiveUnitSystem();
  return aSystem;
}
TCollection_AsciiString DDS_Dictionary::GetActiveUnitSystem ( const TCollection_AsciiString &  theComponent) const

Get the name of active units system from the component theComponent.

If this component exists, its active units system name is returned. Otherwise, empty string is returned.

Parameters:
theComponentcomponent name
Returns:
active units system name

Definition at line 385 of file DDS_Dictionary.cxx.

{
  TCollection_AsciiString aSystem;
  if ( myGroupMap.Contains( theComponent ) )
    aSystem = myGroupMap.FindFromKey( theComponent )->GetActiveUnitSystem();
  return aSystem;
}
void DDS_Dictionary::GetKeys ( const TCollection_AsciiString &  theComponent,
TColStd_SequenceOfAsciiString &  seq 
) const

Fill given string container seq with keys belonging to group with name theComponent.

Parameters:
theComponentname of group whose keys should be stored in the container
seqreturned string container with keys belonging to group; it is not cleared before filling

Definition at line 602 of file DDS_Dictionary.cxx.

{
  Handle( DDS_DicGroup ) aDicGroup;
  if( myGroupMap.Contains( theComponent ) )
    aDicGroup = myGroupMap.FindFromKey( theComponent );

  if( !aDicGroup.IsNull() )
    aDicGroup->GetKeys( seq );
}

Here is the call graph for this function:

TCollection_ExtendedString DDS_Dictionary::GetUnitSystemLabel ( const TCollection_AsciiString &  theSystem) const

Get the label of the units system theSystem.

Searches the given units system in all components. If units system is not found in any component, empty string is returned.

Parameters:
theSystemunits system
Returns:
units system label

Definition at line 332 of file DDS_Dictionary.cxx.

{
  TCollection_ExtendedString aLabel;
  for ( Standard_Integer i = 1; i <= myGroupMap.Extent() && !aLabel.Length(); i++ )
    aLabel = myGroupMap.FindFromIndex( i )->GetUnitSystemLabel( theSystem );
  return aLabel;
}
TCollection_ExtendedString DDS_Dictionary::GetUnitSystemLabel ( const TCollection_AsciiString &  theSystem,
const TCollection_AsciiString &  theComponent 
) const

Get the label of the units system theSystem from the component theComponent.

Searches the specified units system in the specified component only. If units system is not found, empty string is returned.

Parameters:
theSystemunits system
theComponentcomponent name
Returns:
units system label

Definition at line 351 of file DDS_Dictionary.cxx.

{
  TCollection_ExtendedString aLabel;
  if ( myGroupMap.Contains( theComponent ) )
    aLabel = myGroupMap.FindFromKey( theComponent )->GetUnitSystemLabel( theSystem );
  return aLabel;
}
void DDS_Dictionary::GetUnitSystems ( TColStd_SequenceOfAsciiString &  theSystems) const

Get the names of defined units systems from all components.

Parameters:
theSystemsreturning sequence of units systems names.

Definition at line 285 of file DDS_Dictionary.cxx.

{
  theSystems.Clear();

  NCollection_Map<TCollection_AsciiString> aMap;
  for ( Standard_Integer i = 1; i <= myGroupMap.Extent(); i++ )
  {
    TColStd_SequenceOfAsciiString theSeq;
    myGroupMap.FindFromIndex( i )->GetUnitSystems( theSeq );
    for ( Standard_Integer s = 1; s <= theSeq.Length(); s++ )
    {
      if ( aMap.Contains( theSeq.Value( s ) ) )
        continue;

      theSystems.Append( theSeq.Value( s ) );
      aMap.Add( theSeq.Value( s ) );
    }
  }

}
void DDS_Dictionary::GetUnitSystems ( TColStd_SequenceOfAsciiString &  theSystems,
const TCollection_AsciiString &  theComponent 
) const

Get the names of defined units systems from the specified component theComponent.

If component is not found, empty list is returned.

Parameters:
theSystemsreturning sequence of units systems names.
theComponentcomponent name

Definition at line 315 of file DDS_Dictionary.cxx.

{
  theSystems.Clear();
  if ( myGroupMap.Contains( theComponent ) )
    myGroupMap.FindFromKey( theComponent )->GetUnitSystems( theSystems );
}

Here is the caller graph for this function:

LDOMString DDS_Dictionary::KeyWord ( const TCollection_AsciiString &  key) [static]

Get XML keyword as LDOMString by specified key.

If key doesn't exist, empty string is returned. This function is provided for convenience.

Parameters:
keykeyword name
Returns:
keyword value

Definition at line 477 of file DDS_Dictionary.cxx.

{
  LDOMString keyWord;
  Handle(DDS_KeyWords) aKeyWords = DDS_KeyWords::Get();
  if ( !aKeyWords.IsNull() )
  {
    TCollection_AsciiString aStr = aKeyWords->GetKeyWord( key );
    if ( aStr.Length() )
      keyWord = LDOMString( aStr.ToCString() );
  }
  return keyWord;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Boolean DDS_Dictionary::Load ( const TCollection_AsciiString  theFileName) [static]

Load datum definitions in the dictionary from the XML file theFileName.

Parameters:
theFileNameXML file name
Returns:
true if loading is succeded or false otherwise.

Definition at line 442 of file DDS_Dictionary.cxx.

{
  static NCollection_Map<TCollection_AsciiString> _LoadMap;

  if ( _LoadMap.Contains( theFileName ) )
    return Standard_True;

  Handle(DDS_Dictionary) aDic = Get();
  if ( aDic.IsNull() )
    return Standard_False;

  LDOMParser aParser;
  if ( aParser.parse( theFileName.ToCString() ) )
    return Standard_False;

  LDOM_Document aDoc = aParser.getDocument();
  LDOM_Element aDocElement = aDoc.getDocumentElement();
  for ( LDOM_Element aComponentElem = aDocElement.GetChildByTagName( KeyWord( "COMPONENT" ) );
        !aComponentElem.isNull(); aComponentElem = aComponentElem.GetSiblingByTagName() )
    aDic->FillDataMap( aComponentElem, aDocElement );

  _LoadMap.Add( theFileName );

  return Standard_True;
}

Here is the call graph for this function:

void DDS_Dictionary::operator= ( const DDS_Dictionary ) [private]

Assignment operator (put in private section to prevent object copying).

Definition at line 277 of file DDS_Dictionary.cxx.

{
}
void DDS_Dictionary::SetActiveUnitSystem ( const TCollection_AsciiString &  theSystem)

Set the active units system.

This units system will be activated in each existing component, if it component has this units system.

Parameters:
theSystemunits system to be made active

Definition at line 401 of file DDS_Dictionary.cxx.

{
  for ( Standard_Integer i = 1; i <= myGroupMap.Extent(); i++ )
    myGroupMap.FindFromIndex( i )->SetActiveUnitSystem( theSystem );
}
void DDS_Dictionary::SetActiveUnitSystem ( const TCollection_AsciiString &  theSystem,
const TCollection_AsciiString &  theComponent 
)

Set the active units system for the component theComponent.

If specified units system doesn't exist in the component, nothing happens.

Parameters:
theSystemunits system to be made active
theComponentcomponent name

Definition at line 415 of file DDS_Dictionary.cxx.

{
  if ( myGroupMap.Contains( theComponent ) )
    myGroupMap.FindFromKey( theComponent )->SetActiveUnitSystem( theSystem );
}
Standard_Real DDS_Dictionary::ToSI ( const Standard_Real  theValue,
const Standard_CString  theUnits 
) [static]

Convert numeric value theValue from specified measure units theUnits to "SI" measure units (mm for Length, radians for Angles, etc).

Parameters:
theValuevalue being converted
theUnitsmeasure units
Returns:
converted value

Definition at line 550 of file DDS_Dictionary.cxx.

{
  Standard_Real aRetValue = theValue;
  if ( theUnits && *theUnits && strcmp( theUnits, "%" ) )
  {
    try {
#if OCC_VERSION_LARGE > 0x06010000
      OCC_CATCH_SIGNALS;
#endif
      aRetValue = UnitsAPI::AnyToSI( theValue, theUnits );
    }
    catch( Standard_Failure ) {
    }
  }
  else if ( theUnits && *theUnits )
    aRetValue = theValue / 100.0;

  return aRetValue;
}

Member Data Documentation

Standard_EXPORT const TCollection_AsciiString& DDS_Dictionary::const

Definition at line 48 of file DDS_Dictionary.h.

DDS_IndexedDataMapOfDicGroups DDS_Dictionary::myGroupMap [private]

Definition at line 79 of file DDS_Dictionary.h.


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