0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / BinMDataStd / BinMDataStd_IntegerArrayDriver.cxx
CommitLineData
b311480e 1// Created on: 2002-10-31
2// Created by: Michael SAZONOV
973c2be1 3// Copyright (c) 2002-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 <BinMDataStd.hxx>
42cf5bc1 18#include <BinMDataStd_IntegerArrayDriver.hxx>
19#include <BinObjMgt_Persistent.hxx>
20#include <CDM_MessageDriver.hxx>
21#include <Standard_Type.hxx>
22#include <TColStd_HArray1OfInteger.hxx>
23#include <TDataStd_IntegerArray.hxx>
24#include <TDF_Attribute.hxx>
7fd59977 25
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_IntegerArrayDriver,BinMDF_ADriver)
27
7fd59977 28//=======================================================================
29//function : BinMDataStd_IntegerArrayDriver
30//purpose : Constructor
31//=======================================================================
7fd59977 32BinMDataStd_IntegerArrayDriver::BinMDataStd_IntegerArrayDriver
33 (const Handle(CDM_MessageDriver)& theMsgDriver)
34 : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataStd_IntegerArray)->Name())
35{
36}
37
38//=======================================================================
39//function : NewEmpty
40//purpose :
41//=======================================================================
42
43Handle(TDF_Attribute) BinMDataStd_IntegerArrayDriver::NewEmpty() const
44{
45 return new TDataStd_IntegerArray();
46}
47
48//=======================================================================
49//function : Paste
50//purpose : persistent -> transient (retrieve)
51//=======================================================================
52
53Standard_Boolean BinMDataStd_IntegerArrayDriver::Paste
54 (const BinObjMgt_Persistent& theSource,
55 const Handle(TDF_Attribute)& theTarget,
56 BinObjMgt_RRelocationTable& ) const
57{
58 Standard_Integer aFirstInd, aLastInd;
59 if (! (theSource >> aFirstInd >> aLastInd))
60 return Standard_False;
61 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
62 if (aLength <= 0)
63 return Standard_False;
64
65 Handle(TDataStd_IntegerArray) anAtt =
66 Handle(TDataStd_IntegerArray)::DownCast(theTarget);
67 anAtt->Init(aFirstInd, aLastInd);
68 TColStd_Array1OfInteger& aTargetArray = anAtt->Array()->ChangeArray1();
69 if(!theSource.GetIntArray (&aTargetArray(aFirstInd), aLength))
70 return Standard_False;
71 Standard_Boolean aDelta(Standard_False);
7fd59977 72 if(BinMDataStd::DocumentVersion() > 2) {
73 Standard_Byte aDeltaValue;
74 if (! (theSource >> aDeltaValue))
75 return Standard_False;
76 else
77 aDelta = (Standard_Boolean)aDeltaValue;
78 }
0797d9d3 79#ifdef OCCT_DEBUG
7fd59977 80 else if(BinMDataStd::DocumentVersion() == -1)
81 cout << "Current DocVersion field is not initialized. " <<endl;
82#endif
83 anAtt->SetDelta(aDelta);
84 return Standard_True;
85}
86
87//=======================================================================
88//function : Paste
89//purpose : transient -> persistent (store)
90//=======================================================================
91
92void BinMDataStd_IntegerArrayDriver::Paste
93 (const Handle(TDF_Attribute)& theSource,
94 BinObjMgt_Persistent& theTarget,
95 BinObjMgt_SRelocationTable& ) const
96{
97 Handle(TDataStd_IntegerArray) anAtt =
98 Handle(TDataStd_IntegerArray)::DownCast(theSource);
99 const TColStd_Array1OfInteger& aSourceArray = anAtt->Array()->Array1();
100 const Standard_Integer aFirstInd = aSourceArray.Lower();
101 const Standard_Integer aLastInd = aSourceArray.Upper();
102 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
103 theTarget << aFirstInd << aLastInd;
104 Standard_Integer *aPtr = (Standard_Integer *) &aSourceArray(aFirstInd);
105 theTarget.PutIntArray (aPtr, aLength);
106 theTarget << (Standard_Byte)anAtt->GetDelta();
107}