summaryrefslogtreecommitdiff
path: root/src/BinMDF/BinMDF_ReferenceDriver.cxx
blob: ca903ab06177bf949ee50bb6571d50b314126ba3 (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
// File:      BinMDF_ReferenceDriver.cxx
// Created:   30.10.02 12:52:35
// Author:    Michael SAZONOV
// Copyright: Open CASCADE 2002

#include <BinMDF_ReferenceDriver.ixx>
#include <TDF_Reference.hxx>

//=======================================================================
//function : BinMDF_ReferenceDriver
//purpose  : Constructor
//=======================================================================

BinMDF_ReferenceDriver::BinMDF_ReferenceDriver
                        (const Handle(CDM_MessageDriver)& theMsgDriver)
     : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDF_Reference)->Name())
{
}

//=======================================================================
//function : NewEmpty
//purpose  : 
//=======================================================================

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

//=======================================================================
//function : Paste
//purpose  : persistent -> transient (retrieve)
//=======================================================================

Standard_Boolean BinMDF_ReferenceDriver::Paste
                (const BinObjMgt_Persistent&   theSource,
                 const Handle(TDF_Attribute)&  theTarget,
                 BinObjMgt_RRelocationTable&   ) const
{
  Handle(TDF_Reference) aRef = Handle(TDF_Reference)::DownCast(theTarget);

  TDF_Label tLab; // Null label.
  if (!theSource.GetLabel(aRef->Label().Data(), tLab))
    return Standard_False;

  // set referenced label
  aRef->Set(tLab);
  return Standard_True;
}

//=======================================================================
//function : Paste
//purpose  : transient -> persistent (store)
//=======================================================================

void BinMDF_ReferenceDriver::Paste (const Handle(TDF_Attribute)&  theSource,
                                    BinObjMgt_Persistent&         theTarget,
                                    BinObjMgt_SRelocationTable&   ) const
{
  Handle(TDF_Reference) aRef = Handle(TDF_Reference)::DownCast(theSource);
  if (!aRef.IsNull()) {
    const TDF_Label& lab = aRef->Label();
    const TDF_Label& refLab = aRef->Get();
    if (!lab.IsNull() && !refLab.IsNull()) {
      if (lab.IsDescendant(refLab.Root())) {   // Internal reference
        theTarget << refLab;
      }
    }
  }
}