1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0028564: Support of applications using old persistence (ShapeSchema)

1. Bug fix in reading old persistent data using FSD_File storage driver
2. Persistence compatible with legacy format was restored for shapes
   a. Implemented a storage read / write wrapper for legacy persistence
   b. Added DRAW commands to read / write files in legacy format
   c. Added test cases for reading / writing operations with checking number of sub-shapes and physical properties
   d. Updated related sections of the development guide
This commit is contained in:
snn
2017-03-28 17:13:04 +03:00
committed by bugmaster
parent 632175c3a8
commit ec96437207
124 changed files with 7813 additions and 128 deletions

View File

@@ -13,6 +13,7 @@
#include <StdLPersistent_Data.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_WriteData.hxx>
#include <TDF_Data.hxx>
#include <TDF_Attribute.hxx>
@@ -80,6 +81,15 @@ void StdLPersistent_Data::Read (StdObjMgt_ReadData& theReadData)
theReadData >> myVersion >> myLabels >> myAttributes;
}
//=======================================================================
//function : Write
//purpose : Write persistent data to a file
//=======================================================================
void StdLPersistent_Data::Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myVersion << myLabels << myAttributes;
}
//=======================================================================
//function : Import
//purpose : Import transient data from the persistent data

View File

@@ -26,6 +26,17 @@ class StdLPersistent_Data : public StdObjMgt_Persistent
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent child objects
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myLabels);
theChildren.Append(myAttributes);
}
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{ return "PDF_Data"; }
//! Import transient data from the persistent data.
Standard_EXPORT Handle(TDF_Data) Import() const;

View File

@@ -32,6 +32,17 @@ class StdLPersistent_Dependency
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myName >> myVariables; }
//! Write persistent data to a file.
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myName << myVariables; }
//! Gets persistent child objects
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myName);
theChildren.Append(myVariables);
}
//! Returns persistent type name
Standard_CString PName() const;
//! Import transient attribuite from the persistent data.
void Import (const Handle(AttribClass)& theAttribute) const;
@@ -46,4 +57,12 @@ public:
typedef instance<TDataStd_Relation> Relation;
};
template<>
inline Standard_CString StdLPersistent_Dependency::instance<TDataStd_Expression>::PName() const
{ return "PDataStd_Expression"; }
template<>
inline Standard_CString StdLPersistent_Dependency::instance<TDataStd_Relation>::PName() const
{ return "PDataStd_Relation"; }
#endif

View File

@@ -14,6 +14,7 @@
#include <StdLPersistent_Document.hxx>
#include <StdLPersistent_Data.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_WriteData.hxx>
#include <TDocStd_Document.hxx>
#include <TDocStd_Owner.hxx>
@@ -28,6 +29,24 @@ void StdLPersistent_Document::Read (StdObjMgt_ReadData& theReadData)
theReadData >> myData;
}
//=======================================================================
//function : Write
//purpose : Write persistent data to a file
//=======================================================================
void StdLPersistent_Document::Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myData;
}
//=======================================================================
//function : PChildren
//purpose : Gets persistent child objects
//=======================================================================
void StdLPersistent_Document::PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myData);
}
//=======================================================================
//function : Import
//purpose : Import transient document from the persistent data

View File

@@ -26,6 +26,13 @@ class StdLPersistent_Document : public StdObjMgt_Persistent
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Read persistent data from a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent child objects
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const;
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{ return "PDocStd_Document"; }
//! Import transient document from the persistent data.
Standard_EXPORT virtual void ImportDocument

View File

@@ -27,6 +27,13 @@ public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDriverGUID >> myFailure; }
//! Write persistent data to a file.
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myDriverGUID << myFailure; }
//! Gets persistent child objects
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
//! Returns persistent type name
inline Standard_CString PName() const { return "PFunction_Function"; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TFunction_Function)& theAttribute) const

View File

