0024927: Getting rid of "Persistent" functionality -- Code
[occt.git] / src / MDataStd / MDataStd_ByteArrayRetrievalDriver_1.cxx
1 // Created on: 2008-03-27
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2008-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <MDataStd_ByteArrayRetrievalDriver_1.ixx>
17
18 #include <PDataStd_ByteArray.hxx>
19 #include <PDataStd_ByteArray_1.hxx>
20 #include <TDataStd_ByteArray.hxx>
21 #include <MDataStd.hxx>
22 #include <CDM_MessageDriver.hxx>
23 #include <TColStd_HArray1OfByte.hxx>
24 #include <PColStd_HArray1OfInteger.hxx>
25
26 //=======================================================================
27 //function : MDataStd_ByteArrayRetrievalDriver_1
28 //purpose  : 
29 //=======================================================================
30 MDataStd_ByteArrayRetrievalDriver_1::MDataStd_ByteArrayRetrievalDriver_1(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
31 {
32
33 }
34
35 //=======================================================================
36 //function : VersionNumber
37 //purpose  : 
38 //=======================================================================
39 Standard_Integer MDataStd_ByteArrayRetrievalDriver_1::VersionNumber() const
40
41   return 1; 
42 }
43
44 //=======================================================================
45 //function : SourceType
46 //purpose  : 
47 //=======================================================================
48 Handle(Standard_Type) MDataStd_ByteArrayRetrievalDriver_1::SourceType() const
49 {
50   static Handle(Standard_Type) sourceType = STANDARD_TYPE(PDataStd_ByteArray_1);
51   return sourceType;
52 }
53
54 //=======================================================================
55 //function : NewEmpty
56 //purpose  : 
57 //=======================================================================
58 Handle(TDF_Attribute) MDataStd_ByteArrayRetrievalDriver_1::NewEmpty () const 
59 {
60   return new TDataStd_ByteArray();
61 }
62
63 //=======================================================================
64 //function : Paste
65 //purpose  : 
66 //=======================================================================
67 void MDataStd_ByteArrayRetrievalDriver_1::Paste(const Handle(PDF_Attribute)& Source,
68                                               const Handle(TDF_Attribute)& Target,
69                                               const Handle(MDF_RRelocationTable)& ) const
70 {
71   Handle(PDataStd_ByteArray_1) S = Handle(PDataStd_ByteArray_1)::DownCast (Source);
72   Handle(TDataStd_ByteArray) T = Handle(TDataStd_ByteArray)::DownCast (Target);
73
74   if (!S->Get().IsNull()) {
75     const Handle(PColStd_HArray1OfInteger)& pvalues = S->Get();
76     Handle(TColStd_HArray1OfByte) tvalues = 
77       new TColStd_HArray1OfByte(pvalues->Lower(), pvalues->Upper());
78     Standard_Integer i = pvalues->Lower(), upper = pvalues->Upper();
79     for (; i <= upper; i++) {
80       Standard_Byte pvalue = (Standard_Byte) pvalues->Value(i);
81       tvalues->SetValue(i, pvalue);
82     }
83     T->ChangeArray(tvalues, Standard_False);
84     T->SetDelta(S->GetDelta());
85   }
86 }