0024428: Implementation of LGPL license
[occt.git] / src / MDataStd / MDataStd_IntPackedMapRetrievalDriver_1.cxx
CommitLineData
b311480e 1// Created on: 2008-03-28
2// Created by: Sergey ZARITCHNY
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//
973c2be1 7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public version 2.1 as published
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
16#include <MDataStd_IntPackedMapRetrievalDriver_1.ixx>
17#include <PDataStd_IntPackedMap.hxx>
18#include <PDataStd_IntPackedMap_1.hxx>
19#include <TDataStd_IntPackedMap.hxx>
20#include <CDM_MessageDriver.hxx>
21#include <TColStd_HPackedMapOfInteger.hxx>
22#include <TCollection_ExtendedString.hxx>
23
24//=======================================================================
25//function : MDataStd_IntPackedMapRetrievalDriver_1
26//purpose : Constructor
27//=======================================================================
28MDataStd_IntPackedMapRetrievalDriver_1::MDataStd_IntPackedMapRetrievalDriver_1
29 (const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
30{
31}
32//=======================================================================
33//function : VersionNumber
34//purpose :
35//=======================================================================
36Standard_Integer MDataStd_IntPackedMapRetrievalDriver_1::VersionNumber() const
37{ return 1; }
38
39//=======================================================================
40//function : SourceType
41//purpose :
42//=======================================================================
43Handle(Standard_Type) MDataStd_IntPackedMapRetrievalDriver_1::SourceType() const
44{ return STANDARD_TYPE(PDataStd_IntPackedMap_1); }
45
46//=======================================================================
47//function : NewEmpty
48//purpose :
49//=======================================================================
50Handle(TDF_Attribute) MDataStd_IntPackedMapRetrievalDriver_1::NewEmpty() const
51{ return new TDataStd_IntPackedMap (); }
52
53//=======================================================================
54//function : Paste
55//purpose :
56//=======================================================================
57void MDataStd_IntPackedMapRetrievalDriver_1::Paste(
58 const Handle(PDF_Attribute)& Source,
59 const Handle(TDF_Attribute)& Target,
60 const Handle(MDF_RRelocationTable)& ) const
61{
62 Handle(PDataStd_IntPackedMap_1) aS =
63 Handle(PDataStd_IntPackedMap_1)::DownCast (Source);
64 Handle(TDataStd_IntPackedMap) aT =
65 Handle(TDataStd_IntPackedMap)::DownCast (Target);
66 if(!aS.IsNull() && !aT.IsNull()) {
67 if(!aS->IsEmpty()) {
68 Handle(TColStd_HPackedMapOfInteger) aHMap = new TColStd_HPackedMapOfInteger ();
69 Standard_Integer aKey;
70 for(Standard_Integer i = aS->Lower(); i<= aS->Upper() ; i++) {
71 aKey = aS->GetValue(i);
72 if(!aHMap->ChangeMap().Add( aKey )) {
73 WriteMessage(
74 TCollection_ExtendedString("error retrieving integer mamaber of the attribute TDataStd_IntPackedMap"));
75 return;
76 }
77 }
78 aT->ChangeMap(aHMap);
79 }
80 aT->SetDelta(aS->GetDelta());
81 } else
82 WriteMessage(TCollection_ExtendedString("error retrieving attribute TDataStd_IntPackedMap"));
83}