@@ -32,3 +32,21 @@ void StdLPersistent_HArray1::base::Read (StdObjMgt_ReadData& theReadData)
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
readValue (anObjectData, i);
}
//=======================================================================
//function : Write
//purpose : Write persistent data to a file
//=======================================================================
void StdLPersistent_HArray1::base::Write (StdObjMgt_WriteData& theWriteData) const
{
Standard_Integer aLowerBound = lowerBound(), anUpperBound = upperBound();
theWriteData << aLowerBound << anUpperBound;
StdObjMgt_WriteData::Object anObjectData(theWriteData);
Standard_Integer aSize = anUpperBound - aLowerBound + 1;
anObjectData << aSize;
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
writeValue(theWriteData, i);
}

View File

@@ -15,8 +15,12 @@
#ifndef _StdLPersistent_HArray1_HeaderFile
#define _StdLPersistent_HArray1_HeaderFile
#include <Standard_NotImplemented.hxx>
#include <Standard_NullValue.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_WriteData.hxx>
#include <NCollection_DefineHArray1.hxx>
@@ -40,19 +44,27 @@ class StdLPersistent_HArray1
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
protected:
virtual Standard_Integer lowerBound() const = 0;
virtual Standard_Integer upperBound() const = 0;
virtual void createArray (const Standard_Integer theLowerBound,
const Standard_Integer theUpperBound) = 0;
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex) = 0;
virtual void writeValue(StdObjMgt_WriteData& theWriteData,
const Standard_Integer theIndex) const = 0;
};
protected:
template <class ArrayClass>
class instance : public base
{
friend class StdLPersistent_HArray1;
public:
typedef Handle(ArrayClass) ArrayHandle;
typedef typename ArrayClass::value_type ValueType;
@@ -63,27 +75,105 @@ protected:
const Handle(ArrayClass)& Array() const { return myArray; }
protected:
virtual void createArray (const Standard_Integer theLowerBound,
virtual Standard_Integer lowerBound() const { return myArray->Lower(); }
virtual Standard_Integer upperBound() const { return myArray->Upper(); }
virtual void createArray(const Standard_Integer theLowerBound,
const Standard_Integer theUpperBound)
{ myArray = new ArrayClass (theLowerBound, theUpperBound); }
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex)
{ theReadData >> myArray->ChangeValue (theIndex); }
virtual void writeValue(StdObjMgt_WriteData& theWriteData,
const Standard_Integer theIndex) const
{ theWriteData << myArray->Value(theIndex); }
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ return PChildrenT(theChildren); }
virtual Standard_CString PName() const
{ return PNameT(); }
Standard_CString PNameT() const
{
Standard_NotImplemented::Raise("StdLPersistent_HArray1::instance::PName - not implemented");
return "";
}
void PChildrenT(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
protected:
Handle(ArrayClass) myArray;
};
template <class ArrayClass>
class named_instance : public instance<ArrayClass>
{
friend class StdLPersistent_HArray1;
public:
virtual Standard_CString PName() const
{
Standard_NullValue_Raise_if(!myPName,
"StdLPersistent_HArray1::named_instance::PName - name not set");
return myPName;
}
protected:
named_instance(Standard_CString thePName) : myPName(thePName) {}
Standard_CString myPName;
};
public:
typedef instance<TColStd_HArray1OfInteger> Integer;
typedef instance<TColStd_HArray1OfReal> Real;
typedef instance<TColStd_HArray1OfByte> Byte;
typedef instance<StdLPersistent_HArray1OfPersistent> Persistent;
public:
template <class ArrayClass>
static Handle(instance<ArrayClass>) Translate(const ArrayClass& theArray)
{
Handle(instance<ArrayClass>) aPArray = new instance<ArrayClass>;
aPArray->myArray = new ArrayClass(theArray.Lower(), theArray.Upper());
for (Standard_Integer i = theArray.Lower(); i <= theArray.Upper(); ++i)
aPArray->myArray->ChangeValue(i) = theArray.Value(i);
return aPArray;
}
template <class ArrayClass>
static Handle(instance<ArrayClass>) Translate(Standard_CString thePName, const ArrayClass& theArray)
{
Handle(named_instance<ArrayClass>) aPArray = new named_instance<ArrayClass>(thePName);
aPArray->myArray = new ArrayClass(theArray.Lower(), theArray.Upper());
for (Standard_Integer i = theArray.Lower(); i <= theArray.Upper(); ++i)
aPArray->myArray->ChangeValue(i) = theArray.Value(i);
return aPArray;
}
};
template<>
inline Standard_CString StdLPersistent_HArray1::instance<TColStd_HArray1OfInteger>::PNameT() const
{ return "PColStd_HArray1OfInteger"; }
template<>
inline Standard_CString StdLPersistent_HArray1::instance<TColStd_HArray1OfReal>::PNameT() const
{ return "PColStd_HArray1OfReal"; }
template<>
inline Standard_CString StdLPersistent_HArray1::instance<TColStd_HArray1OfByte>::PNameT() const
{ return "PColStd_HArray1OfByte"; }
inline StdObjMgt_ReadData& operator >>
(StdObjMgt_ReadData& theReadData, Standard_Byte& theByte)
{ return theReadData >> reinterpret_cast<Standard_Character&> (theByte); }
inline StdObjMgt_WriteData& operator >>
(StdObjMgt_WriteData& theWriteData, const Standard_Byte& theByte)
{ return theWriteData << reinterpret_cast<const Standard_Character&> (theByte); }
template<>
inline void StdLPersistent_HArray1::instance<StdLPersistent_HArray1OfPersistent>::PChildrenT
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
for (Standard_Integer i = myArray->Lower(); i <= myArray->Upper(); ++i)
theChildren.Append(myArray->Value(i));
}
#endif

