b311480e |
1 | // Created on: 2001-09-04 |
2 | // Created by: Julia DOROVSKIKH |
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 | |
7fd59977 |
16 | |
42cf5bc1 |
17 | #include <CDM_MessageDriver.hxx> |
18 | #include <Standard_Type.hxx> |
19 | #include <TDF_Attribute.hxx> |
7fd59977 |
20 | #include <TDF_Tool.hxx> |
42cf5bc1 |
21 | #include <TFunction_Function.hxx> |
22 | #include <XmlMFunction_FunctionDriver.hxx> |
23 | #include <XmlObjMgt.hxx> |
24 | #include <XmlObjMgt_Persistent.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(XmlMFunction_FunctionDriver,XmlMDF_ADriver) |
7fd59977 |
27 | IMPLEMENT_DOMSTRING (GuidString, "guid") |
28 | IMPLEMENT_DOMSTRING (FailureString, "failure") |
29 | |
30 | //======================================================================= |
31 | //function : XmlMFunction_FunctionDriver |
32 | //purpose : Constructor |
33 | //======================================================================= |
34 | XmlMFunction_FunctionDriver::XmlMFunction_FunctionDriver |
35 | (const Handle(CDM_MessageDriver)& theMsgDriver) |
36 | : XmlMDF_ADriver (theMsgDriver, NULL) |
37 | {} |
38 | |
39 | //======================================================================= |
40 | //function : NewEmpty |
41 | //purpose : |
42 | //======================================================================= |
43 | Handle(TDF_Attribute) XmlMFunction_FunctionDriver::NewEmpty() const |
44 | { |
45 | return (new TFunction_Function()); |
46 | } |
47 | |
48 | //======================================================================= |
49 | //function : Paste |
50 | //purpose : persistent -> transient (retrieve) |
51 | //======================================================================= |
52 | Standard_Boolean XmlMFunction_FunctionDriver::Paste |
53 | (const XmlObjMgt_Persistent& theSource, |
54 | const Handle(TDF_Attribute)& theTarget, |
55 | XmlObjMgt_RRelocationTable& ) const |
56 | { |
57 | Handle(TFunction_Function) aF = Handle(TFunction_Function)::DownCast(theTarget); |
58 | |
59 | // function GUID |
60 | XmlObjMgt_DOMString aGuidDomStr = |
61 | theSource.Element().getAttribute(::GuidString()); |
62 | Standard_CString aGuidStr = (Standard_CString)aGuidDomStr.GetString(); |
63 | if (aGuidStr[0] == '\0') |
64 | { |
65 | WriteMessage ("error retrieving GUID for type TFunction_Function"); |
66 | return Standard_False; |
67 | } |
68 | aF->SetDriverGUID(aGuidStr); |
69 | |
70 | // failure |
71 | Standard_Integer aValue; |
72 | XmlObjMgt_DOMString aFStr = theSource.Element().getAttribute(::FailureString()); |
73 | if (!aFStr.GetInteger(aValue)) |
74 | { |
75 | TCollection_ExtendedString aMessageString = |
76 | TCollection_ExtendedString |
77 | ("Cannot retrieve failure number for TFunction_Function attribute from \"") |
78 | + aFStr + "\""; |
79 | WriteMessage (aMessageString); |
80 | return Standard_False; |
81 | } |
82 | aF->SetFailure(aValue); |
83 | |
84 | return Standard_True; |
85 | } |
86 | |
87 | //======================================================================= |
88 | //function : Paste |
89 | //purpose : transient -> persistent (store) |
90 | //======================================================================= |
91 | void XmlMFunction_FunctionDriver::Paste (const Handle(TDF_Attribute)& theSource, |
92 | XmlObjMgt_Persistent& theTarget, |
93 | XmlObjMgt_SRelocationTable& ) const |
94 | { |
95 | Handle(TFunction_Function) aF = |
96 | Handle(TFunction_Function)::DownCast(theSource); |
97 | if (!aF.IsNull()) |
98 | { |
99 | //convert GUID into attribute value |
100 | Standard_Character aGuidStr [40]; |
101 | Standard_PCharacter pGuidStr; |
102 | // |
103 | pGuidStr=aGuidStr; |
104 | aF->GetDriverGUID().ToCString(pGuidStr); |
105 | theTarget.Element().setAttribute(::GuidString(), aGuidStr); |
106 | |
107 | //integer value of failure |
108 | theTarget.Element().setAttribute(::FailureString(), aF->GetFailure()); |
109 | } |
110 | } |