1 // Created on: 2001-09-04
2 // Created by: Julia DOROVSKIKH
3 // Copyright (c) 2001-2014 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.
17 #include <CDM_MessageDriver.hxx>
18 #include <Standard_Type.hxx>
19 #include <TDF_Attribute.hxx>
20 #include <TDF_Tool.hxx>
21 #include <TFunction_Function.hxx>
22 #include <XmlMFunction_FunctionDriver.hxx>
23 #include <XmlObjMgt.hxx>
24 #include <XmlObjMgt_Persistent.hxx>
26 IMPLEMENT_DOMSTRING (GuidString, "guid")
27 IMPLEMENT_DOMSTRING (FailureString, "failure")
29 //=======================================================================
30 //function : XmlMFunction_FunctionDriver
31 //purpose : Constructor
32 //=======================================================================
33 XmlMFunction_FunctionDriver::XmlMFunction_FunctionDriver
34 (const Handle(CDM_MessageDriver)& theMsgDriver)
35 : XmlMDF_ADriver (theMsgDriver, NULL)
38 //=======================================================================
41 //=======================================================================
42 Handle(TDF_Attribute) XmlMFunction_FunctionDriver::NewEmpty() const
44 return (new TFunction_Function());
47 //=======================================================================
49 //purpose : persistent -> transient (retrieve)
50 //=======================================================================
51 Standard_Boolean XmlMFunction_FunctionDriver::Paste
52 (const XmlObjMgt_Persistent& theSource,
53 const Handle(TDF_Attribute)& theTarget,
54 XmlObjMgt_RRelocationTable& ) const
56 Handle(TFunction_Function) aF = Handle(TFunction_Function)::DownCast(theTarget);
59 XmlObjMgt_DOMString aGuidDomStr =
60 theSource.Element().getAttribute(::GuidString());
61 Standard_CString aGuidStr = (Standard_CString)aGuidDomStr.GetString();
62 if (aGuidStr[0] == '\0')
64 WriteMessage ("error retrieving GUID for type TFunction_Function");
65 return Standard_False;
67 aF->SetDriverGUID(aGuidStr);
70 Standard_Integer aValue;
71 XmlObjMgt_DOMString aFStr = theSource.Element().getAttribute(::FailureString());
72 if (!aFStr.GetInteger(aValue))
74 TCollection_ExtendedString aMessageString =
75 TCollection_ExtendedString
76 ("Cannot retrieve failure number for TFunction_Function attribute from \"")
78 WriteMessage (aMessageString);
79 return Standard_False;
81 aF->SetFailure(aValue);
86 //=======================================================================
88 //purpose : transient -> persistent (store)
89 //=======================================================================
90 void XmlMFunction_FunctionDriver::Paste (const Handle(TDF_Attribute)& theSource,
91 XmlObjMgt_Persistent& theTarget,
92 XmlObjMgt_SRelocationTable& ) const
94 Handle(TFunction_Function) aF =
95 Handle(TFunction_Function)::DownCast(theSource);
98 //convert GUID into attribute value
99 Standard_Character aGuidStr [40];
100 Standard_PCharacter pGuidStr;
103 aF->GetDriverGUID().ToCString(pGuidStr);
104 theTarget.Element().setAttribute(::GuidString(), aGuidStr);
106 //integer value of failure
107 theTarget.Element().setAttribute(::FailureString(), aF->GetFailure());