View File

@@ -36,3 +36,24 @@ void StdLPersistent_HArray2::base::Read (StdObjMgt_ReadData& theReadData)
for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
readValue (anObjectData, aRow, aCol);
}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_HArray2::base::Write (StdObjMgt_WriteData& theWriteData) const
{
Standard_Integer aLowerRow, aLowerCol, anUpperRow, anUpperCol;
lowerBound(aLowerRow, aLowerCol);
upperBound(anUpperRow, anUpperCol);
theWriteData << aLowerRow << aLowerCol << anUpperRow << anUpperCol;
StdObjMgt_WriteData::Object anObjectData(theWriteData);
Standard_Integer aSize = (anUpperRow - aLowerRow + 1) * (anUpperCol - aLowerCol + 1);
anObjectData << aSize;
for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++)
for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
writeValue(anObjectData, aRow, aCol);
}

View File

@@ -15,8 +15,12 @@
#ifndef _StdLPersistent_HArray2_HeaderFile
#define _StdLPersistent_HArray2_HeaderFile
#include <Standard_NotImplemented.hxx>
#include <Standard_NullValue.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_WriteData.hxx>
#include <NCollection_DefineHArray2.hxx>
@@ -36,8 +40,15 @@ class StdLPersistent_HArray2
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Read persistent data from a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
protected:
virtual void createArray (
virtual void lowerBound(Standard_Integer& theRow,
Standard_Integer& theCol) const = 0;
virtual void upperBound(Standard_Integer& theRow,
Standard_Integer& theCol) const = 0;
virtual void createArray(
const Standard_Integer theLowerRow, const Standard_Integer theLowerCol,
const Standard_Integer theUpperRow, const Standard_Integer theUpperCol)
= 0;
@@ -45,12 +56,17 @@ class StdLPersistent_HArray2
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theRow,
const Standard_Integer theCol) = 0;
virtual void writeValue(StdObjMgt_WriteData& theWriteData,
const Standard_Integer theRow,
const Standard_Integer theCol) const = 0;
};
protected:
template <class ArrayClass>
class instance : public base
{
friend class StdLPersistent_HArray2;
public:
typedef Handle(ArrayClass) ArrayHandle;
@@ -59,27 +75,114 @@ protected:
const Handle(ArrayClass)& Array() const { return myArray; }
protected:
virtual void createArray (
virtual void lowerBound(Standard_Integer& theRow,
Standard_Integer& theCol) const
{
theRow = myArray->LowerRow();
theCol = myArray->LowerCol();
}
virtual void upperBound(Standard_Integer& theRow,
Standard_Integer& theCol) const
{
theRow = myArray->UpperRow();
theCol = myArray->UpperCol();
}
virtual void createArray(
const Standard_Integer theLowerRow, const Standard_Integer theLowerCol,
const Standard_Integer theUpperRow, const Standard_Integer theUpperCol)
{
myArray = new ArrayClass (theLowerRow, theUpperRow,
theLowerCol, theUpperCol);
}
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theRow,
const Standard_Integer theCol)
{ theReadData >> myArray->ChangeValue (theRow, theCol); }
virtual void writeValue(StdObjMgt_WriteData& theWriteData,
const Standard_Integer theRow,
const Standard_Integer theCol) const
{
theWriteData << myArray->Value(theRow, theCol);
}
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ return PChildrenT(theChildren); }
virtual Standard_CString PName() const
{ return PNameT(); }
Standard_CString PNameT() const
{
Standard_NotImplemented::Raise("StdLPersistent_HArray2::instance::PName - not implemented");
return "";
}
void PChildrenT(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
protected:
Handle(ArrayClass) myArray;
};
template <class ArrayClass>
class named_instance : public instance<ArrayClass>
{
friend class StdLPersistent_HArray2;
public:
virtual Standard_CString PName() const
{
Standard_NullValue_Raise_if(!myPName,
"StdLPersistent_HArray2::named_instance::PName - name not set");
return myPName;
}
protected:
named_instance(Standard_CString thePName) : myPName(thePName) {}
Standard_CString myPName;
};
public:
typedef instance<TColStd_HArray2OfInteger> Integer;
typedef instance<TColStd_HArray2OfReal> Real;
typedef instance<StdLPersistent_HArray2OfPersistent> Persistent;
public:
template <class ArrayClass>
static Handle(instance<ArrayClass>) Translate(const ArrayClass& theArray)
{
Handle(instance<ArrayClass>) aPArray = new instance<ArrayClass>;
aPArray->myArray = new ArrayClass(theArray.LowerRow(), theArray.UpperRow(),
theArray.LowerCol(), theArray.UpperCol());
for (Standard_Integer i = theArray.LowerRow(); i <= theArray.UpperRow(); ++i)
for (Standard_Integer j = theArray.LowerCol(); j <= theArray.UpperCol(); ++j)
aPArray->myArray->ChangeValue(i, j) = theArray.Value(i, j);
return aPArray;
}
template <class ArrayClass>
static Handle(instance<ArrayClass>) Translate(Standard_CString thePName, const ArrayClass& theArray)
{
Handle(named_instance<ArrayClass>) aPArray = new named_instance<ArrayClass>(thePName);
aPArray->myArray = new ArrayClass(theArray.LowerRow(), theArray.UpperRow(),
theArray.LowerCol(), theArray.UpperCol());
for (Standard_Integer i = theArray.LowerRow(); i <= theArray.UpperRow(); ++i)
for (Standard_Integer j = theArray.LowerCol(); j <= theArray.UpperCol(); ++j)
aPArray->myArray->ChangeValue(i, j) = theArray.Value(i, j);
return aPArray;
}
};
template<>
inline Standard_CString StdLPersistent_HArray2::instance<TColStd_HArray2OfInteger>::PNameT() const
{ return "PColStd_HArray2OfInteger"; }
template<>
inline Standard_CString StdLPersistent_HArray2::instance<TColStd_HArray2OfReal>::PNameT() const
{ return "PColStd_HArray2OfReal"; }
template<>
inline void StdLPersistent_HArray2::instance<StdLPersistent_HArray2OfPersistent>::PChildrenT
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
for (Standard_Integer i = myArray->LowerRow(); i <= myArray->UpperRow(); ++i)
for (Standard_Integer j = myArray->LowerCol(); j <= myArray->UpperCol(); ++j)
theChildren.Append(myArray->Value(i, j));
}
#endif

