b311480e |
1 | // Created on: 2002-10-30 |
2 | // Created by: Michael SAZONOV |
973c2be1 |
3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #include <BinMDF_ReferenceDriver.ixx> |
17 | #include <TDF_Reference.hxx> |
18 | |
19 | //======================================================================= |
20 | //function : BinMDF_ReferenceDriver |
21 | //purpose : Constructor |
22 | //======================================================================= |
23 | |
24 | BinMDF_ReferenceDriver::BinMDF_ReferenceDriver |
25 | (const Handle(CDM_MessageDriver)& theMsgDriver) |
26 | : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDF_Reference)->Name()) |
27 | { |
28 | } |
29 | |
30 | //======================================================================= |
31 | //function : NewEmpty |
32 | //purpose : |
33 | //======================================================================= |
34 | |
35 | Handle(TDF_Attribute) BinMDF_ReferenceDriver::NewEmpty() const |
36 | { |
37 | return new TDF_Reference(); |
38 | } |
39 | |
40 | //======================================================================= |
41 | //function : Paste |
42 | //purpose : persistent -> transient (retrieve) |
43 | //======================================================================= |
44 | |
45 | Standard_Boolean BinMDF_ReferenceDriver::Paste |
46 | (const BinObjMgt_Persistent& theSource, |
47 | const Handle(TDF_Attribute)& theTarget, |
48 | BinObjMgt_RRelocationTable& ) const |
49 | { |
50 | Handle(TDF_Reference) aRef = Handle(TDF_Reference)::DownCast(theTarget); |
51 | |
52 | TDF_Label tLab; // Null label. |
53 | if (!theSource.GetLabel(aRef->Label().Data(), tLab)) |
54 | return Standard_False; |
55 | |
56 | // set referenced label |
57 | aRef->Set(tLab); |
58 | return Standard_True; |
59 | } |
60 | |
61 | //======================================================================= |
62 | //function : Paste |
63 | //purpose : transient -> persistent (store) |
64 | //======================================================================= |
65 | |
66 | void BinMDF_ReferenceDriver::Paste (const Handle(TDF_Attribute)& theSource, |
67 | BinObjMgt_Persistent& theTarget, |
68 | BinObjMgt_SRelocationTable& ) const |
69 | { |
70 | Handle(TDF_Reference) aRef = Handle(TDF_Reference)::DownCast(theSource); |
71 | if (!aRef.IsNull()) { |
72 | const TDF_Label& lab = aRef->Label(); |
73 | const TDF_Label& refLab = aRef->Get(); |
74 | if (!lab.IsNull() && !refLab.IsNull()) { |
75 | if (lab.IsDescendant(refLab.Root())) { // Internal reference |
76 | theTarget << refLab; |
77 | } |
78 | } |
79 | } |
80 | } |