0024428: Implementation of LGPL license
[occt.git] / src / MDataStd / MDataStd_TreeNodeStorageDriver.cxx
CommitLineData
b311480e 1// Created on: 1999-06-17
2// Created by: Vladislav ROMASHKO
3// Copyright (c) 1999-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <MDataStd_TreeNodeStorageDriver.ixx>
18
19#include <TDataStd_TreeNode.hxx>
20#include <PDataStd_TreeNode.hxx>
21#include <Standard_NoSuchObject.hxx>
22#include <CDM_MessageDriver.hxx>
23
24MDataStd_TreeNodeStorageDriver::MDataStd_TreeNodeStorageDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ASDriver(theMsgDriver)
25{}
26
27Standard_Integer MDataStd_TreeNodeStorageDriver::VersionNumber() const
28{ return 0; }
29
30Handle(Standard_Type) MDataStd_TreeNodeStorageDriver::SourceType() const
31{ return STANDARD_TYPE(TDataStd_TreeNode); }
32
33Handle(PDF_Attribute) MDataStd_TreeNodeStorageDriver::NewEmpty() const
34{ return new PDataStd_TreeNode(); }
35
36void MDataStd_TreeNodeStorageDriver::Paste(const Handle(TDF_Attribute)& Source,
37 const Handle(PDF_Attribute)& Target,
38 const Handle(MDF_SRelocationTable)& RelocTable) const
39{
40 Handle(TDataStd_TreeNode) S = Handle(TDataStd_TreeNode)::DownCast (Source);
41 Handle(PDataStd_TreeNode) T = Handle(PDataStd_TreeNode)::DownCast (Target);
42
43 Handle (PDataStd_TreeNode) TF;
44 // Only stores myFirst , myNext
45 // When retrieving the function
46 // myFirst is appended to me and the next of myFirst and subsequently the next of the next
47 // are appended to me.
48
49 Handle (TDataStd_TreeNode) F = S->First();
50 if (!F.IsNull ()) {
51 if (!RelocTable->HasRelocation(F, TF)) {
52 Standard_NoSuchObject::Raise("MDataStd_TreeNodeStorageDriver::Paste");
53 }
54 T->SetFirst(TF);
55 }
56
57 F = S->Next();
58 if (!F.IsNull ()) {
59 if (!RelocTable->HasRelocation(F, TF)) {
60 Standard_NoSuchObject::Raise("MDataStd_TreeNodeStorageDriver::Paste");
61 }
62 T->SetNext(TF);
63 }
64 T->SetTreeID(S->ID());
65}