View File

@@ -13,6 +13,7 @@
#include <StdLPersistent_HString.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_WriteData.hxx>
#include <TDF_Label.hxx>
#include <TDF_Tool.hxx>
@@ -39,6 +40,26 @@ void StdLPersistent_HString::instance<StringClass, CharType>::Read
}
}
//=======================================================================
//function : Write
//purpose : Write persistent data to a file
//=======================================================================
template <class StringClass, typename CharType>
void StdLPersistent_HString::instance<StringClass, CharType>::Write
(StdObjMgt_WriteData& theWriteData) const
{
StdObjMgt_WriteData::Object anObjectData(theWriteData);
Standard_Integer aSize = myValue->Length();
anObjectData << aSize;
for (Standard_Integer i = 1; i <= aSize; i++)
{
CharType aChar (0);
anObjectData << aChar;
}
}
//=======================================================================
//function : Label
//purpose : Get/create a label defined by referenced string

View File

@@ -30,6 +30,9 @@ class StdLPersistent_HString
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const { }
//! Get/create a label defined by referenced string.
Standard_EXPORT virtual TDF_Label Label (const Handle(TDF_Data)& theDF) const;
@@ -48,6 +51,8 @@ public:
public:
//! Get referenced ASCII string.
Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const;
inline Standard_CString PName() const { return "PCollection_HAsciiString"; }
};
class Extended
@@ -56,6 +61,8 @@ public:
public:
//! Get referenced extended string.
Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const;
inline Standard_CString PName() const { return "PCollection_HExtendedString"; }
};
};

