b311480e |
1 | // Created on: 2004-11-24 |
2 | // Created by: Edward AGAPOV |
973c2be1 |
3 | // Copyright (c) 2004-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
973c2be1 |
7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public 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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
7fd59977 |
16 | // The original implementation Copyright: (C) RINA S.p.A |
17 | |
18 | |
19 | #include <CDM_MessageDriver.hxx> |
20 | #include "XmlTObjDrivers_ObjectDriver.hxx" |
21 | #include <TObj_TObject.hxx> |
22 | #include <TObj_Persistence.hxx> |
23 | #include <XmlObjMgt_Persistent.hxx> |
24 | #include <XmlObjMgt_RRelocationTable.hxx> |
25 | #include <XmlObjMgt.hxx> |
26 | |
27 | IMPLEMENT_STANDARD_HANDLE(XmlTObjDrivers_ObjectDriver,XmlMDF_ADriver) |
28 | IMPLEMENT_STANDARD_RTTIEXT(XmlTObjDrivers_ObjectDriver,XmlMDF_ADriver); |
29 | |
30 | //======================================================================= |
31 | //function : XmlTObjDrivers_ObjectDriver |
32 | //purpose : constructor |
33 | //======================================================================= |
34 | |
35 | XmlTObjDrivers_ObjectDriver::XmlTObjDrivers_ObjectDriver |
36 | (const Handle(CDM_MessageDriver)& theMessageDriver) |
37 | : XmlMDF_ADriver( theMessageDriver, NULL) |
38 | { |
39 | } |
40 | |
41 | //======================================================================= |
42 | //function : NewEmpty |
43 | //purpose : Creates a new attribute |
44 | //======================================================================= |
45 | |
46 | Handle(TDF_Attribute) XmlTObjDrivers_ObjectDriver::NewEmpty() const |
47 | { |
48 | return new TObj_TObject; |
49 | } |
50 | |
51 | //======================================================================= |
52 | //function : Paste |
53 | //purpose : Translate the contents of <aSource> and put it |
54 | // into <aTarget>, using the relocation table |
55 | // <aRelocTable> to keep the sharings. |
56 | //======================================================================= |
57 | |
58 | Standard_Boolean XmlTObjDrivers_ObjectDriver::Paste |
59 | (const XmlObjMgt_Persistent& Source, |
60 | const Handle(TDF_Attribute)& Target, |
61 | XmlObjMgt_RRelocationTable& /*RelocTable*/) const |
62 | { |
63 | TCollection_ExtendedString aString; |
64 | if (XmlObjMgt::GetExtendedString (Source, aString)) |
65 | { |
66 | TCollection_AsciiString anAscii (aString); |
67 | Handle(TObj_Object) anObject = |
68 | TObj_Persistence::CreateNewObject(anAscii.ToCString(),Target->Label()); |
69 | Handle(TObj_TObject)::DownCast (Target) ->Set( anObject ); |
70 | return Standard_True; |
71 | } |
72 | WriteMessage("error retrieving ExtendedString for type TObj_TModel"); |
73 | return Standard_False; |
74 | } |
75 | |
76 | //======================================================================= |
77 | //function : Paste |
78 | //purpose : Translate the contents of <aSource> and put it |
79 | // into <aTarget>, using the relocation table |
80 | // <aRelocTable> to keep the sharings. |
81 | // anObject is stored as a Name of class derived from TObj_Object |
82 | //======================================================================= |
83 | |
84 | void XmlTObjDrivers_ObjectDriver::Paste |
85 | (const Handle(TDF_Attribute)& Source, |
86 | XmlObjMgt_Persistent& Target, |
87 | XmlObjMgt_SRelocationTable& /*RelocTable*/) const |
88 | { |
89 | Handle(TObj_TObject) aTObj = |
90 | Handle(TObj_TObject)::DownCast( Source ); |
91 | Handle(TObj_Object) anIObject = aTObj->Get(); |
92 | |
93 | XmlObjMgt::SetExtendedString (Target, anIObject->DynamicType()->Name()); |
94 | } |
95 | |