0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[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
92efcf78 29IMPLEMENT_STANDARD_RTTIEXT(BinMFunction_GraphNodeDriver,BinMDF_ADriver)
30
7fd59977 31//=======================================================================
32//function : BinMFunction_GraphNodeDriver
33//purpose :
34//=======================================================================
7fd59977 35BinMFunction_GraphNodeDriver::BinMFunction_GraphNodeDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
36: BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TFunction_GraphNode)->Name())
37{
38}
39
40//=======================================================================
41//function : NewEmpty
42//purpose :
43//=======================================================================
44
45Handle(TDF_Attribute) BinMFunction_GraphNodeDriver::NewEmpty() const
46{
47 return new TFunction_GraphNode();
48}
49
50//=======================================================================
51//function : Paste
52//purpose : persistent -> transient (retrieve)
53//=======================================================================
54
55Standard_Boolean BinMFunction_GraphNodeDriver::Paste(const BinObjMgt_Persistent& theSource,
56 const Handle(TDF_Attribute)& theTarget,
57 BinObjMgt_RRelocationTable& ) const
58{
59 Handle(TFunction_GraphNode) GN = Handle(TFunction_GraphNode)::DownCast(theTarget);
60
61 Standard_Integer intStatus, nb_previous, nb_next;
62 if (! (theSource >> intStatus >> nb_previous >> nb_next))
63 return Standard_False;
64
65 // Execution status
66 GN->SetStatus((TFunction_ExecutionStatus) intStatus);
67
68 // Previous functions
69 if (nb_previous)
70 {
71 TColStd_Array1OfInteger aTargetArray(1, nb_previous);
72 theSource.GetIntArray (&aTargetArray(1), nb_previous);
73
74 for (Standard_Integer i = 1; i <= nb_previous; i++)
75 {
76 GN->AddPrevious(aTargetArray.Value(i));
77 }
78 }
79
80 // Next functions
81 if (nb_next)
82 {
83 TColStd_Array1OfInteger aTargetArray(1, nb_next);
84 theSource.GetIntArray (&aTargetArray(1), nb_next);
85
86 for (Standard_Integer i = 1; i <= nb_next; i++)
87 {
88 GN->AddNext(aTargetArray.Value(i));
89 }
90 }
91
92 return Standard_True;
93}
94
95//=======================================================================
96//function : Paste
97//purpose : transient -> persistent (store)
98//=======================================================================
99
100void BinMFunction_GraphNodeDriver::Paste (const Handle(TDF_Attribute)& theSource,
101 BinObjMgt_Persistent& theTarget,
102 BinObjMgt_SRelocationTable& ) const
103{
104 Handle(TFunction_GraphNode) GN = Handle(TFunction_GraphNode)::DownCast(theSource);
105
106 // Execution status
107 theTarget << (Standard_Integer) GN->GetStatus();
108 // Number of previous functions
109 theTarget << GN->GetPrevious().Extent();
110 // Number of next functions
111 theTarget << GN->GetNext().Extent();
112
113 // Previous functions
114 Standard_Integer nb = GN->GetPrevious().Extent();
115 if (nb)
116 {
117 TColStd_Array1OfInteger aSourceArray(1, nb);
118 TColStd_MapIteratorOfMapOfInteger itr(GN->GetPrevious());
119 for (Standard_Integer i = 1; itr.More(); itr.Next(), i++)
120 {
121 aSourceArray.SetValue(i, itr.Key());
122 }
123 Standard_Integer *aPtr = (Standard_Integer *) &aSourceArray(1);
124 theTarget.PutIntArray(aPtr, nb);
125 }
126
127 // Next functions
128 nb = GN->GetNext().Extent();
129 if (nb)
130 {
131 TColStd_Array1OfInteger aSourceArray(1, nb);
132 TColStd_MapIteratorOfMapOfInteger itr(GN->GetNext());
133 for (Standard_Integer i = 1; itr.More(); itr.Next(), i++)
134 {
135 aSourceArray.SetValue(i, itr.Key());
136 }
137 Standard_Integer *aPtr = (Standard_Integer *) &aSourceArray(1);
138 theTarget.PutIntArray(aPtr, nb);
139 }
140}
141