1 // Created on: 2017-02-16
2 // Created by: Eugeny NIKONOV
3 // Copyright (c) 2005-2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <BinObjMgt_Persistent.hxx>
17 #include <Message_Messenger.hxx>
18 #include <Standard_Type.hxx>
19 #include <TDF_Attribute.hxx>
20 #include <BinMXCAFDoc_AssemblyItemRefDriver.hxx>
21 #include <XCAFDoc_AssemblyItemRef.hxx>
23 IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_AssemblyItemRefDriver, BinMDF_ADriver)
25 //=======================================================================
28 //=======================================================================
29 BinMXCAFDoc_AssemblyItemRefDriver::BinMXCAFDoc_AssemblyItemRefDriver(const Handle(Message_Messenger)& theMsgDriver)
30 : BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_AssemblyItemRef)->Name())
35 //=======================================================================
38 //=======================================================================
39 Handle(TDF_Attribute) BinMXCAFDoc_AssemblyItemRefDriver::NewEmpty() const
41 return new XCAFDoc_AssemblyItemRef();
44 //=======================================================================
47 //=======================================================================
48 Standard_Boolean BinMXCAFDoc_AssemblyItemRefDriver::Paste(const BinObjMgt_Persistent& theSource,
49 const Handle(TDF_Attribute)& theTarget,
50 BinObjMgt_RRelocationTable& /*theRelocTable*/) const
52 Handle(XCAFDoc_AssemblyItemRef) aThis = Handle(XCAFDoc_AssemblyItemRef)::DownCast(theTarget);
54 return Standard_False;
56 TCollection_AsciiString aPathStr;
57 if (!(theSource >> aPathStr))
58 return Standard_False;
60 aThis->SetItem(aPathStr);
62 Standard_Integer anExtraRef = 0;
63 if (!(theSource >> anExtraRef))
64 return Standard_False;
69 if (!(theSource >> aGUID))
70 return Standard_False;
72 aThis->SetGUID(aGUID);
74 else if (anExtraRef == 2)
76 Standard_Integer aSubshapeIndex;
77 if (!(theSource >> aSubshapeIndex))
78 return Standard_False;
80 aThis->SetSubshapeIndex(aSubshapeIndex);
86 //=======================================================================
89 //=======================================================================
90 void BinMXCAFDoc_AssemblyItemRefDriver::Paste(const Handle(TDF_Attribute)& theSource,
91 BinObjMgt_Persistent& theTarget,
92 BinObjMgt_SRelocationTable& /*theRelocTable*/) const
94 Handle(XCAFDoc_AssemblyItemRef) aThis = Handle(XCAFDoc_AssemblyItemRef)::DownCast(theSource);
97 theTarget << aThis->GetItem().ToString();
100 theTarget << Standard_Integer(1);
101 theTarget << aThis->GetGUID();
103 else if (aThis->IsSubshapeIndex())
105 theTarget << Standard_Integer(2);
106 theTarget << aThis->GetSubshapeIndex();
109 theTarget << Standard_Integer(0);