View File

@@ -32,6 +32,8 @@ class StdLPersistent_NamedData : public StdObjMgt_Attribute<TDataStd_NamedData>
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myKeys >> myValues; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myKeys << myValues; }
inline operator bool() const
{ return !myKeys.IsNull(); }
@@ -60,6 +62,24 @@ public:
myRealArrays.Read (theReadData);
}
//! Write persistent data to a file.
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myDimensions;
myInts.Write(theWriteData);
myReals.Write(theWriteData);
myStrings.Write(theWriteData);
myBytes.Write(theWriteData);
myIntArrays.Write(theWriteData);
myRealArrays.Write(theWriteData);
}
//! Gets persistent child objects
void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
//! Returns persistent type name
Standard_CString PName() const { return "PDataStd_NamedData"; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataStd_NamedData)& theAttribute) const;

View File

@@ -26,13 +26,20 @@ public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myValue >> myDimension; }
//! Write persistent data from a file.
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myValue << myDimension; }
//! Gets persistent child objects
void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
//! Returns persistent type name
Standard_CString PName() const { return "PDataStd_Real"; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataStd_Real)& theAttribute) const
{
theAttribute->Set (myValue);
theAttribute->SetDimension (static_cast<TDataStd_RealEnum> (myDimension));
theAttribute->SetID(TDataStd_Real::GetID());
theAttribute->SetID(TDataStd_Real::GetID());
}
private:

View File

@@ -24,6 +24,27 @@ void StdLPersistent_TreeNode::Read (StdObjMgt_ReadData& theReadData)
theReadData >> myDynamicData->First >> myNext >> myDynamicData->TreeID;
}
//=======================================================================
//function : Write
//purpose : Write persistent data to a file
//=======================================================================
void StdLPersistent_TreeNode::Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myDynamicData->First << myNext << myDynamicData->TreeID;
}
//=======================================================================
//function : PChildren
//purpose : Gets persistent child objects
//=======================================================================
void StdLPersistent_TreeNode::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myNext);
if (!myDynamicData.IsNull())
theChildren.Append(myDynamicData->First);
}
//=======================================================================
//function : CreateAttribute
//purpose : Create an empty transient attribuite

