1 // Created on: 2007-08-27
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <MDataStd_IntPackedMapRetrievalDriver.ixx>
17 #include <PDataStd_IntPackedMap.hxx>
18 #include <TDataStd_IntPackedMap.hxx>
19 #include <CDM_MessageDriver.hxx>
20 #include <TColStd_HPackedMapOfInteger.hxx>
21 #include <TCollection_ExtendedString.hxx>
23 //=======================================================================
24 //function : MDataStd_IntPackedMapRetrievalDriver
25 //purpose : Constructor
26 //=======================================================================
27 MDataStd_IntPackedMapRetrievalDriver::MDataStd_IntPackedMapRetrievalDriver
28 (const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
31 //=======================================================================
32 //function : VersionNumber
34 //=======================================================================
35 Standard_Integer MDataStd_IntPackedMapRetrievalDriver::VersionNumber() const
38 //=======================================================================
39 //function : SourceType
41 //=======================================================================
42 Handle(Standard_Type) MDataStd_IntPackedMapRetrievalDriver::SourceType() const
43 { return STANDARD_TYPE(PDataStd_IntPackedMap); }
45 //=======================================================================
48 //=======================================================================
49 Handle(TDF_Attribute) MDataStd_IntPackedMapRetrievalDriver::NewEmpty() const
50 { return new TDataStd_IntPackedMap (); }
52 //=======================================================================
55 //=======================================================================
56 void MDataStd_IntPackedMapRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,
57 const Handle(TDF_Attribute)& Target,const Handle(MDF_RRelocationTable)& ) const
59 Handle(PDataStd_IntPackedMap) aS = Handle(PDataStd_IntPackedMap)::DownCast (Source);
60 Handle(TDataStd_IntPackedMap) aT = Handle(TDataStd_IntPackedMap)::DownCast (Target);
61 if(!aS.IsNull() && !aT.IsNull()) {
63 Handle(TColStd_HPackedMapOfInteger) aHMap = new TColStd_HPackedMapOfInteger ();
64 Standard_Integer aKey;
65 for(Standard_Integer i = aS->Lower(); i<= aS->Upper() ; i++) {
66 aKey = aS->GetValue(i);
67 if(!aHMap->ChangeMap().Add( aKey )) {
69 TCollection_ExtendedString("error retrieving integer mamaber of the attribute TDataStd_IntPackedMap"));
76 WriteMessage(TCollection_ExtendedString("error retrieving attribute TDataStd_IntPackedMap"));