1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
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.
17 #include <BinMDataStd_ReferenceArrayDriver.hxx>
18 #include <BinMDataStd.hxx>
19 #include <BinObjMgt_Persistent.hxx>
20 #include <Message_Messenger.hxx>
21 #include <Standard_Type.hxx>
22 #include <TDataStd_ReferenceArray.hxx>
23 #include <TDF_Attribute.hxx>
24 #include <TDF_Label.hxx>
25 #include <TDF_Tool.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_ReferenceArrayDriver,BinMDF_ADriver)
29 //=======================================================================
30 //function : BinMDataStd_ReferenceArrayDriver
31 //purpose : Constructor
32 //=======================================================================
33 BinMDataStd_ReferenceArrayDriver::BinMDataStd_ReferenceArrayDriver(const Handle(Message_Messenger)& theMsgDriver)
34 : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataStd_ReferenceArray)->Name())
39 //=======================================================================
42 //=======================================================================
43 Handle(TDF_Attribute) BinMDataStd_ReferenceArrayDriver::NewEmpty() const
45 return new TDataStd_ReferenceArray();
48 //=======================================================================
50 //purpose : persistent -> transient (retrieve)
51 //=======================================================================
52 Standard_Boolean BinMDataStd_ReferenceArrayDriver::Paste(const BinObjMgt_Persistent& theSource,
53 const Handle(TDF_Attribute)& theTarget,
54 BinObjMgt_RRelocationTable& theRelocTable) const
56 Standard_Integer aFirstInd, aLastInd;
57 if (! (theSource >> aFirstInd >> aLastInd))
58 return Standard_False;
59 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
61 return Standard_False;
63 const Handle(TDataStd_ReferenceArray) anAtt = Handle(TDataStd_ReferenceArray)::DownCast(theTarget);
64 anAtt->Init(aFirstInd, aLastInd);
65 for (Standard_Integer i = aFirstInd; i <= aLastInd; i++)
67 TCollection_AsciiString entry;
68 if ( !(theSource >> entry) )
69 return Standard_False;
71 TDF_Tool::Label(anAtt->Label().Data(), entry, L, Standard_True);
73 anAtt->SetValue(i, L);
76 BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
80 //=======================================================================
82 //purpose : transient -> persistent (store)
83 //=======================================================================
84 void BinMDataStd_ReferenceArrayDriver::Paste(const Handle(TDF_Attribute)& theSource,
85 BinObjMgt_Persistent& theTarget,
86 BinObjMgt_SRelocationTable& ) const
88 Handle(TDataStd_ReferenceArray) anAtt = Handle(TDataStd_ReferenceArray)::DownCast(theSource);
89 Standard_Integer aFirstInd = anAtt->Lower(), aLastInd = anAtt->Upper(), i = aFirstInd;
90 if (aFirstInd > aLastInd)
92 theTarget << aFirstInd << aLastInd;
93 for (; i <= aLastInd; i++)
95 TDF_Label L = anAtt->Value(i);
98 TCollection_AsciiString entry;
99 TDF_Tool::Entry(L, entry);
104 // process user defined guid
105 if(anAtt->ID() != TDataStd_ReferenceArray::GetID())
106 theTarget << anAtt->ID();