1 // Created on: 2017-02-14
2 // Created by: Sergey NIKONOV
3 // Copyright (c) 2008-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 <Message_Messenger.hxx>
17 #include <Standard_Type.hxx>
18 #include <TDF_Attribute.hxx>
19 #include <XCAFDoc_AssemblyItemRef.hxx>
20 #include <XmlMXCAFDoc_AssemblyItemRefDriver.hxx>
21 #include <XmlObjMgt_Persistent.hxx>
23 IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_AssemblyItemRefDriver, XmlMDF_ADriver)
24 IMPLEMENT_DOMSTRING(Path, "path")
25 IMPLEMENT_DOMSTRING(AttrGUID, "guid")
26 IMPLEMENT_DOMSTRING(SubshapeIndex, "subshape_index")
28 //=======================================================================
31 //=======================================================================
32 XmlMXCAFDoc_AssemblyItemRefDriver::XmlMXCAFDoc_AssemblyItemRefDriver(const Handle(Message_Messenger)& theMsgDriver)
33 : XmlMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_AssemblyItemRef)->Name())
37 //=======================================================================
40 //=======================================================================
41 Handle(TDF_Attribute) XmlMXCAFDoc_AssemblyItemRefDriver::NewEmpty() const
43 return new XCAFDoc_AssemblyItemRef();
46 //=======================================================================
49 //=======================================================================
50 Standard_Boolean XmlMXCAFDoc_AssemblyItemRefDriver::Paste(const XmlObjMgt_Persistent& theSource,
51 const Handle(TDF_Attribute)& theTarget,
52 XmlObjMgt_RRelocationTable& /*theRelocTable*/) const
54 const XmlObjMgt_Element& anElement = theSource;
56 XmlObjMgt_DOMString aPath = anElement.getAttribute(::Path());
58 return Standard_False;
60 Handle(XCAFDoc_AssemblyItemRef) aThis = Handle(XCAFDoc_AssemblyItemRef)::DownCast(theTarget);
62 return Standard_False;
64 aThis->SetItem(aPath.GetString());
66 XmlObjMgt_DOMString anAttrGUID = anElement.getAttribute(::AttrGUID());
67 if (anAttrGUID != NULL)
69 Standard_GUID aGUID(anAttrGUID.GetString());
70 aThis->SetGUID(aGUID);
74 XmlObjMgt_DOMString aSubshapeIndex = anElement.getAttribute(::SubshapeIndex());
75 if (aSubshapeIndex != NULL)
77 Standard_Integer anIndex;
78 if (!aSubshapeIndex.GetInteger(anIndex))
79 return Standard_False;
81 aThis->SetSubshapeIndex(anIndex);
88 //=======================================================================
91 //=======================================================================
92 void XmlMXCAFDoc_AssemblyItemRefDriver::Paste(const Handle(TDF_Attribute)& theSource,
93 XmlObjMgt_Persistent& theTarget,
94 XmlObjMgt_SRelocationTable& /*theRelocTable*/) const
96 Handle(XCAFDoc_AssemblyItemRef) aThis = Handle(XCAFDoc_AssemblyItemRef)::DownCast(theSource);
98 XmlObjMgt_DOMString aPath(aThis->GetItem().ToString().ToCString());
99 theTarget.Element().setAttribute(::Path(), aPath);
103 Standard_GUID aGUID = aThis->GetGUID();
104 Standard_Character aGUIDStr[Standard_GUID_SIZE + 1];
105 aGUID.ToCString(aGUIDStr);
106 aGUIDStr[Standard_GUID_SIZE] = '\0';
107 XmlObjMgt_DOMString anAttrGUID(aGUIDStr);
108 theTarget.Element().setAttribute(::AttrGUID(), anAttrGUID);
110 else if (aThis->IsSubshapeIndex())
112 TCollection_AsciiString aSubshapeIndexStr(aThis->GetSubshapeIndex());
113 XmlObjMgt_DOMString aSubshapeIndex(aSubshapeIndexStr.ToCString());
114 theTarget.Element().setAttribute(::SubshapeIndex(), aSubshapeIndex);