blob: 00f429c249d91388286afa23898303aafc08e0c1 (
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
|
// File: BinMDataStd_RelationDriver.cxx
// Created: Wed Sep 12 14:07:32 2001
// Author: Julia DOROVSKIKH
// Copyright: Open Cascade 2001
// History:
#include <BinMDataStd_RelationDriver.ixx>
#include <TDataStd_Relation.hxx>
#include <TDataStd_Variable.hxx>
#include <TDF_ListIteratorOfAttributeList.hxx>
//=======================================================================
//function : BinMDataStd_RelationDriver
//purpose : Constructor
//=======================================================================
BinMDataStd_RelationDriver::BinMDataStd_RelationDriver
(const Handle(CDM_MessageDriver)& theMsgDriver)
: BinMDF_ADriver (theMsgDriver, NULL)
{}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMDataStd_RelationDriver::NewEmpty() const
{
return (new TDataStd_Relation());
}
//=======================================================================
//function : Paste
//purpose : persistent -> transient (retrieve)
//=======================================================================
Standard_Boolean BinMDataStd_RelationDriver::Paste
(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const
{
Handle(TDataStd_Relation) aC =
Handle(TDataStd_Relation)::DownCast(theTarget);
// variables
Standard_Integer nbvar;
if (! (theSource >> nbvar) || nbvar < 0)
return Standard_False;
TDF_AttributeList& aList = aC->GetVariables();
for (; nbvar > 0; nbvar--)
{
Handle(TDF_Attribute) aV;
Standard_Integer aNb;
if (! (theSource >> aNb))
return Standard_False;
if (aNb > 0)
{
if (theRelocTable.IsBound(aNb))
aV = Handle(TDataStd_Variable)::DownCast(theRelocTable.Find(aNb));
else
{
aV = new TDataStd_Variable;
theRelocTable.Bind(aNb, aV);
}
}
aList.Append(aV);
}
// expression
TCollection_ExtendedString aString;
if (! (theSource >> aString))
return Standard_False;
aC->SetRelation(aString);
return Standard_True;
}
//=======================================================================
//function : Paste
//purpose : transient -> persistent (store)
//=======================================================================
void BinMDataStd_RelationDriver::Paste
(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const
{
Handle(TDataStd_Relation) aC =
Handle(TDataStd_Relation)::DownCast(theSource);
// variables
const TDF_AttributeList& aList = aC->GetVariables();
Standard_Integer nbvar = aList.Extent();
theTarget << nbvar;
TDF_ListIteratorOfAttributeList it;
for (it.Initialize(aList); it.More(); it.Next())
{
const Handle(TDF_Attribute)& TV = it.Value();
Standard_Integer aNb;
if (!TV.IsNull())
aNb = theRelocTable.Add(TV);
else
aNb = -1;
theTarget << aNb;
}
// expression
TCollection_ExtendedString aName = aC->Name();
theTarget << aName;
}
|