From a0ed0f9e1ca535743c1d280de9052e4fa8c87f61 Mon Sep 17 00:00:00 2001 From: apl Date: Fri, 30 Mar 2012 08:58:04 +0000 Subject: [PATCH] virtual methods for DDS_Dictionary class. DDS_Dictionary, DDS_Group, DDS_Item now can be subclassed for dictionary customziation. --- src/DDS/DDS_DicGroup.cxx | 68 +++++++++++++- src/DDS/DDS_DicGroup.h | 43 ++++++--- src/DDS/DDS_DicItem.cxx | 185 +++++++++++++++++++++++++++++++++++++ src/DDS/DDS_DicItem.h | 182 ++++++++++++++++++++++-------------- src/DDS/DDS_Dictionary.cxx | 56 +++++++---- src/DDS/DDS_Dictionary.h | 25 +++-- 6 files changed, 452 insertions(+), 107 deletions(-) diff --git a/src/DDS/DDS_DicGroup.cxx b/src/DDS/DDS_DicGroup.cxx index b084ec637..299406652 100644 --- a/src/DDS/DDS_DicGroup.cxx +++ b/src/DDS/DDS_DicGroup.cxx @@ -182,12 +182,12 @@ void DDS_DicGroup::FillDataMap( const LDOM_Element& theComponentData, const LDOM // 1. Attributes (id,label,units?,format?,required?) TCollection_AsciiString anID = aQuantity.getAttribute( DDS_Dictionary::KeyWord( "DATUM_ID" ) ); - Handle(DDS_DicItem) aDicItem = new DDS_DicItem(); + Handle(DDS_DicItem) aDicItem = CreateItem(); aDicItem->myComponent = this; aDicItem->FillDataMap( anID, aQuantity, theComponentData, theDocElement, unitSystems ); myDataMap.Add( anID, aDicItem ); - + bool exist = false; for( int i=1, n=myKeys.Length(); i<=n && !exist; i++ ) if( myKeys.Value( i )==anID ) @@ -226,3 +226,67 @@ void DDS_DicGroup::GetKeys( TColStd_SequenceOfAsciiString& seq ) const { seq = myKeys; } + +/*! + \brief Instantiate new dictionary item, used for customization of + data dictionary items. + \return New dictionary item instance. +*/ +Handle(DDS_DicItem) DDS_DicGroup::CreateItem() const +{ + return new DDS_DicItem(); +} + +/*! + \brief Bind dictionary item to ID + \return Standard_True if the item has been succesfully bound. + Standard_False if there is an item with same id. +*/ +Standard_Boolean DDS_DicGroup::AddDicItem( const TCollection_AsciiString& theID, + const Handle(DDS_DicItem)& theDicItem ) +{ + if ( myDataMap.Contains( theID ) ) + return Standard_False; + + myDataMap.Add( theID, theDicItem ); + myKeys.Append( theID ); + + return Standard_True; +} + +/*! + \brief Check if there is item bounded by id. + \return Standard_True if there is an item bound in map with given id. +*/ +Standard_Boolean DDS_DicGroup::HasDicItem( const TCollection_AsciiString& theID ) const +{ + return myDataMap.Contains( theID ); +} + +/*! + \brief Clear dictionary items map +*/ +void DDS_DicGroup::RemoveAllDicItems() +{ + myDataMap.Clear(); + myKeys.Clear(); +} + +/*! + \brief Returns a reference to a map. Can be used to iterate through + dictionary items. +*/ +const DDS_IndexedDataMapOfDicItems& DDS_DicGroup::GetItemMap() const +{ + return myDataMap; +} + +/*! + \brief Add new unit system and bind its label name. + \return Standard_False if there is other system bound by this key. +*/ +Standard_Boolean DDS_DicGroup::AddUnitSystem( const TCollection_AsciiString& theSystemKey, + const TCollection_ExtendedString& theSystemLabel ) +{ + return myUnitSystem.Bind( theSystemKey, theSystemLabel ); +} diff --git a/src/DDS/DDS_DicGroup.h b/src/DDS/DDS_DicGroup.h index 53d7d6080..614566535 100644 --- a/src/DDS/DDS_DicGroup.h +++ b/src/DDS/DDS_DicGroup.h @@ -38,27 +38,44 @@ DEFINE_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared) class DDS_DicGroup : public MMgt_TShared { public: - DDS_DicGroup( const TCollection_AsciiString& ); + Standard_EXPORT DDS_DicGroup( const TCollection_AsciiString& ); - TCollection_AsciiString GetName() const; - Standard_EXPORT void GetKeys( TColStd_SequenceOfAsciiString& ) const; + Standard_EXPORT TCollection_AsciiString GetName() const; + Standard_EXPORT void GetKeys( TColStd_SequenceOfAsciiString& ) const; - Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const; + Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const; - Standard_EXPORT void GetUnitSystems( TColStd_SequenceOfAsciiString& ) const; - Standard_EXPORT TCollection_ExtendedString GetUnitSystemLabel( const TCollection_AsciiString& ) const; + Standard_EXPORT void GetUnitSystems( TColStd_SequenceOfAsciiString& ) const; + Standard_EXPORT TCollection_ExtendedString GetUnitSystemLabel( const TCollection_AsciiString& ) const; - Standard_EXPORT TCollection_AsciiString GetActiveUnitSystem() const; - Standard_EXPORT void SetActiveUnitSystem( const TCollection_AsciiString& ); + Standard_EXPORT TCollection_AsciiString GetActiveUnitSystem() const; + Standard_EXPORT void SetActiveUnitSystem( const TCollection_AsciiString& ); -private: - DDS_DicGroup( const DDS_DicGroup& ); + virtual Standard_EXPORT Handle(DDS_DicItem) CreateItem() const; + +protected: - void operator=( const DDS_DicGroup& ); + Standard_EXPORT DDS_DicGroup( const DDS_DicGroup& ); - void FillDataMap( const LDOM_Element&, const LDOM_Element& ); + Standard_EXPORT void operator=( const DDS_DicGroup& ); + + Standard_EXPORT virtual void FillDataMap( const LDOM_Element&, const LDOM_Element& ); + + Standard_EXPORT Standard_Boolean AddDicItem( const TCollection_AsciiString&, + const Handle(DDS_DicItem)& ); + + Standard_EXPORT Standard_Boolean HasDicItem( const TCollection_AsciiString& ) const; + + Standard_EXPORT void RemoveAllDicItems(); + + Standard_EXPORT const + DDS_IndexedDataMapOfDicItems& GetItemMap() const; + + Standard_EXPORT Standard_Boolean AddUnitSystem( const TCollection_AsciiString&, + const TCollection_ExtendedString& ); + +protected: -private: typedef NCollection_DataMap UnitSystemMap; diff --git a/src/DDS/DDS_DicItem.cxx b/src/DDS/DDS_DicItem.cxx index baa616b3c..f8030e45b 100644 --- a/src/DDS/DDS_DicItem.cxx +++ b/src/DDS/DDS_DicItem.cxx @@ -1291,3 +1291,188 @@ DDS_DicItem::UnitSystem DDS_DicItem::GetActiveUnitSystem() const aSystem = aComponent->GetActiveUnitSystem(); return aSystem; } + +/*! + \brief Set item's identify string. + \param theId identify string. +*/ +void DDS_DicItem::SetId( const TCollection_AsciiString& theId ) +{ + myId = theId; +} + +/*! + \brief Set item's component pointer. + \param theComponent component pointer. +*/ +void DDS_DicItem::SetComponent( const Handle(Standard_Transient)& theComponent ) +{ + myComponent = theComponent; +} + +/*! + \brief Set item's label string. + \param theLabel label string. +*/ +void DDS_DicItem::SetLabel( const TCollection_AsciiString& theLabel ) +{ + myLabel = theLabel; +} + +/*! + \brief Set item's filter string. + \param theFilter filter string. +*/ +void DDS_DicItem::SetFilter( const TCollection_AsciiString& theFilter ) +{ + myFilter = theFilter; +} + +/*! + \brief Set item's required value. + \param theRequired required value string. +*/ +void DDS_DicItem::SetRequired( const TCollection_AsciiString& theRequired ) +{ + myRequired = theRequired; +} + +/*! + \brief Set item's warning level value. + \param theWarningLevel warning level value. +*/ +void DDS_DicItem::SetWarningLevel( const Standard_Integer& theWarningLevel ) +{ + myWarnLevel = theWarningLevel; +} + +/*! + \brief Set item's minimum zoom value. + \param theMinZoom minimum zoom value. +*/ +void DDS_DicItem::SetMinZoom( const Standard_Real& theMinZoom ) +{ + myMinZoom = theMinZoom; +} + +/*! + \brief Set item's maximum zoom value. + \param theMaxZoom maximum zoom value. +*/ +void DDS_DicItem::SetMaxZoom( const Standard_Real& theMaxZoom ) +{ + myMaxZoom = theMaxZoom; +} + +/*! + \brief Set item's zoom order value. + \param theZoomOrder zoom order value. +*/ +void DDS_DicItem::SetZoomOrder( const Standard_Real& theZoomOrder ) +{ + myZoomOrder = theZoomOrder; +} + +/*! + \brief Set item's short description. + \param theShortDescr short description string. +*/ +void DDS_DicItem::SetShortDescription( const TCollection_ExtendedString& theShortDescr ) +{ + myShortDescr = theShortDescr; +} + +/*! + \brief Set item's long description. + \param theLongDescr long description string. +*/ +void DDS_DicItem::SetLongDescription( const TCollection_ExtendedString& theLongDescr ) +{ + myLongDescr = theLongDescr; +} + +/*! + \brief Add item's option. + \param theOptionName option name string. + \param theOptionValue option value string. +*/ +bool DDS_DicItem::SetOption( const TCollection_AsciiString& theOptionName, + const TCollection_AsciiString& theOptionValue ) +{ + return myOptions.Bind( theOptionName, theOptionValue ); +} + +/*! + \brief Set item's type value. + \param theType item value type. +*/ +void DDS_DicItem::SetType( const DDS_DicItem::Type& theType ) +{ + myType = theType; +} + +/*! + \brief Set item's minimum value. + \param theMinVal minimum possible value. +*/ +void DDS_DicItem::SetMin( const Standard_Real& theMinVal ) +{ + myData |= MinValue; + myMin = theMinVal; +} + +/*! + \brief Set item's maximum value. + \param theMaxVal maximum possible value. +*/ +void DDS_DicItem::SetMax( const Standard_Real& theMaxVal ) +{ + myData |= MaxValue; + myMax = theMaxVal; +} + +/*! + \brief Set item's default value as a real number. + \param theDefVal default value. +*/ +void DDS_DicItem::SetDefaultValue( const Standard_Real& theDefVal ) +{ + myData |= DefaultValue; + myDefValue = theDefVal; +} + +/*! + \brief Set item's default value as a string. + \param theDefStr default value. +*/ +void DDS_DicItem::SetDefaultValue( const TCollection_AsciiString& theDefStr ) +{ + myDefString = theDefStr; +} + +/*! + \brief Set item's value list. + \param theStrings list of value strings. + \param theIntegers list of integer values associated with string item. +*/ +void DDS_DicItem::SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)& theStrings, + const Handle(TColStd_HArray1OfInteger)& theIntegers ) +{ + myListRef = theStrings; + myListRefID = theIntegers; +} + +/*! + \brief Set item's value list and icons. + \param theStrings list of value strings. + \param theIntegers list of integer values associated with string item. + \param theIcons list of icons associated with string item. +*/ +void DDS_DicItem::SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)& theStrings, + const Handle(TColStd_HArray1OfInteger)& theIntegers, + const Handle(TColStd_HArray1OfExtendedString)& theIcons ) +{ + myListRef = theStrings; + myListRefID = theIntegers; + myListRefIcons = theIcons; +} diff --git a/src/DDS/DDS_DicItem.h b/src/DDS/DDS_DicItem.h index 994104a97..8bc23a005 100644 --- a/src/DDS/DDS_DicItem.h +++ b/src/DDS/DDS_DicItem.h @@ -82,90 +82,132 @@ public: typedef TCollection_AsciiString UnitSystem; public: - DDS_DicItem(); + Standard_EXPORT DDS_DicItem(); - Standard_EXPORT TCollection_AsciiString GetId() const; - Standard_EXPORT DDS_DicItem::Type GetType() const; - Standard_EXPORT TCollection_ExtendedString GetLabel() const; - Standard_EXPORT TCollection_ExtendedString GetFilter() const; - Standard_EXPORT TCollection_ExtendedString GetRequired() const; - Standard_EXPORT DDS_MsgType GetWarningLevel() const; - Standard_EXPORT TCollection_ExtendedString GetLongDescription() const; - Standard_EXPORT TCollection_ExtendedString GetShortDescription() const; - Standard_EXPORT TCollection_AsciiString GetComponent() const; + Standard_EXPORT TCollection_AsciiString GetId() const; + Standard_EXPORT DDS_DicItem::Type GetType() const; + Standard_EXPORT TCollection_ExtendedString GetLabel() const; + Standard_EXPORT TCollection_ExtendedString GetFilter() const; + Standard_EXPORT TCollection_ExtendedString GetRequired() const; + Standard_EXPORT DDS_MsgType GetWarningLevel() const; + Standard_EXPORT TCollection_ExtendedString GetLongDescription() const; + Standard_EXPORT TCollection_ExtendedString GetShortDescription() const; + Standard_EXPORT TCollection_AsciiString GetComponent() const; - Standard_EXPORT TCollection_AsciiString GetUnits() const; - Standard_EXPORT TCollection_AsciiString GetUnits( const UnitSystem& ) const; + Standard_EXPORT TCollection_AsciiString GetUnits() const; + Standard_EXPORT TCollection_AsciiString GetUnits( const UnitSystem& ) const; - Standard_EXPORT TCollection_ExtendedString GetDefaultValue() const; - Standard_EXPORT TCollection_ExtendedString GetDefaultValue( const UnitSystem& ) const; + Standard_EXPORT TCollection_ExtendedString GetDefaultValue() const; + Standard_EXPORT TCollection_ExtendedString GetDefaultValue( const UnitSystem& ) const; - Standard_EXPORT Standard_Real GetMinValue() const; - Standard_EXPORT Standard_Real GetMinValue( const UnitSystem& ) const; + Standard_EXPORT Standard_Real GetMinValue() const; + Standard_EXPORT Standard_Real GetMinValue( const UnitSystem& ) const; - Standard_EXPORT Standard_Real GetMaxValue() const; - Standard_EXPORT Standard_Real GetMaxValue( const UnitSystem& ) const; + Standard_EXPORT Standard_Real GetMaxValue() const; + Standard_EXPORT Standard_Real GetMaxValue( const UnitSystem& ) const; - Standard_EXPORT Standard_Integer GetPrecision() const; - Standard_EXPORT Standard_Integer GetPrecision( const UnitSystem& ) const; + Standard_EXPORT Standard_Integer GetPrecision() const; + Standard_EXPORT virtual Standard_Integer GetPrecision( const UnitSystem& ) const; - Standard_EXPORT TCollection_AsciiString GetFormat( const Standard_Boolean = Standard_True ) const; - Standard_EXPORT TCollection_AsciiString GetFormat( const UnitSystem&, - const Standard_Boolean = Standard_True ) const; - Standard_EXPORT TCollection_ExtendedString GetNameOfValues() const; - Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&, - Handle(TColStd_HArray1OfInteger)& ) const; - Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&, - Handle(TColStd_HArray1OfInteger)&, - Handle(TColStd_HArray1OfExtendedString)& ) const; - Standard_EXPORT Standard_Boolean GetSpecialValues( TColStd_MapOfReal& ) const; + Standard_EXPORT TCollection_AsciiString GetFormat( const Standard_Boolean = Standard_True ) const; + Standard_EXPORT virtual TCollection_AsciiString GetFormat( const UnitSystem&, + const Standard_Boolean = Standard_True ) const; + Standard_EXPORT TCollection_ExtendedString GetNameOfValues() const; + Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&, + Handle(TColStd_HArray1OfInteger)& ) const; + Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&, + Handle(TColStd_HArray1OfInteger)&, + Handle(TColStd_HArray1OfExtendedString)& ) const; + Standard_EXPORT Standard_Boolean GetSpecialValues( TColStd_MapOfReal& ) const; - Standard_EXPORT Standard_Real GetMinZoom() const; - Standard_EXPORT Standard_Real GetMaxZoom() const; - Standard_EXPORT Standard_Real GetZoomOrder() const; + Standard_EXPORT Standard_Real GetMinZoom() const; + Standard_EXPORT Standard_Real GetMaxZoom() const; + Standard_EXPORT Standard_Real GetZoomOrder() const; - Standard_EXPORT Standard_Real ToSI( const Standard_Real ) const; - Standard_EXPORT Standard_Real FromSI( const Standard_Real ) const; + Standard_EXPORT Standard_Real ToSI( const Standard_Real ) const; + Standard_EXPORT Standard_Real FromSI( const Standard_Real ) const; - Standard_EXPORT Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const; - Standard_EXPORT Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const; + Standard_EXPORT virtual Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const; + Standard_EXPORT virtual Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const; - Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const; + Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const; - Standard_EXPORT TCollection_ExtendedString GetOption( const TCollection_AsciiString& ) const; - Standard_EXPORT Standard_Boolean GetOptionNames( TColStd_SequenceOfAsciiString& ) const; + Standard_EXPORT TCollection_ExtendedString GetOption( const TCollection_AsciiString& ) const; + Standard_EXPORT Standard_Boolean GetOptionNames( TColStd_SequenceOfAsciiString& ) const; + +protected: + + Standard_EXPORT void SetId( const TCollection_AsciiString& ); + + Standard_EXPORT void SetComponent( const Handle(Standard_Transient)& ); + + Standard_EXPORT void SetLabel( const TCollection_AsciiString& ); + + Standard_EXPORT void SetFilter( const TCollection_AsciiString& ); + + Standard_EXPORT void SetRequired( const TCollection_AsciiString& ); + + Standard_EXPORT void SetWarningLevel( const Standard_Integer& ); + + Standard_EXPORT void SetMinZoom( const Standard_Real& ); + Standard_EXPORT void SetMaxZoom( const Standard_Real& ); + Standard_EXPORT void SetZoomOrder( const Standard_Real& ); + + Standard_EXPORT void SetShortDescription( const TCollection_ExtendedString& ); + Standard_EXPORT void SetLongDescription( const TCollection_ExtendedString& ); + + Standard_EXPORT bool SetOption( const TCollection_AsciiString&, const TCollection_AsciiString& ); + Standard_EXPORT void SetType( const DDS_DicItem::Type& ); + + Standard_EXPORT void SetMin( const Standard_Real& ); + Standard_EXPORT void SetMax( const Standard_Real& ); + + Standard_EXPORT void SetDefaultValue( const Standard_Real& ); + Standard_EXPORT void SetDefaultValue( const TCollection_AsciiString& ); + + Standard_EXPORT void SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)&, + const Handle(TColStd_HArray1OfInteger)& ); + Standard_EXPORT void SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)&, + const Handle(TColStd_HArray1OfInteger)&, + const Handle(TColStd_HArray1OfExtendedString)& ); + +protected: + + Standard_EXPORT DDS_DicItem( const DDS_DicItem& ); + + Standard_EXPORT void operator=( const DDS_DicItem& ); + + Standard_EXPORT virtual void FillDataMap( TCollection_AsciiString, const LDOM_Element&, + const LDOM_Element&, const LDOM_Element&, + const TColStd_SequenceOfAsciiString& ); private: - DDS_DicItem( const DDS_DicItem& ); - void operator=( const DDS_DicItem& ); - void FillDataMap( TCollection_AsciiString, const LDOM_Element&, - const LDOM_Element&, const LDOM_Element&, - const TColStd_SequenceOfAsciiString& ); - void PrepareFormats( const TCollection_AsciiString& ); - void GetDefaultFormat(); - UnitSystem GetActiveUnitSystem() const; - - void GetStringFormat( const TCollection_AsciiString&, - const TCollection_AsciiString&, - const TCollection_AsciiString&, - const TCollection_AsciiString&, - TCollection_AsciiString& ); - void GetIntegerFormat( const TCollection_AsciiString&, - const TCollection_AsciiString&, - const TCollection_AsciiString&, - const TCollection_AsciiString&, - const Standard_Character, - TCollection_AsciiString& ); - void GetFloatFormat( const TCollection_AsciiString&, - const TCollection_AsciiString&, - const TCollection_AsciiString&, - const TCollection_AsciiString&, - const Standard_Character, - TCollection_AsciiString& ); - void Split( const TCollection_AsciiString&, - Handle(TColStd_HArray1OfExtendedString)& ); - - UnitData* GetUnitData( const UnitSystem& ) const; + + Standard_EXPORT void PrepareFormats( const TCollection_AsciiString& ); + Standard_EXPORT void GetDefaultFormat(); + Standard_EXPORT UnitSystem GetActiveUnitSystem() const; + + Standard_EXPORT void GetStringFormat( const TCollection_AsciiString&, + const TCollection_AsciiString&, + const TCollection_AsciiString&, + const TCollection_AsciiString&, + TCollection_AsciiString& ); + Standard_EXPORT void GetIntegerFormat( const TCollection_AsciiString&, + const TCollection_AsciiString&, + const TCollection_AsciiString&, + const TCollection_AsciiString&, + const Standard_Character, + TCollection_AsciiString& ); + Standard_EXPORT void GetFloatFormat( const TCollection_AsciiString&, + const TCollection_AsciiString&, + const TCollection_AsciiString&, + const TCollection_AsciiString&, + const Standard_Character, + TCollection_AsciiString& ); + Standard_EXPORT void Split( const TCollection_AsciiString&, + Handle(TColStd_HArray1OfExtendedString)& ); + + Standard_EXPORT UnitData* GetUnitData( const UnitSystem& ) const; private: typedef NCollection_DataMap OptionsMap; diff --git a/src/DDS/DDS_Dictionary.cxx b/src/DDS/DDS_Dictionary.cxx index f02cf4390..eb5f01d18 100644 --- a/src/DDS/DDS_Dictionary.cxx +++ b/src/DDS/DDS_Dictionary.cxx @@ -42,6 +42,8 @@ IMPLEMENT_STANDARD_HANDLE(DDS_Dictionary, MMgt_TShared) IMPLEMENT_STANDARD_RTTIEXT(DDS_Dictionary, MMgt_TShared) +Handle(DDS_Dictionary) DDS_Dictionary::myDictionary = Handle(DDS_Dictionary)(); + /*! \class DDS_Dictionary \brief This class provides an information about used datums, @@ -424,12 +426,10 @@ void DDS_Dictionary::SetActiveUnitSystem( const TCollection_AsciiString& theSyst */ Handle_DDS_Dictionary DDS_Dictionary::Get() { - static Handle(DDS_Dictionary) sDictionary; - - if ( sDictionary.IsNull() ) - sDictionary = new DDS_Dictionary(); + if ( myDictionary.IsNull() ) + myDictionary = new DDS_Dictionary(); - return sDictionary; + return myDictionary; } /*! @@ -455,9 +455,8 @@ Standard_Boolean DDS_Dictionary::Load( const TCollection_AsciiString theFileName 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 ); + if ( !aDocElement.isNull() ) + aDic->FillDataMap( aDocElement ); _LoadMap.Add( theFileName ); @@ -526,17 +525,20 @@ Handle_DDS_DicItem DDS_Dictionary::GetDicItem( const TCollection_AsciiString& th /*! \brief Fill the internal data structures from the XML node. - \param theComponentData component XML node \param theDocElement document XML node */ -void DDS_Dictionary::FillDataMap( const LDOM_Element& theComponentData, const LDOM_Element& theDocElement ) +void DDS_Dictionary::FillDataMap( const LDOM_Element& theDocElement ) { - 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 ); + for ( LDOM_Element aComponentElem = theDocElement.GetChildByTagName( KeyWord( "COMPONENT" ) ); + !aComponentElem.isNull(); aComponentElem = aComponentElem.GetSiblingByTagName() ) + { + TCollection_AsciiString aCompName = aComponentElem.getAttribute( KeyWord( "COMPONENT_NAME" ) ); + if ( !myGroupMap.Contains( aCompName ) ) + myGroupMap.Add( aCompName, CreateGroup( aCompName ) ); + Handle(DDS_DicGroup) aDicGroup = myGroupMap.FindFromKey( aCompName ); + aDicGroup->FillDataMap( aComponentElem, theDocElement ); + myGroupMap.Add( aCompName, aDicGroup ); + } } /*! @@ -607,3 +609,25 @@ void DDS_Dictionary::GetKeys( const TCollection_AsciiString& theComponent, TColS if( !aDicGroup.IsNull() ) aDicGroup->GetKeys( seq ); } + +/*! + \brief Create instance of a dictionary group. This method can + be used for customization data dictionary by specific + groups design. + \return New dictionary group instance. +*/ +Handle(DDS_DicGroup) DDS_Dictionary::CreateGroup( const TCollection_AsciiString& theCompName ) const +{ + return new DDS_DicGroup( theCompName ); +} + +/*! + \brief Set instance of dictionary. This method might be used in descendant classes to initialize + custom dictionary and replace the default implementation. + This method overrides static handle on dictionary that is available + through Get() method +*/ +void DDS_Dictionary::SetDictionary( const Handle(DDS_Dictionary)& theDict ) +{ + myDictionary = theDict; +} diff --git a/src/DDS/DDS_Dictionary.h b/src/DDS/DDS_Dictionary.h index de178b1a1..6267bc5d2 100644 --- a/src/DDS/DDS_Dictionary.h +++ b/src/DDS/DDS_Dictionary.h @@ -67,17 +67,30 @@ public: static Standard_EXPORT LDOMString KeyWord( const TCollection_AsciiString& ); -private: - DDS_Dictionary(); - DDS_Dictionary( const DDS_Dictionary& ); +protected: - void operator=( const DDS_Dictionary& ); + Standard_EXPORT virtual Handle(DDS_DicGroup) CreateGroup( const TCollection_AsciiString& ) const; - void FillDataMap( const LDOM_Element&, const LDOM_Element& ); +protected: + + Standard_EXPORT DDS_Dictionary(); + + Standard_EXPORT DDS_Dictionary( const DDS_Dictionary& ); + + Standard_EXPORT void operator=( const DDS_Dictionary& ); + + Standard_EXPORT virtual void FillDataMap( const LDOM_Element& ); + + Standard_EXPORT static void SetDictionary(const Handle(DDS_Dictionary)& theDict); + +protected: -private: DDS_IndexedDataMapOfDicGroups myGroupMap; +private: + + static Handle(DDS_Dictionary) myDictionary; + public: DEFINE_STANDARD_RTTI(DDS_Dictionary) }; -- 2.39.2