0022627: Change OCCT memory management defaults
[occt.git] / src / TObj / TObj_TNameContainer.cxx
CommitLineData
7fd59977 1// File: TObj_TNameContainer.cxx
2// Created: Tue Nov 23 12:51:24 2004
3// Author: Pavel TELKOV
4// Copyright: Open CASCADE 2007
5// The original implementation Copyright: (C) RINA S.p.A
6
7#include <TObj_TNameContainer.hxx>
8#include <Standard_GUID.hxx>
9
10IMPLEMENT_STANDARD_HANDLE(TObj_TNameContainer,TDF_Attribute)
11IMPLEMENT_STANDARD_RTTIEXT(TObj_TNameContainer,TDF_Attribute)
12
13//=======================================================================
14//function : TObj_TNameContainer
15//purpose :
16//=======================================================================
17
18TObj_TNameContainer::TObj_TNameContainer()
19{
20}
21
22//=======================================================================
23//function : GetID
24//purpose :
25//=======================================================================
26
27const Standard_GUID& TObj_TNameContainer::GetID()
28{
29 static Standard_GUID theID ("3bbefb47-e618-11d4-ba38-0060b0ee18ea");
30 return theID;
31}
32
33//=======================================================================
34//function : ID
35//purpose :
36//=======================================================================
37
38const Standard_GUID& TObj_TNameContainer::ID() const
39{
40 return GetID();
41}
42
43//=======================================================================
44//function : Set
45//purpose :
46//=======================================================================
47
48Handle(TObj_TNameContainer) TObj_TNameContainer::Set(const TDF_Label& theLabel)
49{
50 Handle(TObj_TNameContainer) A;
51 if (!theLabel.FindAttribute(TObj_TNameContainer::GetID(), A))
52 {
53 A = new TObj_TNameContainer;
54 theLabel.AddAttribute(A);
55 }
56 return A;
57}
58
59//=======================================================================
60//function : RecordName
61//purpose :
62//=======================================================================
63
64void TObj_TNameContainer::RecordName(const Handle(TCollection_HExtendedString)& theName,
65 const TDF_Label& theLabel)
66{
67 if(!IsRegistered(theName))
68 {
69 Backup();
70 myMap.Bind(new TCollection_HExtendedString(theName->String()),theLabel);
71 }
72}
73
74//=======================================================================
75//function : RemoveName
76//purpose :
77//=======================================================================
78
79void TObj_TNameContainer::RemoveName(const Handle(TCollection_HExtendedString)& theName)
80{
81 if(IsRegistered(theName))
82 {
83 Backup();
84 myMap.UnBind(theName);
85 }
86}
87
88void TObj_TNameContainer::Clear()
89{
90 Backup();
91 myMap.Clear();
92}
93
94//=======================================================================
95//function : CheckName
96//purpose :
97//=======================================================================
98
99Standard_Boolean TObj_TNameContainer::IsRegistered(const Handle(TCollection_HExtendedString)& theName) const
100{
101 return myMap.IsBound(theName);
102}
103
104//=======================================================================
105//function : NewEmpty
106//purpose :
107//=======================================================================
108
109Handle(TDF_Attribute) TObj_TNameContainer::NewEmpty () const
110{
111 return new TObj_TNameContainer();
112}
113
114//=======================================================================
115//function : Restore
116//purpose :
117//=======================================================================
118
119void TObj_TNameContainer::Restore(const Handle(TDF_Attribute)& theWith)
120{
121 Handle(TObj_TNameContainer) R = Handle(TObj_TNameContainer)::DownCast (theWith);
122
123 myMap = R->Get();
124}
125
126//=======================================================================
127//function : Paste
128//purpose :
129//=======================================================================
130
131void TObj_TNameContainer::Paste (const Handle(TDF_Attribute)& theInto,
132 const Handle(TDF_RelocationTable)& /* RT */) const
133{
134 Handle(TObj_TNameContainer) R = Handle(TObj_TNameContainer)::DownCast (theInto);
135 R->Set(myMap);
136}
137
138//=======================================================================
139//function : Get
140//purpose :
141//=======================================================================
142
143const TObj_DataMapOfNameLabel& TObj_TNameContainer::Get() const
144{
145 return myMap;
146}
147
148//=======================================================================
149//function : Set
150//purpose :
151//=======================================================================
152
153void TObj_TNameContainer::Set(const TObj_DataMapOfNameLabel& theMap)
154{
155 Backup();
156 myMap = theMap;
157}