0025394: Make it possible to store/retrieve the list-based attributes containing...
[occt.git] / src / MDataStd / MDataStd_RealListStorageDriver.cxx
1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-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_RealListStorageDriver.ixx>
17 #include <PDataStd_RealList.hxx>
18 #include <TDataStd_RealList.hxx>
19 #include <MDataStd.hxx>
20 #include <CDM_MessageDriver.hxx>
21 #include <TColStd_ListIteratorOfListOfReal.hxx>
22
23 //=======================================================================
24 //function : MDataStd_RealListStorageDriver
25 //purpose  : 
26 //=======================================================================
27 MDataStd_RealListStorageDriver::MDataStd_RealListStorageDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ASDriver(theMsgDriver)
28 {
29
30 }
31
32 //=======================================================================
33 //function : VersionNumber
34 //purpose  : 
35 //=======================================================================
36 Standard_Integer MDataStd_RealListStorageDriver::VersionNumber() const
37
38   return 0;
39 }
40
41
42 //=======================================================================
43 //function : SourceType
44 //purpose  : 
45 //=======================================================================
46 Handle(Standard_Type) MDataStd_RealListStorageDriver::SourceType() const
47 {
48   static Handle(Standard_Type) sourceType = STANDARD_TYPE(TDataStd_RealList);
49   return sourceType;
50 }
51
52 //=======================================================================
53 //function : NewEmpty
54 //purpose  : 
55 //=======================================================================
56 Handle(PDF_Attribute) MDataStd_RealListStorageDriver::NewEmpty() const 
57 {
58   return new PDataStd_RealList();
59 }
60
61 //=======================================================================
62 //function : Paste
63 //purpose  : 
64 //=======================================================================
65 void MDataStd_RealListStorageDriver::Paste(const Handle(TDF_Attribute)&  Source,
66                                            const Handle(PDF_Attribute)&        Target,
67                                            const Handle(MDF_SRelocationTable)& /*RelocTable*/) const
68 {
69   const Handle(TDataStd_RealList) S = Handle(TDataStd_RealList)::DownCast (Source);
70   const Handle(PDataStd_RealList) T = Handle(PDataStd_RealList)::DownCast (Target);
71   
72   Standard_Integer lower(1), upper = S->Extent();
73   if(upper == 0) {
74     lower = 0;
75     T->Init(lower, upper);
76   }
77   else if (upper >= lower)
78   {
79     T->Init(lower, upper);
80     TColStd_ListIteratorOfListOfReal itr(S->List());
81     for (Standard_Integer i = lower; itr.More(); itr.Next(), i++) {
82       T->SetValue(i, itr.Value());
83     }
84   }
85 }