summaryrefslogtreecommitdiff
path: root/src/TObj/TObj_TNameContainer.cxx
blob: c4d40122dd44430271aa719f99661e1822fa9b82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// File:        TObj_TNameContainer.cxx
// Created:     Tue Nov 23 12:51:24 2004
// Author:      Pavel TELKOV
// Copyright:   Open CASCADE  2007
// The original implementation Copyright: (C) RINA S.p.A

#include <TObj_TNameContainer.hxx>
#include <Standard_GUID.hxx>

IMPLEMENT_STANDARD_HANDLE(TObj_TNameContainer,TDF_Attribute)
IMPLEMENT_STANDARD_RTTIEXT(TObj_TNameContainer,TDF_Attribute)

//=======================================================================
//function : TObj_TNameContainer
//purpose  : 
//=======================================================================

TObj_TNameContainer::TObj_TNameContainer()
{
}

//=======================================================================
//function : GetID
//purpose  : 
//=======================================================================

const Standard_GUID& TObj_TNameContainer::GetID()
{
  static Standard_GUID theID ("3bbefb47-e618-11d4-ba38-0060b0ee18ea");
  return theID;
}
  
//=======================================================================
//function : ID
//purpose  : 
//=======================================================================

const Standard_GUID& TObj_TNameContainer::ID() const
{
  return GetID();
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================

Handle(TObj_TNameContainer) TObj_TNameContainer::Set(const TDF_Label& theLabel)
{
  Handle(TObj_TNameContainer) A;
  if (!theLabel.FindAttribute(TObj_TNameContainer::GetID(), A)) 
  {
    A = new TObj_TNameContainer;
    theLabel.AddAttribute(A);
  }
  return A;
}

//=======================================================================
//function : RecordName
//purpose  : 
//=======================================================================

void TObj_TNameContainer::RecordName(const Handle(TCollection_HExtendedString)& theName,
                                         const TDF_Label& theLabel)
{
  if(!IsRegistered(theName)) 
  {
    Backup();
    myMap.Bind(new TCollection_HExtendedString(theName->String()),theLabel);
  }
}

//=======================================================================
//function : RemoveName
//purpose  : 
//=======================================================================

void TObj_TNameContainer::RemoveName(const Handle(TCollection_HExtendedString)& theName)
{
  if(IsRegistered(theName)) 
  {
    Backup();
    myMap.UnBind(theName);
  }
}

void TObj_TNameContainer::Clear()
{
  Backup();
  myMap.Clear();
}

//=======================================================================
//function : CheckName
//purpose  : 
//=======================================================================

Standard_Boolean TObj_TNameContainer::IsRegistered(const Handle(TCollection_HExtendedString)& theName) const
{
  return myMap.IsBound(theName);
}
  
//=======================================================================
//function : NewEmpty
//purpose  : 
//=======================================================================

Handle(TDF_Attribute) TObj_TNameContainer::NewEmpty () const
{  
  return new TObj_TNameContainer();
}

//=======================================================================
//function : Restore
//purpose  : 
//=======================================================================

void TObj_TNameContainer::Restore(const Handle(TDF_Attribute)& theWith) 
{
  Handle(TObj_TNameContainer) R = Handle(TObj_TNameContainer)::DownCast (theWith);
  
  myMap = R->Get();
}

//=======================================================================
//function : Paste
//purpose  : 
//=======================================================================

void TObj_TNameContainer::Paste (const Handle(TDF_Attribute)& theInto,
                                     const Handle(TDF_RelocationTable)& /* RT */) const
{ 
  Handle(TObj_TNameContainer) R = Handle(TObj_TNameContainer)::DownCast (theInto);
  R->Set(myMap);
}

//=======================================================================
//function : Get
//purpose  : 
//=======================================================================

const TObj_DataMapOfNameLabel& TObj_TNameContainer::Get() const
{
  return myMap;
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================

void TObj_TNameContainer::Set(const TObj_DataMapOfNameLabel& theMap)
{
  Backup();
  myMap = theMap;
}