1 // Copyright (c) 2015 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <StdObjMgt_ReadData.hxx>
15 #include <StdObjMgt_Persistent.hxx>
17 #include <Standard_GUID.hxx>
20 StdObjMgt_ReadData::StdObjMgt_ReadData
21 (Storage_BaseDriver& theDriver, const Standard_Integer theNumberOfObjects)
22 : myDriver (&theDriver)
23 , myPersistentObjects (1, theNumberOfObjects) {}
25 void StdObjMgt_ReadData::ReadPersistentObject (const Standard_Integer theRef)
27 Handle(StdObjMgt_Persistent) aPersistent = myPersistentObjects (theRef);
30 Standard_Integer aRef, aType;
31 myDriver->ReadPersistentObjectHeader (aRef, aType);
32 myDriver->BeginReadPersistentObjectData();
33 aPersistent->Read (*this);
34 myDriver->EndReadPersistentObjectData();
38 Handle(StdObjMgt_Persistent) StdObjMgt_ReadData::ReadReference()
40 Standard_Integer aRef;
41 myDriver->GetReference (aRef);
42 return aRef ? PersistentObject (aRef) : NULL;
45 //=======================================================================
46 //function : operator >>
47 //purpose : Read persistent data from a file
48 //=======================================================================
49 StdObjMgt_ReadData& operator >>
50 (StdObjMgt_ReadData::Object theReadData, Standard_GUID& theGUID)
52 Standard_Integer a32b;
53 Standard_ExtCharacter a16b[3];
54 Standard_Character a8b [6];
56 theReadData >> a32b >> a16b[0] >> a16b[1] >> a16b[2];
57 theReadData >> a8b[0] >> a8b[1] >> a8b[2] >> a8b[3] >> a8b[4] >> a8b[5];
59 theGUID = Standard_GUID (a32b, a16b[0], a16b[1], a16b[2],
60 a8b[0], a8b[1], a8b[2], a8b[3], a8b[4], a8b[5]);