0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / StdObjMgt / StdObjMgt_ReadData.cxx
CommitLineData
7ed7467d 1// Copyright (c) 2015 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
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.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#include <StdObjMgt_ReadData.hxx>
ff205346 15#include <StdObjMgt_Persistent.hxx>
7ed7467d 16
45d8465e 17#include <Standard_GUID.hxx>
18
7ed7467d 19
ff205346 20StdObjMgt_ReadData::StdObjMgt_ReadData
21 (Storage_BaseDriver& theDriver, const Standard_Integer theNumberOfObjects)
22 : myDriver (&theDriver)
23 , myPersistentObjects (1, theNumberOfObjects) {}
7ed7467d 24
ff205346 25void StdObjMgt_ReadData::ReadPersistentObject (const Standard_Integer theRef)
26{
27 Handle(StdObjMgt_Persistent) aPersistent = myPersistentObjects (theRef);
28 if (aPersistent)
29 {
30 Standard_Integer aRef, aType;
31 myDriver->ReadPersistentObjectHeader (aRef, aType);
32 myDriver->BeginReadPersistentObjectData();
33 aPersistent->Read (*this);
34 myDriver->EndReadPersistentObjectData();
35 }
36}
37
38Handle(StdObjMgt_Persistent) StdObjMgt_ReadData::ReadReference()
7ed7467d 39{
40 Standard_Integer aRef;
41 myDriver->GetReference (aRef);
ff205346 42 return aRef ? PersistentObject (aRef) : NULL;
7ed7467d 43}
45d8465e 44
45//=======================================================================
46//function : operator >>
47//purpose : Read persistent data from a file
48//=======================================================================
49StdObjMgt_ReadData& operator >>
50 (StdObjMgt_ReadData::Object theReadData, Standard_GUID& theGUID)
51{
52 Standard_Integer a32b;
53 Standard_ExtCharacter a16b[3];
54 Standard_Character a8b [6];
55
56 theReadData >> a32b >> a16b[0] >> a16b[1] >> a16b[2];
57 theReadData >> a8b[0] >> a8b[1] >> a8b[2] >> a8b[3] >> a8b[4] >> a8b[5];
58
59 theGUID = Standard_GUID (a32b, a16b[0], a16b[1], a16b[2],
60 a8b[0], a8b[1], a8b[2], a8b[3], a8b[4], a8b[5]);
61
62 return theReadData;
63}