1 // Created on: 2004-11-23
2 // Created by: Pavel TELKOV
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 // The original implementation Copyright: (C) RINA S.p.A
18 #include <TObj_TNameContainer.hxx>
19 #include <Standard_GUID.hxx>
22 IMPLEMENT_STANDARD_RTTIEXT(TObj_TNameContainer,TDF_Attribute)
24 //=======================================================================
25 //function : TObj_TNameContainer
27 //=======================================================================
29 TObj_TNameContainer::TObj_TNameContainer()
33 //=======================================================================
36 //=======================================================================
38 const Standard_GUID& TObj_TNameContainer::GetID()
40 static Standard_GUID theID ("3bbefb47-e618-11d4-ba38-0060b0ee18ea");
44 //=======================================================================
47 //=======================================================================
49 const Standard_GUID& TObj_TNameContainer::ID() const
54 //=======================================================================
57 //=======================================================================
59 Handle(TObj_TNameContainer) TObj_TNameContainer::Set(const TDF_Label& theLabel)
61 Handle(TObj_TNameContainer) A;
62 if (!theLabel.FindAttribute(TObj_TNameContainer::GetID(), A))
64 A = new TObj_TNameContainer;
65 theLabel.AddAttribute(A);
70 //=======================================================================
71 //function : RecordName
73 //=======================================================================
75 void TObj_TNameContainer::RecordName(const Handle(TCollection_HExtendedString)& theName,
76 const TDF_Label& theLabel)
78 if(!IsRegistered(theName))
81 myMap.Bind(new TCollection_HExtendedString(theName->String()),theLabel);
85 //=======================================================================
86 //function : RemoveName
88 //=======================================================================
90 void TObj_TNameContainer::RemoveName(const Handle(TCollection_HExtendedString)& theName)
92 if(IsRegistered(theName))
95 myMap.UnBind(theName);
99 void TObj_TNameContainer::Clear()
105 //=======================================================================
106 //function : CheckName
108 //=======================================================================
110 Standard_Boolean TObj_TNameContainer::IsRegistered(const Handle(TCollection_HExtendedString)& theName) const
112 return myMap.IsBound(theName);
115 //=======================================================================
116 //function : NewEmpty
118 //=======================================================================
120 Handle(TDF_Attribute) TObj_TNameContainer::NewEmpty () const
122 return new TObj_TNameContainer();
125 //=======================================================================
128 //=======================================================================
130 void TObj_TNameContainer::Restore(const Handle(TDF_Attribute)& theWith)
132 Handle(TObj_TNameContainer) R = Handle(TObj_TNameContainer)::DownCast (theWith);
137 //=======================================================================
140 //=======================================================================
142 void TObj_TNameContainer::Paste (const Handle(TDF_Attribute)& theInto,
143 const Handle(TDF_RelocationTable)& /* RT */) const
145 Handle(TObj_TNameContainer) R = Handle(TObj_TNameContainer)::DownCast (theInto);
149 //=======================================================================
152 //=======================================================================
154 const TObj_DataMapOfNameLabel& TObj_TNameContainer::Get() const
159 //=======================================================================
162 //=======================================================================
164 void TObj_TNameContainer::Set(const TObj_DataMapOfNameLabel& theMap)
167 myMap.Assign (theMap);