b311480e |
1 | // Created on: 2001-08-24 |
2 | // Created by: Alexnder GRIGORIEV |
973c2be1 |
3 | // Copyright (c) 2001-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 | |
42cf5bc1 |
16 | |
83ae3591 |
17 | #include <Message_Messenger.hxx> |
42cf5bc1 |
18 | #include <Standard_Type.hxx> |
7fd59977 |
19 | #include <TDataStd_Variable.hxx> |
42cf5bc1 |
20 | #include <TDF_Attribute.hxx> |
21 | #include <XmlMDataStd_VariableDriver.hxx> |
22 | #include <XmlObjMgt_Persistent.hxx> |
7fd59977 |
23 | |
92efcf78 |
24 | IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_VariableDriver,XmlMDF_ADriver) |
7fd59977 |
25 | IMPLEMENT_DOMSTRING (IsConstString, "isconst") |
26 | IMPLEMENT_DOMSTRING (UnitString, "unit") |
27 | IMPLEMENT_DOMSTRING (ConstString, "true") |
28 | |
29 | //======================================================================= |
30 | //function : XmlMDataStd_VariableDriver |
31 | //purpose : Constructor |
32 | //======================================================================= |
33 | XmlMDataStd_VariableDriver::XmlMDataStd_VariableDriver |
83ae3591 |
34 | (const Handle(Message_Messenger)& theMsgDriver) |
7fd59977 |
35 | : XmlMDF_ADriver (theMsgDriver, NULL) |
36 | {} |
37 | |
38 | //======================================================================= |
39 | //function : NewEmpty |
40 | //purpose : |
41 | //======================================================================= |
42 | Handle(TDF_Attribute) XmlMDataStd_VariableDriver::NewEmpty() const |
43 | { |
44 | return (new TDataStd_Variable()); |
45 | } |
46 | |
47 | //======================================================================= |
48 | //function : Paste |
49 | //purpose : |
50 | //======================================================================= |
51 | Standard_Boolean XmlMDataStd_VariableDriver::Paste |
52 | (const XmlObjMgt_Persistent& theSource, |
53 | const Handle(TDF_Attribute)& theTarget, |
54 | XmlObjMgt_RRelocationTable& ) const |
55 | { |
56 | Handle(TDataStd_Variable) aV = Handle(TDataStd_Variable)::DownCast(theTarget); |
57 | |
58 | XmlObjMgt_DOMString aStr = |
59 | theSource.Element().getAttribute(::IsConstString()); |
60 | aV->Constant (aStr != NULL); |
61 | |
62 | aStr = theSource.Element().getAttribute(::UnitString()); |
63 | aV->Unit(aStr); |
64 | return Standard_True; |
65 | } |
66 | |
67 | //======================================================================= |
68 | //function : Paste |
69 | //purpose : |
70 | //======================================================================= |
71 | void XmlMDataStd_VariableDriver::Paste (const Handle(TDF_Attribute)& theSource, |
72 | XmlObjMgt_Persistent& theTarget, |
73 | XmlObjMgt_SRelocationTable& ) const |
74 | { |
75 | Handle(TDataStd_Variable) aV = Handle(TDataStd_Variable)::DownCast(theSource); |
76 | if (aV->IsConstant()) |
77 | theTarget.Element().setAttribute (::IsConstString(), ::ConstString()); |
78 | theTarget.Element().setAttribute(::UnitString(), aV->Unit().ToCString()); |
79 | } |