0029590: Coding - avoid usage of Standard_EXPORT attribute for inline methods
[occt.git] / src / StdLPersistent / StdLPersistent_TreeNode.cxx
1 // Copyright (c) 2015 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <StdLPersistent_TreeNode.hxx>
15
16
17 //=======================================================================
18 //function : Read
19 //purpose  : Read persistent data from a file
20 //=======================================================================
21 void StdLPersistent_TreeNode::Read (StdObjMgt_ReadData& theReadData)
22 {
23   myDynamicData = new dynamic;
24   theReadData >> myDynamicData->First >> myNext >> myDynamicData->TreeID;
25 }
26
27 //=======================================================================
28 //function : Write
29 //purpose  : Write persistent data to a file
30 //=======================================================================
31 void StdLPersistent_TreeNode::Write (StdObjMgt_WriteData& theWriteData) const
32 {
33   theWriteData << myDynamicData->First << myNext << myDynamicData->TreeID;
34 }
35
36 //=======================================================================
37 //function : PChildren
38 //purpose  : Gets persistent child objects
39 //=======================================================================
40 void StdLPersistent_TreeNode::PChildren
41   (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
42 {
43   theChildren.Append(myNext);
44   if (!myDynamicData.IsNull())
45     theChildren.Append(myDynamicData->First);
46 }
47
48 //=======================================================================
49 //function : CreateAttribute
50 //purpose  : Create an empty transient attribuite
51 //=======================================================================
52 Handle(TDF_Attribute) StdLPersistent_TreeNode::CreateAttribute()
53 {
54   Static::CreateAttribute();
55   myTransient->SetTreeID (myDynamicData->TreeID);
56   return myTransient;
57 }
58
59 //=======================================================================
60 //function : ImportAttribute
61 //purpose  : Import transient attribuite from the persistent data
62 //=======================================================================
63 void StdLPersistent_TreeNode::ImportAttribute()
64 {
65   if (myDynamicData)
66   {
67     Handle(StdLPersistent_TreeNode) aChild = myDynamicData->First;
68     while (aChild)
69     {
70       if (aChild->myTransient)
71         myTransient->Append(aChild->myTransient);
72       StdLPersistent_TreeNode* aCurr = aChild.get();
73       aChild = aChild->myNext;
74       aCurr->myNext.Nullify(); // this reference is no longer needed
75     }
76
77     myDynamicData.Nullify();
78   }
79 }