mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +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:
16
src/StdLPersistent/FILES
Normal file
16
src/StdLPersistent/FILES
Normal file
@@ -0,0 +1,16 @@
|
||||
FILES
|
||||
StdLPersistent.cxx
|
||||
StdLPersistent.hxx
|
||||
StdLPersistent_PCollection_HExtendedString.cxx
|
||||
StdLPersistent_PCollection_HExtendedString.hxx
|
||||
StdLPersistent_PColStd_HArray1.hxx
|
||||
StdLPersistent_PColStd_HArray1Base.cxx
|
||||
StdLPersistent_PColStd_HArray1Base.hxx
|
||||
StdLPersistent_PDataStd_Integer.cxx
|
||||
StdLPersistent_PDataStd_Integer.hxx
|
||||
StdLPersistent_PDataStd_Name.cxx
|
||||
StdLPersistent_PDataStd_Name.hxx
|
||||
StdLPersistent_PDF_Data.cxx
|
||||
StdLPersistent_PDF_Data.hxx
|
||||
StdLPersistent_PDocStd_Document.cxx
|
||||
StdLPersistent_PDocStd_Document.hxx
|
43
src/StdLPersistent/StdLPersistent.cxx
Normal file
43
src/StdLPersistent/StdLPersistent.cxx
Normal 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.
|
||||
|
||||
#include <StdLPersistent.hxx>
|
||||
#include <StdObjMgt_MapOfInstantiators.hxx>
|
||||
|
||||
#include <StdLPersistent_PDocStd_Document.hxx>
|
||||
#include <StdLPersistent_PDF_Data.hxx>
|
||||
#include <StdLPersistent_PColStd_HArray1.hxx>
|
||||
#include <StdLPersistent_PCollection_HExtendedString.hxx>
|
||||
#include <StdLPersistent_PDataStd_Name.hxx>
|
||||
#include <StdLPersistent_PDataStd_Integer.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BindTypes
|
||||
//purpose : Register types
|
||||
//=======================================================================
|
||||
void StdLPersistent::BindTypes (StdObjMgt_MapOfInstantiators& theMap)
|
||||
{
|
||||
theMap.Bind <StdLPersistent_PDocStd_Document> ("PDocStd_Document");
|
||||
theMap.Bind <StdLPersistent_PDF_Data> ("PDF_Data");
|
||||
theMap.Bind <StdLPersistent_PDataStd_Name> ("PDataStd_Name");
|
||||
theMap.Bind <StdLPersistent_PDataStd_Integer> ("PDataStd_Integer");
|
||||
|
||||
theMap.Bind <StdLPersistent_PColStd_HArray1OfInteger>
|
||||
("PColStd_HArray1OfInteger");
|
||||
|
||||
theMap.Bind <StdLPersistent_PDF_HAttributeArray1>
|
||||
("PDF_HAttributeArray1");
|
||||
|
||||
theMap.Bind <StdLPersistent_PCollection_HExtendedString>
|
||||
("PCollection_HExtendedString");
|
||||
}
|
29
src/StdLPersistent/StdLPersistent.hxx
Normal file
29
src/StdLPersistent/StdLPersistent.hxx
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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 _StdLPersistent_HeaderFile
|
||||
#define _StdLPersistent_HeaderFile
|
||||
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
class StdObjMgt_MapOfInstantiators;
|
||||
|
||||
class StdLPersistent
|
||||
{
|
||||
public:
|
||||
//! Register types.
|
||||
Standard_EXPORT static void BindTypes (StdObjMgt_MapOfInstantiators& theMap);
|
||||
};
|
||||
|
||||
#endif
|
62
src/StdLPersistent/StdLPersistent_PColStd_HArray1.hxx
Normal file
62
src/StdLPersistent/StdLPersistent_PColStd_HArray1.hxx
Normal file
@@ -0,0 +1,62 @@
|
||||
// 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 _StdLPersistent_PColStd_HArray1_HeaderFile
|
||||
#define _StdLPersistent_PColStd_HArray1_HeaderFile
|
||||
|
||||
#include <StdLPersistent_PColStd_HArray1Base.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
class StdObjMgt_Persistent;
|
||||
|
||||
|
||||
template <class Type>
|
||||
class StdLPersistent_PColStd_HArray1 : public StdLPersistent_PColStd_HArray1Base
|
||||
{
|
||||
public:
|
||||
//! Get the value.
|
||||
const NCollection_Array1<Type>& Array() const { return *myArray; }
|
||||
|
||||
protected:
|
||||
virtual void CreateArray (const Standard_Integer theLowerBound,
|
||||
const Standard_Integer theUpperBound)
|
||||
{
|
||||
myArray = new NCollection_Array1<Type> (theLowerBound, theUpperBound);
|
||||
}
|
||||
|
||||
virtual void ReadValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex)
|
||||
{
|
||||
Type aValue;
|
||||
theReadData >> aValue;
|
||||
myArray->SetValue (theIndex, aValue);
|
||||
}
|
||||
|
||||
private:
|
||||
NCollection_Handle<NCollection_Array1<Type>> myArray;
|
||||
};
|
||||
|
||||
typedef StdLPersistent_PColStd_HArray1<Standard_Integer>
|
||||
StdLPersistent_PColStd_HArray1OfInteger;
|
||||
|
||||
typedef StdLPersistent_PColStd_HArray1<Handle(StdObjMgt_Persistent)>
|
||||
StdLPersistent_PDF_HAttributeArray1;
|
||||
|
||||
#endif
|
37
src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.cxx
Normal file
37
src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.cxx
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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 <StdLPersistent_PColStd_HArray1Base.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PColStd_HArray1Base::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
Standard_Integer aLowerBound, anUpperBound;
|
||||
theReadData >> aLowerBound >> anUpperBound;
|
||||
CreateArray (aLowerBound, anUpperBound);
|
||||
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData >> aSize;
|
||||
|
||||
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
|
||||
ReadValue (theReadData, i);
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
}
|
35
src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.hxx
Normal file
35
src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.hxx
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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 _StdLPersistent_PColStd_HArray1Base_HeaderFile
|
||||
#define _StdLPersistent_PColStd_HArray1Base_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_PColStd_HArray1Base : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
protected:
|
||||
virtual void CreateArray (const Standard_Integer theLowerBound,
|
||||
const Standard_Integer theUpperBound) = 0;
|
||||
|
||||
virtual void ReadValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex) = 0;
|
||||
};
|
||||
|
||||
#endif
|
@@ -0,0 +1,40 @@
|
||||
// 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 <StdLPersistent_PCollection_HExtendedString.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PCollection_HExtendedString::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData >> aSize;
|
||||
myValue = new TCollection_HExtendedString (aSize, 0);
|
||||
|
||||
for (Standard_Integer i = 1; i <= aSize; i++)
|
||||
{
|
||||
Standard_ExtCharacter aChar;
|
||||
theReadData >> aChar;
|
||||
myValue->SetValue (i, aChar);
|
||||
}
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
// 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 _StdLPersistent_PCollection_HExtendedString_HeaderFile
|
||||
#define _StdLPersistent_PCollection_HExtendedString_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
class TCollection_HExtendedString;
|
||||
|
||||
|
||||
class StdLPersistent_PCollection_HExtendedString : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Get the value.
|
||||
Handle(TCollection_HExtendedString) Value() const { return myValue; }
|
||||
|
||||
private:
|
||||
Handle(TCollection_HExtendedString) myValue;
|
||||
};
|
||||
|
||||
#endif
|
98
src/StdLPersistent/StdLPersistent_PDF_Data.cxx
Normal file
98
src/StdLPersistent/StdLPersistent_PDF_Data.cxx
Normal file
@@ -0,0 +1,98 @@
|
||||
// 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 <StdLPersistent_PDF_Data.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
|
||||
//! Create a transient label tree from persistent data
|
||||
class StdLPersistent_PDF_Data::Parser
|
||||
{
|
||||
public:
|
||||
//! Start parsing a persistent data.
|
||||
Parser (const StdLPersistent_PDF_Data& theSource)
|
||||
: myLabelsIter (theSource.myLabels->Array())
|
||||
, myAttribIter (theSource.myAttributes->Array()) {}
|
||||
|
||||
//! Fill a transient label with data.
|
||||
void FillLabel (TDF_Label theLabel)
|
||||
{
|
||||
Standard_Integer i;
|
||||
|
||||
// Read count of attributes
|
||||
myLabelsIter.Next();
|
||||
Standard_Integer anAttribCount = myLabelsIter.Value();
|
||||
|
||||
// Add attributes to the label
|
||||
for (i = 0 ; i < anAttribCount; i++)
|
||||
{
|
||||
// read persistent attribute
|
||||
const Handle(StdObjMgt_Persistent)& aPAttrib = myAttribIter.Value();
|
||||
myAttribIter.Next();
|
||||
|
||||
// create transient attribute and add it to the label
|
||||
if (!aPAttrib.IsNull())
|
||||
{
|
||||
Handle(TDF_Attribute) aTAttrib = aPAttrib->ImportAttribute();
|
||||
if (!aTAttrib.IsNull())
|
||||
theLabel.AddAttribute (aTAttrib);
|
||||
}
|
||||
}
|
||||
|
||||
// Read count of child labels
|
||||
myLabelsIter.Next();
|
||||
Standard_Integer aSubLabelsCount = myLabelsIter.Value();
|
||||
|
||||
// Create child labels
|
||||
for (i = 0 ; i < aSubLabelsCount; i++)
|
||||
{
|
||||
// read tag of child label
|
||||
myLabelsIter.Next();
|
||||
Standard_Integer aSubLabelTag = myLabelsIter.Value();
|
||||
|
||||
// create and fill child label
|
||||
TDF_Label aSubLabel = theLabel.FindChild (aSubLabelTag, Standard_True);
|
||||
FillLabel (aSubLabel);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
NCollection_Array1<Standard_Integer >::Iterator myLabelsIter;
|
||||
NCollection_Array1<Handle(StdObjMgt_Persistent)>::Iterator myAttribIter;
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDF_Data::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myVersion >> myLabels >> myAttributes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient data from the persistent data
|
||||
//=======================================================================
|
||||
Handle(TDF_Data) StdLPersistent_PDF_Data::Import() const
|
||||
{
|
||||
if (myLabels.IsNull() || myAttributes.IsNull())
|
||||
return NULL;
|
||||
|
||||
Handle(TDF_Data) aData = new TDF_Data;
|
||||
Parser (*this).FillLabel (aData->Root());
|
||||
return aData;
|
||||
}
|
43
src/StdLPersistent/StdLPersistent_PDF_Data.hxx
Normal file
43
src/StdLPersistent/StdLPersistent_PDF_Data.hxx
Normal 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 _StdLPersistent_PDF_Data_HeaderFile
|
||||
#define _StdLPersistent_PDF_Data_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
#include <StdLPersistent_PColStd_HArray1.hxx>
|
||||
|
||||
class TDF_Data;
|
||||
|
||||
|
||||
class StdLPersistent_PDF_Data : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Import transient data from the persistent data.
|
||||
Standard_EXPORT Handle(TDF_Data) Import() const;
|
||||
|
||||
private:
|
||||
class Parser;
|
||||
|
||||
private:
|
||||
Standard_Integer myVersion;
|
||||
Handle(StdLPersistent_PColStd_HArray1OfInteger) myLabels;
|
||||
Handle(StdLPersistent_PDF_HAttributeArray1) myAttributes;
|
||||
};
|
||||
|
||||
#endif
|
38
src/StdLPersistent/StdLPersistent_PDataStd_Integer.cxx
Normal file
38
src/StdLPersistent/StdLPersistent_PDataStd_Integer.cxx
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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 <StdLPersistent_PDataStd_Integer.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TDataStd_Integer.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDataStd_Integer::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myValue;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_PDataStd_Integer::ImportAttribute() const
|
||||
{
|
||||
Handle(TDataStd_Integer) aValue = new TDataStd_Integer;
|
||||
aValue->Set (myValue);
|
||||
return aValue;
|
||||
}
|
34
src/StdLPersistent/StdLPersistent_PDataStd_Integer.hxx
Normal file
34
src/StdLPersistent/StdLPersistent_PDataStd_Integer.hxx
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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 _StdLPersistent_PDataStd_Integer_HeaderFile
|
||||
#define _StdLPersistent_PDataStd_Integer_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_PDataStd_Integer : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) ImportAttribute() const;
|
||||
|
||||
private:
|
||||
Standard_Integer myValue;
|
||||
};
|
||||
|
||||
#endif
|
43
src/StdLPersistent/StdLPersistent_PDataStd_Name.cxx
Normal file
43
src/StdLPersistent/StdLPersistent_PDataStd_Name.cxx
Normal 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.
|
||||
|
||||
#include <StdLPersistent_PDataStd_Name.hxx>
|
||||
#include <StdLPersistent_PCollection_HExtendedString.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDataStd_Name::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myString;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_PDataStd_Name::ImportAttribute() const
|
||||
{
|
||||
if (myString.IsNull() || myString->Value().IsNull())
|
||||
return NULL;
|
||||
|
||||
Handle(TDataStd_Name) aName = new TDataStd_Name;
|
||||
aName->Set (myString->Value()->String());
|
||||
return aName;
|
||||
}
|
36
src/StdLPersistent/StdLPersistent_PDataStd_Name.hxx
Normal file
36
src/StdLPersistent/StdLPersistent_PDataStd_Name.hxx
Normal file
@@ -0,0 +1,36 @@
|
||||
// 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 _StdLPersistent_PDataStd_Name_HeaderFile
|
||||
#define _StdLPersistent_PDataStd_Name_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
class StdLPersistent_PCollection_HExtendedString;
|
||||
|
||||
|
||||
class StdLPersistent_PDataStd_Name : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) ImportAttribute() const;
|
||||
|
||||
private:
|
||||
Handle(StdLPersistent_PCollection_HExtendedString) myString;
|
||||
};
|
||||
|
||||
#endif
|
44
src/StdLPersistent/StdLPersistent_PDocStd_Document.cxx
Normal file
44
src/StdLPersistent/StdLPersistent_PDocStd_Document.cxx
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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 <StdLPersistent_PDocStd_Document.hxx>
|
||||
#include <StdLPersistent_PDF_Data.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TDocStd_Owner.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDocStd_Document::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myData;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient document from the persistent data
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDocStd_Document::Import (const Handle(CDM_Document)& theDocument) const
|
||||
{
|
||||
Handle(TDocStd_Document) aDocument = Handle(TDocStd_Document)::DownCast (theDocument);
|
||||
if (aDocument.IsNull() || myData.IsNull())
|
||||
return;
|
||||
|
||||
Handle(TDF_Data) aData = myData->Import();
|
||||
aDocument->SetData (aData);
|
||||
TDocStd_Owner::SetDocument (aData, aDocument);
|
||||
}
|
37
src/StdLPersistent/StdLPersistent_PDocStd_Document.hxx
Normal file
37
src/StdLPersistent/StdLPersistent_PDocStd_Document.hxx
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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 _StdLPersistent_PDocStd_Document_HeaderFile
|
||||
#define _StdLPersistent_PDocStd_Document_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
class CDM_Document;
|
||||
class StdLPersistent_PDF_Data;
|
||||
|
||||
|
||||
class StdLPersistent_PDocStd_Document : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Import transient document from the persistent data.
|
||||
Standard_EXPORT void Import (const Handle(CDM_Document)& theDocument) const;
|
||||
|
||||
private:
|
||||
Handle(StdLPersistent_PDF_Data) myData;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user