Integration of OCCT 6.5.0 from SVN
[occt.git] / src / XmlObjMgt / XmlObjMgt_Persistent.cxx
1 // File:        XmlObjMgt_Persistent.cxx
2 // Created:     Tue Jul 17 12:30:46 2001
3 // Author:      Julia DOROVSKIKH <jfa@hotdox.nnov.matra-dtv.fr>
4 // Copyright:   Matra Datavision 2001
5 // History:   AGV 130202: Changed prototype LDOM_Node::getOwnerDocument()
6
7 #include <XmlObjMgt_Persistent.ixx>
8 #include <XmlObjMgt_Document.hxx>
9 #include <XmlObjMgt.hxx>
10 #include <TCollection_AsciiString.hxx>
11
12 //=======================================================================
13 //function : XmlObjMgt_Persistent
14 //purpose  : empty constructor
15 //=======================================================================
16
17 XmlObjMgt_Persistent::XmlObjMgt_Persistent ()
18      : myID (0)
19 {}
20
21 //=======================================================================
22 //function : XmlObjMgt_Persistent
23 //purpose  : 
24 //=======================================================================
25 XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement)
26      : myElement (theElement), myID (0)
27 {
28   if (theElement != NULL)
29     theElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID);
30 }
31
32 //=======================================================================
33 //function : XmlObjMgt_Persistent
34 //purpose  : 
35 //=======================================================================
36 XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement,
37                                             const XmlObjMgt_DOMString& theRef)
38      : myID (0)
39 {
40   if (theElement != NULL) {
41     Standard_Integer aRefID;
42     if (theElement.getAttribute (theRef).GetInteger (aRefID)) {
43       myElement = XmlObjMgt::FindChildElement (theElement, aRefID);
44       if (myElement != NULL)
45         myElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID);
46     }
47   }
48 }
49
50 //=======================================================================
51 //function : CreateElement
52 //purpose  : <theType id="theID"/>
53 //=======================================================================
54 void XmlObjMgt_Persistent::CreateElement (XmlObjMgt_Element&         theParent,
55                                           const XmlObjMgt_DOMString& theType,
56                                           const Standard_Integer     theID)
57 {
58 //AGV  XmlObjMgt_Document& anOwnerDoc =
59 //AGV    (XmlObjMgt_Document&)theParent.getOwnerDocument();
60   XmlObjMgt_Document anOwnerDoc =
61     XmlObjMgt_Document (theParent.getOwnerDocument());
62   myElement = anOwnerDoc.createElement (theType);
63   theParent.appendChild (myElement);
64   SetId (theID);
65 }
66
67 //=======================================================================
68 //function : SetId
69 //purpose  : 
70 //=======================================================================
71 void XmlObjMgt_Persistent::SetId(const Standard_Integer theId)
72 {
73   myID = theId;
74   myElement.setAttribute (XmlObjMgt::IdString(), theId);
75 }