blob: ddf37b665bc2cc2e38a23173e1c8991d649194fd (
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
|
// File: BinMDataStd_TreeNodeDriver.cxx
// Created: Fri Aug 24 20:46:58 2001
// Author: Alexnder GRIGORIEV
// Copyright: Open Cascade 2001
// History:
#include <BinMDataStd_TreeNodeDriver.ixx>
#include <TDataStd_TreeNode.hxx>
#include <TCollection_ExtendedString.hxx>
//=======================================================================
//function : BinMDataStd_TreeNodeDriver
//purpose : Constructor
//=======================================================================
BinMDataStd_TreeNodeDriver::BinMDataStd_TreeNodeDriver
(const Handle(CDM_MessageDriver)& theMsgDriver)
: BinMDF_ADriver (theMsgDriver, NULL)
{}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMDataStd_TreeNodeDriver::NewEmpty() const
{
return (new TDataStd_TreeNode());
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
Standard_Boolean BinMDataStd_TreeNodeDriver::Paste
(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const
{
Handle(TDataStd_TreeNode) aT = Handle(TDataStd_TreeNode)::DownCast(theTarget);
// read int fields
Standard_Integer i, aNb;
for (i = 0 ; i < 4; ++i)
{
if (! (theSource >> aNb))
return Standard_False;
if (aNb < 0) continue;
Handle(TDataStd_TreeNode) aNode;
if (theRelocTable.IsBound(aNb))
aNode = Handle(TDataStd_TreeNode)::DownCast(theRelocTable.Find(aNb));
else
{
aNode = Handle(TDataStd_TreeNode)::DownCast( aT->NewEmpty() ); // already with tree ID
theRelocTable.Bind(aNb, aNode);
}
switch (i) {
case 0: aT->SetFather (aNode); break;
case 1: aT->SetNext (aNode); break;
case 2: aT->SetPrevious(aNode); break;
case 3: aT->SetFirst (aNode); break;
default: continue;
}
}
// tree id
Standard_GUID aGUID;
if (! (theSource >> aGUID))
return Standard_False;
aT->SetTreeID(aGUID);
return Standard_True;
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void BinMDataStd_TreeNodeDriver::Paste
(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const
{
Handle(TDataStd_TreeNode) aS = Handle(TDataStd_TreeNode)::DownCast(theSource);
// first write int fields
Standard_Integer i, aNb;
for (i = 0 ; i < 4; ++i)
{
Handle(TDataStd_TreeNode) aNode;
switch (i) {
case 0: aNode = aS->Father(); break;
case 1: aNode = aS->Next(); break;
case 2: aNode = aS->Previous(); break;
case 3: aNode = aS->First(); break;
default: continue;
}
if (aNode.IsNull())
aNb = -1;
else
aNb = theRelocTable.Add(aNode); // create and/or get index
theTarget.PutInteger(aNb);
}
// tree id
theTarget << aS->ID();
}
|