0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- manual
[occt.git] / src / BinMFunction / BinMFunction_GraphNodeDriver.cxx
CommitLineData
b311480e 1// Created on: 2008-05-11
2// Created by: Vlad Romashko
973c2be1 3// Copyright (c) 2008-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
42cf5bc1 16
7fd59977 17#include <BinMDF_ADriver.hxx>
42cf5bc1 18#include <BinMFunction_GraphNodeDriver.hxx>
7fd59977 19#include <BinObjMgt_Persistent.hxx>
20#include <BinObjMgt_RRelocationTable.hxx>
21#include <BinObjMgt_SRelocationTable.hxx>
42cf5bc1 22#include <CDM_MessageDriver.hxx>
23#include <Standard_Type.hxx>
7fd59977 24#include <TColStd_Array1OfInteger.hxx>
25#include <TColStd_MapIteratorOfMapOfInteger.hxx>
42cf5bc1 26#include <TDF_Attribute.hxx>
27#include <TFunction_GraphNode.hxx>
7fd59977 28
29//=======================================================================
30//function : BinMFunction_GraphNodeDriver
31//purpose :
32//=======================================================================
7fd59977 33BinMFunction_GraphNodeDriver::BinMFunction_GraphNodeDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
34: BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TFunction_GraphNode)->Name())
35{
36}
37
38//=======================================================================
39//function : NewEmpty
40//purpose :
41//=======================================================================
42
43Handle(TDF_Attribute) BinMFunction_GraphNodeDriver::NewEmpty() const
44{
45 return new TFunction_GraphNode();
46}
47
48//=======================================================================
49//function : Paste
50//purpose : persistent -> transient (retrieve)
51//=======================================================================
52
53Standard_Boolean BinMFunction_GraphNodeDriver::Paste(const BinObjMgt_Persistent& theSource,
54 const Handle(TDF_Attribute)& theTarget,
55 BinObjMgt_RRelocationTable& ) const
56{
57 Handle(TFunction_GraphNode) GN = Handle(TFunction_GraphNode)::DownCast(theTarget);
58
59 Standard_Integer intStatus, nb_previous, nb_next;
60 if (! (theSource >> intStatus >> nb_previous >> nb_next))
61 return Standard_False;
62
63 // Execution status
64 GN->SetStatus((TFunction_ExecutionStatus) intStatus);
65
66 // Previous functions
67 if (nb_previous)
68 {
69 TColStd_Array1OfInteger aTargetArray(1, nb_previous);
70 theSource.GetIntArray (&aTargetArray(1), nb_previous);
71
72 for (Standard_Integer i = 1; i <= nb_previous; i++)
73 {
74 GN->AddPrevious(aTargetArray.Value(i));
75 }
76 }
77
78 // Next functions
79 if (nb_next)
80 {
81 TColStd_Array1OfInteger aTargetArray(1, nb_next);
82 theSource.GetIntArray (&aTargetArray(1), nb_next);
83
84 for (Standard_Integer i = 1; i <= nb_next; i++)
85 {
86 GN->AddNext(aTargetArray.Value(i));
87 }
88 }
89
90 return Standard_True;
91}
92
93//=======================================================================
94//function : Paste
95//purpose : transient -> persistent (store)
96//=======================================================================
97
98void BinMFunction_GraphNodeDriver::Paste (const Handle(TDF_Attribute)& theSource,
99 BinObjMgt_Persistent& theTarget,
100 BinObjMgt_SRelocationTable& ) const
101{
102 Handle(TFunction_GraphNode) GN = Handle(TFunction_GraphNode)::DownCast(theSource);
103
104 // Execution status
105 theTarget << (Standard_Integer) GN->GetStatus();
106 // Number of previous functions
107 theTarget << GN->GetPrevious().Extent();
108 // Number of next functions
109 theTarget << GN->GetNext().Extent();
110
111 // Previous functions
112 Standard_Integer nb = GN->GetPrevious().Extent();
113 if (nb)
114 {
115 TColStd_Array1OfInteger aSourceArray(1, nb);
116 TColStd_MapIteratorOfMapOfInteger itr(GN->GetPrevious());
117 for (Standard_Integer i = 1; itr.More(); itr.Next(), i++)
118 {
119 aSourceArray.SetValue(i, itr.Key());
120 }
121 Standard_Integer *aPtr = (Standard_Integer *) &aSourceArray(1);
122 theTarget.PutIntArray(aPtr, nb);
123 }
124
125 // Next functions
126 nb = GN->GetNext().Extent();
127 if (nb)
128 {
129 TColStd_Array1OfInteger aSourceArray(1, nb);
130 TColStd_MapIteratorOfMapOfInteger itr(GN->GetNext());
131 for (Standard_Integer i = 1; itr.More(); itr.Next(), i++)
132 {
133 aSourceArray.SetValue(i, itr.Key());
134 }
135 Standard_Integer *aPtr = (Standard_Integer *) &aSourceArray(1);
136 theTarget.PutIntArray(aPtr, nb);
137 }
138}
139