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