1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0030169: Application Framework - Document format version management improvement

This commit is contained in:
szy
2018-10-09 17:30:10 +03:00
committed by apn
parent 90fd614536
commit b34d86cb28
58 changed files with 315 additions and 305 deletions

View File

@@ -44,7 +44,6 @@
#include <BinMDF_ADriverTable.hxx>
#include <Message_Messenger.hxx>
static Standard_Integer myDocumentVersion = -1;
//=======================================================================
//function : AddDrivers
//purpose :
@@ -81,20 +80,3 @@ void BinMDataStd::AddDrivers (const Handle(BinMDF_ADriverTable)& theDriverTable,
theDriverTable->AddDriver (new BinMDataStd_AsciiStringDriver (theMsgDriver) );
theDriverTable->AddDriver (new BinMDataStd_IntPackedMapDriver (theMsgDriver) );
}
//=======================================================================
//function : SetDocumentVersion
//purpose : Sets current document version
//=======================================================================
void BinMDataStd::SetDocumentVersion(const Standard_Integer theVersion)
{
myDocumentVersion = theVersion;
}
//=======================================================================
//function : DocumentVersion
//purpose : Retrieved document version
//=======================================================================
Standard_Integer BinMDataStd::DocumentVersion()
{
return myDocumentVersion;
}

View File

@@ -25,32 +25,6 @@
class BinMDF_ADriverTable;
class Message_Messenger;
class BinMDataStd_NameDriver;
class BinMDataStd_IntegerDriver;
class BinMDataStd_RealDriver;
class BinMDataStd_IntegerArrayDriver;
class BinMDataStd_RealArrayDriver;
class BinMDataStd_UAttributeDriver;
class BinMDataStd_DirectoryDriver;
class BinMDataStd_CommentDriver;
class BinMDataStd_VariableDriver;
class BinMDataStd_ExpressionDriver;
class BinMDataStd_RelationDriver;
class BinMDataStd_NoteBookDriver;
class BinMDataStd_TreeNodeDriver;
class BinMDataStd_ExtStringArrayDriver;
class BinMDataStd_TickDriver;
class BinMDataStd_AsciiStringDriver;
class BinMDataStd_IntPackedMapDriver;
class BinMDataStd_IntegerListDriver;
class BinMDataStd_RealListDriver;
class BinMDataStd_ExtStringListDriver;
class BinMDataStd_BooleanListDriver;
class BinMDataStd_ReferenceListDriver;
class BinMDataStd_BooleanArrayDriver;
class BinMDataStd_ReferenceArrayDriver;
class BinMDataStd_ByteArrayDriver;
class BinMDataStd_NamedDataDriver;
//! Storage and Retrieval drivers for modelling attributes.
class BinMDataStd
@@ -62,16 +36,12 @@ public:
//! Adds the attribute drivers to <theDriverTable>.
Standard_EXPORT static void AddDrivers (const Handle(BinMDF_ADriverTable)& theDriverTable, const Handle(Message_Messenger)& aMsgDrv);
Standard_EXPORT static void SetDocumentVersion (const Standard_Integer DocVersion);
Standard_EXPORT static Standard_Integer DocumentVersion();
template<class T>
static void SetAttributeID(const BinObjMgt_Persistent& theSource, const Handle(T)& anAtt)
static void SetAttributeID(const BinObjMgt_Persistent& theSource, const Handle(T)& anAtt, const Standard_Integer aDocFormatVersion)
{
Standard_Boolean ok = Standard_True;
if(BinMDataStd::DocumentVersion() > 9) { // process user defined guid
if(aDocFormatVersion > 9) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;

View File

@@ -55,14 +55,14 @@ Handle(TDF_Attribute) BinMDataStd_AsciiStringDriver::NewEmpty() const
Standard_Boolean BinMDataStd_AsciiStringDriver::Paste
(const BinObjMgt_Persistent& Source,
const Handle(TDF_Attribute)& Target,
BinObjMgt_RRelocationTable& /*RelocTable*/) const
BinObjMgt_RRelocationTable& RelocTable) const
{
Handle(TDataStd_AsciiString) aStrAtt = Handle(TDataStd_AsciiString)::DownCast(Target);
TCollection_AsciiString aString;
Standard_Boolean ok = Source >> aString;
if (ok)
aStrAtt->Set( aString );
if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 8) { // process user defined guid
const Standard_Integer& aPos = Source.Position();
Standard_GUID aGuid;
ok = Source >> aGuid;

View File

@@ -51,7 +51,7 @@ Handle(TDF_Attribute) BinMDataStd_BooleanArrayDriver::NewEmpty() const
//=======================================================================
Standard_Boolean BinMDataStd_BooleanArrayDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -71,7 +71,7 @@ Standard_Boolean BinMDataStd_BooleanArrayDriver::Paste(const BinObjMgt_Persisten
bytes->SetValue(i, aTargetArray.Value(i));
}
anAtt->SetInternalArray(bytes);
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}

View File

@@ -51,7 +51,7 @@ Handle(TDF_Attribute) BinMDataStd_BooleanListDriver::NewEmpty() const
//=======================================================================
Standard_Boolean BinMDataStd_BooleanListDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aIndex, aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -71,7 +71,7 @@ Standard_Boolean BinMDataStd_BooleanListDriver::Paste(const BinObjMgt_Persistent
}
}
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}
@@ -101,4 +101,4 @@ void BinMDataStd_BooleanListDriver::Paste(const Handle(TDF_Attribute)& theSource
// process user defined guid
if(anAtt->ID() != TDataStd_BooleanList::GetID())
theTarget << anAtt->ID();
}
}