View File

@@ -28,6 +28,16 @@ public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent child objects
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const;
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{ return "PDataStd_TreeNode"; }
//! Create an empty transient attribuite
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();

View File

@@ -48,15 +48,27 @@ class StdLPersistent_Value
public:
typedef integer <TDF_TagSource> TagSource;
typedef string <TDF_Reference> Reference;
typedef string <TDataStd_Comment> Comment;
class TagSource : public integer <TDF_TagSource> {
public:
Standard_CString PName() const { return "PDF_TagSource"; }
};
class Reference : public string <TDF_Reference> {
public:
Standard_CString PName() const { return "PDF_Reference"; }
};
class Comment : public string <TDataStd_Comment> {
public:
Standard_CString PName() const { return "PDF_Comment"; }
};
class UAttribute : public string <TDataStd_UAttribute>
{
public:
//! Create an empty transient attribuite
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
Standard_CString PName() const { return "PDataStd_UAttribute"; }
};
class Integer : public integer <TDataStd_Integer>
@@ -64,6 +76,7 @@ public:
public:
//! Create an empty transient attribuite
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
Standard_CString PName() const { return "PDataStd_Integer"; }
};
class Name : public string <TDataStd_Name>
@@ -71,6 +84,7 @@ public:
public:
//! Create an empty transient attribuite
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
Standard_CString PName() const { return "PDataStd_Name"; }
};
class AsciiString : public string <TDataStd_AsciiString, StdLPersistent_HString::Ascii>
@@ -78,7 +92,23 @@ public:
public:
//! Create an empty transient attribuite
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
Standard_CString PName() const { return "PDataStd_AsciiString"; }
};
};
template<>
template<>
inline Standard_CString StdObjMgt_Attribute<TDF_TagSource>::Simple<Standard_Integer>::PName() const
{ return "PDF_TagSource"; }
template<>
template<>
inline Standard_CString StdObjMgt_Attribute<TDF_Reference>::Simple<Handle(StdObjMgt_Persistent)>::PName() const
{ return "PDF_Reference"; }
template<>
template<>
inline Standard_CString StdObjMgt_Attribute<TDataStd_Comment>::Simple<Handle(StdObjMgt_Persistent)>::PName() const
{ return "PDataStd_Comment"; }
#endif

View File

@@ -27,6 +27,14 @@ public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myIsConstant >> myUnit; }
//! Write persistent data to a file.
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myIsConstant << myUnit; }
//! Gets persistent child objects
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ theChildren.Append(myUnit); }
//! Returns persistent type name
inline Standard_CString PName() const { return "PDataStd_Variable"; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataStd_Variable)& theAttribute) const

View File

@@ -31,6 +31,12 @@ protected:
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData&) {}
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData&) const {}
//! Gets persistent child objects
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
//! Returns persistent type name
Standard_CString PName() const;
//! Import transient attribuite from the persistent data
Standard_EXPORT virtual void ImportAttribute() {}
@@ -42,4 +48,16 @@ public:
typedef instance<TDataStd_NoteBook> NoteBook;
};
template<>
inline Standard_CString StdLPersistent_Void::instance<TDataStd_Directory>::PName() const
{ return "PDataStd_Directory"; }
template<>
inline Standard_CString StdLPersistent_Void::instance<TDataStd_Tick>::PName() const
{ return "PDataStd_Tick"; }
template<>
inline Standard_CString StdLPersistent_Void::instance<TDataStd_NoteBook>::PName() const
{ return "PDataStd_Notebook"; }
#endif

View File

@@ -27,6 +27,17 @@ public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDocEntry >> myLabEntry; }
//! Write persistent data to a file.
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myDocEntry << myLabEntry; }
//! Gets persistent child objects
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myDocEntry);
theChildren.Append(myLabEntry);
}
//! Returns persistent type name
inline Standard_CString PName() const { return "PDocStd_XLink"; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDocStd_XLink)& theAttribute) const