1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +03:00

0026961: Recover possibility to read files in old persistence format -- preparation

Added basic support for possibility to read filed in old persistent format.
Toolkits TKStd, TKStdL, TKShape added to provide necessary tools (to be done).
Obsolete interfaces are removed from classes in PCDM and Storage.
This commit is contained in:
myn
2015-12-09 20:27:36 +03:00
committed by abv
parent ede9746c21
commit 7ed7467da3
79 changed files with 2010 additions and 1287 deletions

6
src/StdObjMgt/FILES Normal file
View File

@@ -0,0 +1,6 @@
StdObjMgt_MapOfInstantiators.cxx
StdObjMgt_MapOfInstantiators.hxx
StdObjMgt_Persistent.cxx
StdObjMgt_Persistent.hxx
StdObjMgt_ReadData.cxx
StdObjMgt_ReadData.hxx

View File

@@ -0,0 +1,15 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdObjMgt_MapOfInstantiators.hxx>

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdObjMgt_MapOfInstantiators_HeaderFile
#define _StdObjMgt_MapOfInstantiators_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <NCollection_DataMap.hxx>
#include <TCollection_AsciiString.hxx>
class StdObjMgt_MapOfInstantiators
: public NCollection_DataMap<TCollection_AsciiString,
StdObjMgt_Persistent::Instantiator,
TCollection_AsciiString>
{
public:
template <class Type>
void Bind (const TCollection_AsciiString& theTypeName)
{
NCollection_DataMap<TCollection_AsciiString,
StdObjMgt_Persistent::Instantiator,
TCollection_AsciiString>
::Bind (theTypeName, &Instantiate<Type>);
}
DEFINE_STANDARD_ALLOC
private:
template <class Type>
static Handle(StdObjMgt_Persistent) Instantiate()
{ return new Type; }
};
#endif // _StdObjMgt_MapOfInstantiators_HeaderFile

View File

@@ -0,0 +1,25 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdObjMgt_Persistent.hxx>
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//! (to be overriden by attribute classes;
//! returns a null handle by default for non-attribute classes)
//=======================================================================
Handle(TDF_Attribute) StdObjMgt_Persistent::ImportAttribute() const
{
return Handle(TDF_Attribute)();
}

View File

@@ -0,0 +1,43 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdObjMgt_Persistent_HeaderFile
#define _StdObjMgt_Persistent_HeaderFile
#include <Standard.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Transient.hxx>
class StdObjMgt_ReadData;
class TDF_Attribute;
//! Root class for a temporary object that reads data from a file and then
//! creates transient object using the data.
class StdObjMgt_Persistent : public Standard_Transient
{
public:
//! Create a derived class instance.
typedef Handle(StdObjMgt_Persistent) (*Instantiator)();
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData) = 0;
//! Import transient attribuite from the persistent data
//! (to be overriden by attribute classes;
//! returns a null handle by default for non-attribute classes).
Standard_EXPORT virtual Handle(TDF_Attribute) ImportAttribute() const;
};
#endif // _StdObjMgt_Persistent_HeaderFile

View File

@@ -0,0 +1,31 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdObjMgt_ReadData.hxx>
StdObjMgt_ReadData::StdObjMgt_ReadData (Storage_BaseDriver& theDriver,
const Standard_Integer theNumberOfObjects)
: myDriver (&theDriver)
, myPersistentObjects (1, theNumberOfObjects) {}
void StdObjMgt_ReadData::ReadReference (Handle(StdObjMgt_Persistent)& theTarget)
{
Standard_Integer aRef;
myDriver->GetReference (aRef);
if (aRef)
theTarget = Object (aRef);
else
theTarget.Nullify();
}

View File

@@ -0,0 +1,61 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdObjMgt_ReadData_HeaderFile
#define _StdObjMgt_ReadData_HeaderFile
#include <Standard.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <NCollection_Array1.hxx>
#include <Storage_BaseDriver.hxx>
//! Auxiliary data used to read persistent objects from a file.
class StdObjMgt_ReadData
{
public:
Standard_EXPORT StdObjMgt_ReadData (Storage_BaseDriver& theDriver,
const Standard_Integer theNumberOfObjects);
void CreateObject (const Standard_Integer theRef,
StdObjMgt_Persistent::Instantiator theInstantiator)
{ myPersistentObjects (theRef) = theInstantiator(); }
Handle(StdObjMgt_Persistent) Object (const Standard_Integer theRef) const
{ return myPersistentObjects (theRef); }
Storage_BaseDriver& Driver() const
{ return *myDriver; }
Standard_EXPORT void ReadReference (Handle(StdObjMgt_Persistent)& theTarget);
template <class Type>
StdObjMgt_ReadData& operator >> (Type& aValue)
{
*myDriver >> aValue;
return *this;
}
template <class Type>
StdObjMgt_ReadData& operator >> (Handle(Type)& theTarget)
{
ReadReference (theTarget);
return *this;
}
private:
Storage_BaseDriver* myDriver;
NCollection_Array1<Handle(StdObjMgt_Persistent)> myPersistentObjects;
};
#endif // _StdObjMgt_ReadData_HeaderFile