1 // Copyright (c) 2015 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <StdLPersistent_TreeNode.hxx>
17 //=======================================================================
19 //purpose : Read persistent data from a file
20 //=======================================================================
21 void StdLPersistent_TreeNode::Read (StdObjMgt_ReadData& theReadData)
23 myDynamicData = new dynamic;
24 theReadData >> myDynamicData->First >> myNext >> myDynamicData->TreeID;
27 //=======================================================================
29 //purpose : Write persistent data to a file
30 //=======================================================================
31 void StdLPersistent_TreeNode::Write (StdObjMgt_WriteData& theWriteData) const
33 theWriteData << myDynamicData->First << myNext << myDynamicData->TreeID;
36 //=======================================================================
37 //function : PChildren
38 //purpose : Gets persistent child objects
39 //=======================================================================
40 void StdLPersistent_TreeNode::PChildren
41 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
43 theChildren.Append(myNext);
44 if (!myDynamicData.IsNull())
45 theChildren.Append(myDynamicData->First);
48 //=======================================================================
49 //function : CreateAttribute
50 //purpose : Create an empty transient attribuite
51 //=======================================================================
52 Handle(TDF_Attribute) StdLPersistent_TreeNode::CreateAttribute()
54 Static::CreateAttribute();
55 myTransient->SetTreeID (myDynamicData->TreeID);
59 //=======================================================================
60 //function : ImportAttribute
61 //purpose : Import transient attribuite from the persistent data
62 //=======================================================================
63 void StdLPersistent_TreeNode::ImportAttribute()
67 Handle(StdLPersistent_TreeNode) aChild = myDynamicData->First;
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
77 myDynamicData.Nullify();