View File

@@ -51,7 +51,7 @@ Handle(TDF_Attribute) BinMDataStd_ByteArrayDriver::NewEmpty() const
//=======================================================================
Standard_Boolean BinMDataStd_ByteArrayDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -71,7 +71,7 @@ Standard_Boolean BinMDataStd_ByteArrayDriver::Paste(const BinObjMgt_Persistent&
anAtt->ChangeArray(bytes);
Standard_Boolean aDelta(Standard_False);
if(BinMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;
@@ -80,7 +80,7 @@ Standard_Boolean BinMDataStd_ByteArrayDriver::Paste(const BinObjMgt_Persistent&
}
anAtt->SetDelta(aDelta);
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}

View File

@@ -54,7 +54,7 @@ Handle(TDF_Attribute) BinMDataStd_ExtStringArrayDriver::NewEmpty() const
Standard_Boolean BinMDataStd_ExtStringArrayDriver::Paste
(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -81,7 +81,7 @@ Standard_Boolean BinMDataStd_ExtStringArrayDriver::Paste
if(ok) {
Standard_Boolean aDelta(Standard_False);
if(BinMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue)) {
return Standard_False;
@@ -92,7 +92,7 @@ Standard_Boolean BinMDataStd_ExtStringArrayDriver::Paste
anAtt->SetDelta(aDelta);
}
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return ok;
}

View File

@@ -52,7 +52,7 @@ Handle(TDF_Attribute) BinMDataStd_ExtStringListDriver::NewEmpty() const
Standard_Boolean BinMDataStd_ExtStringListDriver::Paste
(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -74,7 +74,7 @@ Standard_Boolean BinMDataStd_ExtStringListDriver::Paste
}
}
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}

View File

@@ -59,7 +59,7 @@ Handle(TDF_Attribute) BinMDataStd_IntPackedMapDriver::NewEmpty() const
Standard_Boolean BinMDataStd_IntPackedMapDriver::Paste
(const BinObjMgt_Persistent& Source,
const Handle(TDF_Attribute)& Target,
BinObjMgt_RRelocationTable& /*RelocTable*/) const
BinObjMgt_RRelocationTable& RelocTable) const
{
Handle(TDataStd_IntPackedMap) aTagAtt = Handle(TDataStd_IntPackedMap)::DownCast(Target);
if(aTagAtt.IsNull()) {
@@ -87,7 +87,7 @@ Standard_Boolean BinMDataStd_IntPackedMapDriver::Paste
}
Standard_Boolean aDelta(Standard_False);
if(BinMDataStd::DocumentVersion() > 2) {
if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Byte aDeltaValue;
if (! (Source >> aDeltaValue))
return Standard_False;

View File

@@ -53,7 +53,7 @@ Handle(TDF_Attribute) BinMDataStd_IntegerArrayDriver::NewEmpty() const
Standard_Boolean BinMDataStd_IntegerArrayDriver::Paste
(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -69,7 +69,7 @@ Standard_Boolean BinMDataStd_IntegerArrayDriver::Paste
if(!theSource.GetIntArray (&aTargetArray(aFirstInd), aLength))
return Standard_False;
Standard_Boolean aDelta(Standard_False);
if(BinMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;
@@ -77,12 +77,11 @@ Standard_Boolean BinMDataStd_IntegerArrayDriver::Paste
aDelta = (aDeltaValue != 0);
}
#ifdef OCCT_DEBUG
else if(BinMDataStd::DocumentVersion() == -1)
cout << "Current DocVersion field is not initialized. " <<endl;
//cout << "Current Document Format Version = " << theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() <<endl;
#endif
anAtt->SetDelta(aDelta);
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}

View File

@@ -52,14 +52,14 @@ Handle(TDF_Attribute) BinMDataStd_IntegerDriver::NewEmpty() const
Standard_Boolean BinMDataStd_IntegerDriver::Paste
(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRT) const
{
Handle(TDataStd_Integer) anAtt = Handle(TDataStd_Integer)::DownCast(theTarget);
Standard_Integer aValue;
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);
if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
if(theRT.GetHeaderData()->StorageVersion().IntegerValue() > 8) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;

View File

@@ -51,7 +51,7 @@ Handle(TDF_Attribute) BinMDataStd_IntegerListDriver::NewEmpty() const
//=======================================================================
Standard_Boolean BinMDataStd_IntegerListDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aIndex, aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -67,7 +67,7 @@ Standard_Boolean BinMDataStd_IntegerListDriver::Paste(const BinObjMgt_Persistent
}
}
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}

