0022651: Impossible to build OCC as static library due to using Standard_EXPORT inste...
[occt.git] / src / StdLPersistent / StdLPersistent_TreeNode.cxx
CommitLineData
7ed7467d 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
ff205346 14#include <StdLPersistent_TreeNode.hxx>
7ed7467d 15
7ed7467d 16
17//=======================================================================
18//function : Read
19//purpose : Read persistent data from a file
20//=======================================================================
ff205346 21void StdLPersistent_TreeNode::Read (StdObjMgt_ReadData& theReadData)
22{
23 myDynamicData = new dynamic;
24 theReadData >> myDynamicData->First >> myNext >> myDynamicData->TreeID;
25}
26
27//=======================================================================
ec964372 28//function : Write
29//purpose : Write persistent data to a file
30//=======================================================================
31void 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//=======================================================================
40void 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//=======================================================================
ff205346 49//function : CreateAttribute
50//purpose : Create an empty transient attribuite
51//=======================================================================
52Handle(TDF_Attribute) StdLPersistent_TreeNode::CreateAttribute()
7ed7467d 53{
ff205346 54 Static::CreateAttribute();
55 myTransient->SetTreeID (myDynamicData->TreeID);
56 return myTransient;
7ed7467d 57}
58
59//=======================================================================
60//function : ImportAttribute
61//purpose : Import transient attribuite from the persistent data
62//=======================================================================
ff205346 63void StdLPersistent_TreeNode::ImportAttribute()
7ed7467d 64{
ff205346 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 }
7ed7467d 76
ff205346 77 myDynamicData.Nullify();
78 }
7ed7467d 79}