View File

@@ -52,14 +52,14 @@ Handle(TDF_Attribute) BinMDataStd_NameDriver::NewEmpty() const
Standard_Boolean BinMDataStd_NameDriver::Paste
(const BinObjMgt_Persistent& Source,
const Handle(TDF_Attribute)& Target,
BinObjMgt_RRelocationTable& /*RelocTable*/) const
BinObjMgt_RRelocationTable& RelocTable) const
{
Handle(TDataStd_Name) aName = Handle(TDataStd_Name)::DownCast(Target);
TCollection_ExtendedString aStr;
Standard_Boolean ok = Source >> aStr;
if (ok)
aName->Set( aStr );
if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 8) { // process user defined guid
const Standard_Integer& aPos = Source.Position();
Standard_GUID aGuid;
ok = Source >> aGuid;

View File

@@ -53,7 +53,7 @@ Handle(TDF_Attribute) BinMDataStd_RealArrayDriver::NewEmpty() const
Standard_Boolean BinMDataStd_RealArrayDriver::Paste
(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -70,7 +70,7 @@ Standard_Boolean BinMDataStd_RealArrayDriver::Paste
return Standard_False;
Standard_Boolean aDelta(Standard_False);
if(BinMDataStd::DocumentVersion() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;
@@ -79,7 +79,7 @@ Standard_Boolean BinMDataStd_RealArrayDriver::Paste
}
anAtt->SetDelta(aDelta);
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}

View File

@@ -52,14 +52,14 @@ Handle(TDF_Attribute) BinMDataStd_RealDriver::NewEmpty() const
Standard_Boolean BinMDataStd_RealDriver::Paste
(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Handle(TDataStd_Real) anAtt= Handle(TDataStd_Real)::DownCast(theTarget);
Standard_Real aValue;
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);
if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 8) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;

View File

@@ -51,7 +51,7 @@ Handle(TDF_Attribute) BinMDataStd_RealListDriver::NewEmpty() const
//=======================================================================
Standard_Boolean BinMDataStd_RealListDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aIndex, aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -68,7 +68,7 @@ Standard_Boolean BinMDataStd_RealListDriver::Paste(const BinObjMgt_Persistent&
}
}
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}

View File

@@ -51,7 +51,7 @@ Handle(TDF_Attribute) BinMDataStd_ReferenceArrayDriver::NewEmpty() const
//=======================================================================
Standard_Boolean BinMDataStd_ReferenceArrayDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -73,7 +73,7 @@ Standard_Boolean BinMDataStd_ReferenceArrayDriver::Paste(const BinObjMgt_Persist
anAtt->SetValue(i, L);
}
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}

View File

@@ -52,7 +52,7 @@ Handle(TDF_Attribute) BinMDataStd_ReferenceListDriver::NewEmpty() const
//=======================================================================
Standard_Boolean BinMDataStd_ReferenceListDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& ) const
BinObjMgt_RRelocationTable& theRelocTable) const
{
Standard_Integer aFirstInd, aLastInd;
if (! (theSource >> aFirstInd >> aLastInd))
@@ -76,7 +76,7 @@ Standard_Boolean BinMDataStd_ReferenceListDriver::Paste(const BinObjMgt_Persiste
}
}
BinMDataStd::SetAttributeID(theSource, anAtt);
BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
return Standard_True;
}