mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0031546: Application Framework - Memory leak (100 bytes) on Load / Close OCAF document
Class Standard_BaseDriver is inherited from Standard_Transient, its descendants are updated accordingly. Handle is used to manipulate objects of this class and its descendants (instead of references or raw pointers) to ensure automatic destruction. Added test bugs caf bug31546 Related: - Standard_OVERRIDE is added in declarations of virtual methods in descendants of Storage_BaseDriver - Methods operator << and operator >> are removed in descendants of Storage_BaseDriver (they repeat the same methods inherited from the base class) - Typedef PCDM_BaseDriverPointer is marked as deprecated - Unused class DDI_Ostream is removed - Private field Standard_Transient::count is renamed to myRefCount_ to avoid compiler warnings if the same name is used within the scope of a descendant class - Output of meaningful error messages is restored in DRAW commands fsdread and fsdwrite
This commit is contained in:
@@ -4,7 +4,6 @@ Storage_ArrayOfCallBack.hxx
|
||||
Storage_ArrayOfSchema.hxx
|
||||
Storage_BaseDriver.cxx
|
||||
Storage_BaseDriver.hxx
|
||||
Storage_BaseDriver.lxx
|
||||
Storage_BucketOfPersistent.hxx
|
||||
Storage_CallBack.cxx
|
||||
Storage_CallBack.hxx
|
||||
@@ -36,7 +35,6 @@ Storage_RootData.cxx
|
||||
Storage_RootData.hxx
|
||||
Storage_Schema.cxx
|
||||
Storage_Schema.hxx
|
||||
Storage_Schema.lxx
|
||||
Storage_SeqOfRoot.hxx
|
||||
Storage_SolveMode.hxx
|
||||
Storage_StreamExtCharParityError.hxx
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Storage_BaseDriver, Standard_Transient)
|
||||
|
||||
Storage_BaseDriver::Storage_BaseDriver() : myOpenMode(Storage_VSNone)
|
||||
{
|
||||
}
|
||||
|
@@ -17,23 +17,16 @@
|
||||
#ifndef _Storage_BaseDriver_HeaderFile
|
||||
#define _Storage_BaseDriver_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <Storage_OpenMode.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Storage_Error.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Storage_Data.hxx>
|
||||
#include <Storage_Position.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_SequenceOfAsciiString.hxx>
|
||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
||||
#include <Standard_Character.hxx>
|
||||
#include <Standard_ExtCharacter.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_ShortReal.hxx>
|
||||
|
||||
class Storage_StreamTypeMismatchError;
|
||||
class Storage_StreamFormatError;
|
||||
class Storage_StreamWriteError;
|
||||
@@ -41,27 +34,32 @@ class Storage_StreamExtCharParityError;
|
||||
class TCollection_AsciiString;
|
||||
class TCollection_ExtendedString;
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Storage_BaseDriver,Standard_Transient)
|
||||
|
||||
//! Root class for drivers. A driver assigns a physical container
|
||||
//! to data to be stored or retrieved, for instance a file.
|
||||
//! The FSD package provides two derived concrete classes :
|
||||
//! - FSD_File is a general driver which defines a
|
||||
//! file as the container of data.
|
||||
class Storage_BaseDriver
|
||||
class Storage_BaseDriver : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_RTTIEXT(Storage_BaseDriver,Standard_Transient)
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
public:
|
||||
|
||||
Standard_EXPORT virtual ~Storage_BaseDriver();
|
||||
|
||||
Standard_EXPORT virtual Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode) = 0;
|
||||
TCollection_AsciiString Name() const { return myName; }
|
||||
|
||||
TCollection_AsciiString Name() const;
|
||||
|
||||
Storage_OpenMode OpenMode() const;
|
||||
Storage_OpenMode OpenMode() const { return myOpenMode; }
|
||||
|
||||
Standard_EXPORT static TCollection_AsciiString ReadMagicNumber (Standard_IStream& theIStream);
|
||||
Standard_EXPORT static TCollection_AsciiString ReadMagicNumber(Standard_IStream& theIStream);
|
||||
|
||||
public:
|
||||
//!@name Virtual methods, to be provided by descendants
|
||||
|
||||
Standard_EXPORT virtual Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode) = 0;
|
||||
|
||||
//! returns True if we are at end of the stream
|
||||
Standard_EXPORT virtual Standard_Boolean IsEnd() = 0;
|
||||
@@ -173,114 +171,102 @@ public:
|
||||
|
||||
Standard_EXPORT virtual void SkipObject() = 0;
|
||||
|
||||
Standard_EXPORT virtual Storage_Error Close() = 0;
|
||||
|
||||
public:
|
||||
//!@name Ouput methods
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutReference (const Standard_Integer aValue) = 0;
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutCharacter (const Standard_Character aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_Character aValue)
|
||||
{
|
||||
return PutCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutExtCharacter (const Standard_ExtCharacter aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue)
|
||||
{
|
||||
return PutExtCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutInteger (const Standard_Integer aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_Integer aValue)
|
||||
{
|
||||
return PutInteger(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutBoolean (const Standard_Boolean aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_Boolean aValue)
|
||||
{
|
||||
return PutBoolean(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutReal (const Standard_Real aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_Real aValue)
|
||||
{
|
||||
return PutReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutShortReal (const Standard_ShortReal aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_ShortReal aValue)
|
||||
{
|
||||
return PutShortReal(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& operator << (const Standard_Character aValue)
|
||||
{
|
||||
return PutCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue)
|
||||
{
|
||||
return PutExtCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutInteger(const Standard_Integer aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_Integer aValue)
|
||||
{
|
||||
return PutInteger(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_Boolean aValue)
|
||||
{
|
||||
return PutBoolean(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutReal(const Standard_Real aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_Real aValue)
|
||||
{
|
||||
return PutReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) = 0;
|
||||
Storage_BaseDriver& operator << (const Standard_ShortReal aValue)
|
||||
{
|
||||
return PutShortReal(aValue);
|
||||
}
|
||||
|
||||
public:
|
||||
//!@name Input methods
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetReference (Standard_Integer& aValue) = 0;
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetCharacter (Standard_Character& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_Character& aValue)
|
||||
{
|
||||
return GetCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue)
|
||||
{
|
||||
return GetExtCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetInteger (Standard_Integer& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_Integer& aValue)
|
||||
{
|
||||
return GetInteger(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_Boolean& aValue)
|
||||
{
|
||||
return GetBoolean(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetReal (Standard_Real& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_Real& aValue)
|
||||
{
|
||||
return GetReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetShortReal (Standard_ShortReal& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
|
||||
{
|
||||
return GetShortReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_Error Close() = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_Character& aValue)
|
||||
{
|
||||
return GetCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue)
|
||||
{
|
||||
return GetExtCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetInteger(Standard_Integer& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_Integer& aValue)
|
||||
{
|
||||
return GetInteger(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_Boolean& aValue)
|
||||
{
|
||||
return GetBoolean(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetReal(Standard_Real& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_Real& aValue)
|
||||
{
|
||||
return GetReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) = 0;
|
||||
Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
|
||||
{
|
||||
return GetShortReal(aValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver();
|
||||
|
||||
void SetName (const TCollection_AsciiString& aName);
|
||||
|
||||
void SetOpenMode (const Storage_OpenMode aMode);
|
||||
|
||||
|
||||
void SetName(const TCollection_AsciiString& aName) { myName = aName; }
|
||||
|
||||
void SetOpenMode(const Storage_OpenMode aMode) { myOpenMode = aMode; }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Storage_OpenMode myOpenMode;
|
||||
TCollection_AsciiString myName;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <Storage_BaseDriver.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Storage_BaseDriver_HeaderFile
|
||||
|
@@ -1,34 +0,0 @@
|
||||
// Copyright (c) 1998-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 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.
|
||||
|
||||
inline TCollection_AsciiString Storage_BaseDriver::Name() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
inline Storage_OpenMode Storage_BaseDriver::OpenMode() const
|
||||
{
|
||||
return myOpenMode;
|
||||
}
|
||||
|
||||
inline void Storage_BaseDriver::SetName(const TCollection_AsciiString& aName)
|
||||
{
|
||||
myName = aName;
|
||||
}
|
||||
|
||||
inline void Storage_BaseDriver::SetOpenMode(const Storage_OpenMode aMode)
|
||||
{
|
||||
myOpenMode = aMode;
|
||||
}
|
||||
|
@@ -29,42 +29,24 @@ class Storage_BaseDriver;
|
||||
class Storage_CallBack;
|
||||
DEFINE_STANDARD_HANDLE(Storage_CallBack, Standard_Transient)
|
||||
|
||||
|
||||
class Storage_CallBack : public Standard_Transient
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT virtual Handle(Standard_Persistent) New() const = 0;
|
||||
|
||||
Standard_EXPORT virtual void Add (const Handle(Standard_Persistent)& aPers, const Handle(Storage_Schema)& aSchema) const = 0;
|
||||
|
||||
Standard_EXPORT virtual void Write (const Handle(Standard_Persistent)& aPers, Storage_BaseDriver& aDriver, const Handle(Storage_Schema)& aSchema) const = 0;
|
||||
Standard_EXPORT virtual void Write (const Handle(Standard_Persistent)& aPers,
|
||||
const Handle(Storage_BaseDriver)& aDriver,
|
||||
const Handle(Storage_Schema)& aSchema) const = 0;
|
||||
|
||||
Standard_EXPORT virtual void Read (const Handle(Standard_Persistent)& aPers, Storage_BaseDriver& aDriver, const Handle(Storage_Schema)& aSchema) const = 0;
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT virtual void Read (const Handle(Standard_Persistent)& aPers,
|
||||
const Handle(Storage_BaseDriver)& aDriver,
|
||||
const Handle(Storage_Schema)& aSchema) const = 0;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Storage_CallBack,Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Storage_CallBack_HeaderFile
|
||||
|
@@ -36,11 +36,15 @@ void Storage_DefaultCallBack::Add(const Handle(Standard_Persistent)&, const Hand
|
||||
{
|
||||
}
|
||||
|
||||
void Storage_DefaultCallBack::Write(const Handle(Standard_Persistent)&,Storage_BaseDriver&,const Handle(Storage_Schema)&) const
|
||||
void Storage_DefaultCallBack::Write(const Handle(Standard_Persistent)&,
|
||||
const Handle(Storage_BaseDriver)&,
|
||||
const Handle(Storage_Schema)&) const
|
||||
{
|
||||
}
|
||||
|
||||
void Storage_DefaultCallBack::Read(const Handle(Standard_Persistent)&,Storage_BaseDriver& f,const Handle(Storage_Schema)&) const
|
||||
void Storage_DefaultCallBack::Read(const Handle(Standard_Persistent)&,
|
||||
const Handle(Storage_BaseDriver)& theDriver,
|
||||
const Handle(Storage_Schema)&) const
|
||||
{
|
||||
f.SkipObject();
|
||||
theDriver->SkipObject();
|
||||
}
|
||||
|
@@ -24,49 +24,30 @@
|
||||
class Standard_Persistent;
|
||||
class Storage_Schema;
|
||||
class Storage_BaseDriver;
|
||||
|
||||
|
||||
class Storage_DefaultCallBack;
|
||||
DEFINE_STANDARD_HANDLE(Storage_DefaultCallBack, Storage_CallBack)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Storage_DefaultCallBack, Storage_CallBack)
|
||||
|
||||
class Storage_DefaultCallBack : public Storage_CallBack
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT Storage_DefaultCallBack();
|
||||
|
||||
Standard_EXPORT Handle(Standard_Persistent) New() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void Add (const Handle(Standard_Persistent)& aPers, const Handle(Storage_Schema)& aSchema) const Standard_OVERRIDE;
|
||||
Standard_EXPORT void Add (const Handle(Standard_Persistent)& thePers,
|
||||
const Handle(Storage_Schema)& theSchema) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void Write (const Handle(Standard_Persistent)& aPers, Storage_BaseDriver& aDriver, const Handle(Storage_Schema)& aSchema) const Standard_OVERRIDE;
|
||||
Standard_EXPORT void Write (const Handle(Standard_Persistent)& thePers,
|
||||
const Handle(Storage_BaseDriver)& theDriver,
|
||||
const Handle(Storage_Schema)& theSchema) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void Read (const Handle(Standard_Persistent)& aPers, Storage_BaseDriver& aDriver, const Handle(Storage_Schema)& aSchema) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT void Read (const Handle(Standard_Persistent)& thePers,
|
||||
const Handle(Storage_BaseDriver)& theDriver,
|
||||
const Handle(Storage_Schema)& theSchema) const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Storage_DefaultCallBack,Storage_CallBack)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Storage_DefaultCallBack_HeaderFile
|
||||
|
@@ -27,11 +27,11 @@ Storage_HeaderData::Storage_HeaderData() : myNBObj(0), myErrorStatus(Storage_VSO
|
||||
{
|
||||
}
|
||||
|
||||
Standard_Boolean Storage_HeaderData::Read (Storage_BaseDriver& theDriver)
|
||||
Standard_Boolean Storage_HeaderData::Read (const Handle(Storage_BaseDriver)& theDriver)
|
||||
{
|
||||
// Check driver open mode
|
||||
if (theDriver.OpenMode() != Storage_VSRead
|
||||
&& theDriver.OpenMode() != Storage_VSReadWrite)
|
||||
if (theDriver->OpenMode() != Storage_VSRead
|
||||
&& theDriver->OpenMode() != Storage_VSReadWrite)
|
||||
{
|
||||
myErrorStatus = Storage_VSModeError;
|
||||
myErrorStatusExt = "OpenMode";
|
||||
@@ -39,7 +39,7 @@ Standard_Boolean Storage_HeaderData::Read (Storage_BaseDriver& theDriver)
|
||||
}
|
||||
|
||||
// Read info section
|
||||
myErrorStatus = theDriver.BeginReadInfoSection();
|
||||
myErrorStatus = theDriver->BeginReadInfoSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "BeginReadInfoSection";
|
||||
@@ -50,15 +50,8 @@ Standard_Boolean Storage_HeaderData::Read (Storage_BaseDriver& theDriver)
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.ReadInfo (myNBObj,
|
||||
myStorageVersion,
|
||||
myDate,
|
||||
mySchemaName,
|
||||
mySchemaVersion,
|
||||
myApplicationName,
|
||||
myApplicationVersion,
|
||||
myDataType,
|
||||
myUserInfo);
|
||||
theDriver->ReadInfo (myNBObj, myStorageVersion, myDate, mySchemaName, mySchemaVersion,
|
||||
myApplicationName, myApplicationVersion, myDataType, myUserInfo);
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError const&)
|
||||
{
|
||||
@@ -74,7 +67,7 @@ Standard_Boolean Storage_HeaderData::Read (Storage_BaseDriver& theDriver)
|
||||
}
|
||||
}
|
||||
|
||||
myErrorStatus = theDriver.EndReadInfoSection();
|
||||
myErrorStatus = theDriver->EndReadInfoSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "EndReadInfoSection";
|
||||
@@ -82,7 +75,7 @@ Standard_Boolean Storage_HeaderData::Read (Storage_BaseDriver& theDriver)
|
||||
}
|
||||
|
||||
// Read comment section
|
||||
myErrorStatus = theDriver.BeginReadCommentSection();
|
||||
myErrorStatus = theDriver->BeginReadCommentSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "BeginReadCommentSection";
|
||||
@@ -93,7 +86,7 @@ Standard_Boolean Storage_HeaderData::Read (Storage_BaseDriver& theDriver)
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.ReadComment (myComments);
|
||||
theDriver->ReadComment (myComments);
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError const&)
|
||||
{
|
||||
@@ -109,7 +102,7 @@ Standard_Boolean Storage_HeaderData::Read (Storage_BaseDriver& theDriver)
|
||||
}
|
||||
}
|
||||
|
||||
myErrorStatus = theDriver.EndReadCommentSection();
|
||||
myErrorStatus = theDriver->EndReadCommentSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "EndReadCommentSection";
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
Standard_EXPORT Storage_HeaderData();
|
||||
|
||||
Standard_EXPORT Standard_Boolean Read (Storage_BaseDriver& theDriver);
|
||||
Standard_EXPORT Standard_Boolean Read (const Handle(Storage_BaseDriver)& theDriver);
|
||||
|
||||
//! return the creation date
|
||||
Standard_EXPORT TCollection_AsciiString CreationDate() const;
|
||||
|
@@ -29,11 +29,11 @@ Storage_RootData::Storage_RootData() : myErrorStatus(Storage_VSOk)
|
||||
{
|
||||
}
|
||||
|
||||
Standard_Boolean Storage_RootData::Read (Storage_BaseDriver& theDriver)
|
||||
Standard_Boolean Storage_RootData::Read (const Handle(Storage_BaseDriver)& theDriver)
|
||||
{
|
||||
// Check driver open mode
|
||||
if (theDriver.OpenMode() != Storage_VSRead
|
||||
&& theDriver.OpenMode() != Storage_VSReadWrite)
|
||||
if (theDriver->OpenMode() != Storage_VSRead
|
||||
&& theDriver->OpenMode() != Storage_VSReadWrite)
|
||||
{
|
||||
myErrorStatus = Storage_VSModeError;
|
||||
myErrorStatusExt = "OpenMode";
|
||||
@@ -41,7 +41,7 @@ Standard_Boolean Storage_RootData::Read (Storage_BaseDriver& theDriver)
|
||||
}
|
||||
|
||||
// Read root section
|
||||
myErrorStatus = theDriver.BeginReadRootSection();
|
||||
myErrorStatus = theDriver->BeginReadRootSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "BeginReadRootSection";
|
||||
@@ -51,13 +51,13 @@ Standard_Boolean Storage_RootData::Read (Storage_BaseDriver& theDriver)
|
||||
TCollection_AsciiString aRootName, aTypeName;
|
||||
Standard_Integer aRef;
|
||||
|
||||
Standard_Integer len = theDriver.RootSectionSize();
|
||||
Standard_Integer len = theDriver->RootSectionSize();
|
||||
for (Standard_Integer i = 1; i <= len; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.ReadRoot (aRootName, aRef, aTypeName);
|
||||
theDriver->ReadRoot (aRootName, aRef, aTypeName);
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError const&)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ Standard_Boolean Storage_RootData::Read (Storage_BaseDriver& theDriver)
|
||||
myObjects.Bind (aRootName, aRoot);
|
||||
}
|
||||
|
||||
myErrorStatus = theDriver.EndReadRootSection();
|
||||
myErrorStatus = theDriver->EndReadRootSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "EndReadRootSection";
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
Standard_EXPORT Storage_RootData();
|
||||
|
||||
Standard_EXPORT Standard_Boolean Read (Storage_BaseDriver& theDriver);
|
||||
Standard_EXPORT Standard_Boolean Read (const Handle(Storage_BaseDriver)& theDriver);
|
||||
|
||||
//! returns the number of roots.
|
||||
Standard_EXPORT Standard_Integer NumberOfRoots() const;
|
||||
|
@@ -340,9 +340,8 @@ TCollection_AsciiString Storage_Schema::Name() const
|
||||
// VSReadWrite
|
||||
//=======================================================================
|
||||
|
||||
void Storage_Schema::Write
|
||||
(Storage_BaseDriver& f,
|
||||
const Handle(Storage_Data)& aData) const
|
||||
void Storage_Schema::Write (const Handle(Storage_BaseDriver)& theDriver,
|
||||
const Handle(Storage_Data)& aData) const
|
||||
{
|
||||
if (aData.IsNull()) return;
|
||||
|
||||
@@ -384,42 +383,42 @@ void Storage_Schema::Write
|
||||
aData->HeaderData()->SetSchemaName(myName);
|
||||
aData->HeaderData()->SetSchemaVersion(myVersion);
|
||||
|
||||
if ((f.OpenMode() == Storage_VSWrite) || (f.OpenMode() == Storage_VSReadWrite)) {
|
||||
if ((theDriver->OpenMode() == Storage_VSWrite) || (theDriver->OpenMode() == Storage_VSReadWrite)) {
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
errorContext = "BeginWriteInfoSection";
|
||||
f.BeginWriteInfoSection();
|
||||
theDriver->BeginWriteInfoSection();
|
||||
errorContext = "WriteInfo";
|
||||
f.WriteInfo(aData->NumberOfObjects(),
|
||||
aData->StorageVersion(),
|
||||
aData->CreationDate(),
|
||||
aData->SchemaName(),
|
||||
aData->SchemaVersion(),
|
||||
aData->ApplicationName(),
|
||||
aData->ApplicationVersion(),
|
||||
aData->DataType(),
|
||||
aData->UserInfo());
|
||||
theDriver->WriteInfo(aData->NumberOfObjects(),
|
||||
aData->StorageVersion(),
|
||||
aData->CreationDate(),
|
||||
aData->SchemaName(),
|
||||
aData->SchemaVersion(),
|
||||
aData->ApplicationName(),
|
||||
aData->ApplicationVersion(),
|
||||
aData->DataType(),
|
||||
aData->UserInfo());
|
||||
errorContext = "EndWriteInfoSection";
|
||||
f.EndWriteInfoSection();
|
||||
theDriver->EndWriteInfoSection();
|
||||
|
||||
errorContext = "BeginWriteCommentSection";
|
||||
f.BeginWriteCommentSection();
|
||||
theDriver->BeginWriteCommentSection();
|
||||
errorContext = "WriteComment";
|
||||
f.WriteComment(aData->Comments());
|
||||
theDriver->WriteComment(aData->Comments());
|
||||
errorContext = "EndWriteCommentSection";
|
||||
f.EndWriteCommentSection();
|
||||
theDriver->EndWriteCommentSection();
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) tlist;
|
||||
|
||||
tlist = aData->Types();
|
||||
|
||||
errorContext = "BeginWriteTypeSection";
|
||||
f.BeginWriteTypeSection();
|
||||
theDriver->BeginWriteTypeSection();
|
||||
len = aData->NumberOfTypes();
|
||||
|
||||
Handle(Storage_HArrayOfCallBack) WFunc = new Storage_HArrayOfCallBack(1,len);
|
||||
|
||||
f.SetTypeSectionSize(len);
|
||||
theDriver->SetTypeSectionSize(len);
|
||||
|
||||
Storage_DataMapIteratorOfMapOfCallBack cbit(iData->myTypeBinding);
|
||||
Handle(Storage_TypedCallBack) atcallBack;
|
||||
@@ -431,42 +430,42 @@ void Storage_Schema::Write
|
||||
|
||||
errorContext = "WriteTypeInformations";
|
||||
for (i = 1; i <= len; i++) {
|
||||
f.WriteTypeInformations(i,tlist->Value(i).ToCString());
|
||||
theDriver->WriteTypeInformations(i,tlist->Value(i).ToCString());
|
||||
}
|
||||
|
||||
errorContext = "EndWriteTypeSection";
|
||||
f.EndWriteTypeSection();
|
||||
theDriver->EndWriteTypeSection();
|
||||
|
||||
errorContext = "BeginWriteRootSection";
|
||||
f.BeginWriteRootSection();
|
||||
f.SetRootSectionSize(plist->Length());
|
||||
theDriver->BeginWriteRootSection();
|
||||
theDriver->SetRootSectionSize(plist->Length());
|
||||
|
||||
errorContext = "WriteRoot";
|
||||
for (i = 1; i <= plist->Length(); i++) {
|
||||
f.WriteRoot(plist->Value(i)->Name(),i,"PDocStd_Document");
|
||||
theDriver->WriteRoot(plist->Value(i)->Name(),i,"PDocStd_Document");
|
||||
}
|
||||
|
||||
errorContext = "EndWriteRootSection";
|
||||
f.EndWriteRootSection();
|
||||
theDriver->EndWriteRootSection();
|
||||
|
||||
errorContext = "BeginWriteRefSection";
|
||||
f.BeginWriteRefSection();
|
||||
f.SetRefSectionSize(iData->myObjId - 1);
|
||||
theDriver->BeginWriteRefSection();
|
||||
theDriver->SetRefSectionSize(iData->myObjId - 1);
|
||||
errorContext = "WriteReferenceType";
|
||||
|
||||
Storage_BucketIterator bit(&iData->myPtoA);
|
||||
|
||||
while(bit.More()) {
|
||||
p = bit.Value();
|
||||
if (!p.IsNull()) f.WriteReferenceType(p->_refnum,p->_typenum);
|
||||
if (!p.IsNull()) theDriver->WriteReferenceType(p->_refnum,p->_typenum);
|
||||
bit.Next();
|
||||
}
|
||||
|
||||
errorContext = "EndWriteRefSection";
|
||||
f.EndWriteRefSection();
|
||||
theDriver->EndWriteRefSection();
|
||||
|
||||
errorContext = "BeginWriteDataSection";
|
||||
f.BeginWriteDataSection();
|
||||
theDriver->BeginWriteDataSection();
|
||||
|
||||
Handle(Storage_Schema) me = this;
|
||||
|
||||
@@ -477,14 +476,14 @@ void Storage_Schema::Write
|
||||
while(bit.More()) {
|
||||
p = bit.Value();
|
||||
if (!p.IsNull()) {
|
||||
WFunc->Value(p->_typenum)->Write(p,f,me);
|
||||
WFunc->Value(p->_typenum)->Write(p, theDriver, me);
|
||||
p->_typenum = 0;
|
||||
}
|
||||
bit.Next();
|
||||
}
|
||||
|
||||
errorContext = "EndWriteDataSection";
|
||||
f.EndWriteDataSection();
|
||||
theDriver->EndWriteDataSection();
|
||||
}
|
||||
catch(Storage_StreamWriteError const&) {
|
||||
aData->SetErrorStatus(Storage_VSWriteError);
|
||||
|
@@ -17,18 +17,15 @@
|
||||
#ifndef _Storage_Schema_HeaderFile
|
||||
#define _Storage_Schema_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <Storage_MapOfCallBack.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
#include <Storage_HArrayOfSchema.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Storage_InternalData.hxx>
|
||||
#include <Storage_MapOfCallBack.hxx>
|
||||
#include <Storage_SolveMode.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_SequenceOfAsciiString.hxx>
|
||||
#include <TColStd_HSequenceOfAsciiString.hxx>
|
||||
#include <Storage_SolveMode.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
|
||||
class Storage_CallBack;
|
||||
class Storage_StreamFormatError;
|
||||
class TCollection_AsciiString;
|
||||
@@ -105,7 +102,7 @@ public:
|
||||
//! schema with which this algorithm is working.
|
||||
//! Note: aData may aggregate several root objects
|
||||
//! to be stored together.
|
||||
Standard_EXPORT void Write (Storage_BaseDriver& s, const Handle(Storage_Data)& aData) const;
|
||||
Standard_EXPORT void Write (const Handle(Storage_BaseDriver)& s, const Handle(Storage_Data)& aData) const;
|
||||
|
||||
//! return a current date string
|
||||
Standard_EXPORT static TCollection_AsciiString ICreationDate();
|
||||
@@ -160,22 +157,28 @@ public:
|
||||
//! UseDefaultCallBack() is set.
|
||||
Standard_EXPORT Handle(Storage_CallBack) DefaultCallBack() const;
|
||||
|
||||
void WritePersistentObjectHeader (const Handle(Standard_Persistent)& sp, Storage_BaseDriver& s);
|
||||
|
||||
void WritePersistentReference (const Handle(Standard_Persistent)& sp, Storage_BaseDriver& s);
|
||||
void WritePersistentObjectHeader(const Handle(Standard_Persistent)& sp, const Handle(Storage_BaseDriver)& theDriver)
|
||||
{
|
||||
theDriver->WritePersistentObjectHeader(sp->_refnum, sp->_typenum);
|
||||
}
|
||||
|
||||
void WritePersistentReference(const Handle(Standard_Persistent)& sp, const Handle(Storage_BaseDriver)& theDriver)
|
||||
{
|
||||
theDriver->PutReference(sp.IsNull() ? 0 : sp->_refnum);
|
||||
}
|
||||
|
||||
Standard_EXPORT Standard_Boolean AddPersistent (const Handle(Standard_Persistent)& sp, const Standard_CString tName) const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean PersistentToAdd (const Handle(Standard_Persistent)& sp) const;
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Storage_Schema,Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Boolean HasTypeBinding (const TCollection_AsciiString& aTypeName) const;
|
||||
Standard_Boolean HasTypeBinding(const TCollection_AsciiString& aTypeName) const
|
||||
{
|
||||
return Storage_Schema::ICurrentData()->InternalData()->myTypeBinding.IsBound(aTypeName);
|
||||
}
|
||||
|
||||
Standard_EXPORT void BindType (const TCollection_AsciiString& aTypeName, const Handle(Storage_CallBack)& aCallBack) const;
|
||||
|
||||
@@ -198,11 +201,4 @@ private:
|
||||
TCollection_AsciiString myVersion;
|
||||
};
|
||||
|
||||
|
||||
#include <Storage_Schema.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Storage_Schema_HeaderFile
|
||||
|
@@ -1,39 +0,0 @@
|
||||
// Copyright (c) 1998-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 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 <Storage_Data.hxx>
|
||||
#include <Storage_InternalData.hxx>
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
|
||||
|
||||
inline void Storage_Schema::WritePersistentObjectHeader(const Handle(Standard_Persistent)& sp,Storage_BaseDriver& f)
|
||||
{
|
||||
f.WritePersistentObjectHeader(sp->_refnum,sp->_typenum);
|
||||
}
|
||||
|
||||
inline Standard_Boolean Storage_Schema::HasTypeBinding(const TCollection_AsciiString& aTypeName) const
|
||||
{
|
||||
return Storage_Schema::ICurrentData()->InternalData()->myTypeBinding.IsBound(aTypeName);
|
||||
}
|
||||
|
||||
inline void Storage_Schema::WritePersistentReference(const Handle(Standard_Persistent)& sp,Storage_BaseDriver& f)
|
||||
{
|
||||
if (!sp.IsNull()) {
|
||||
f.PutReference(sp->_refnum);
|
||||
}
|
||||
else {
|
||||
f.PutReference(0);
|
||||
}
|
||||
}
|
||||
|
@@ -26,11 +26,11 @@ Storage_TypeData::Storage_TypeData() : myErrorStatus(Storage_VSOk)
|
||||
{
|
||||
}
|
||||
|
||||
Standard_Boolean Storage_TypeData::Read (Storage_BaseDriver& theDriver)
|
||||
Standard_Boolean Storage_TypeData::Read (const Handle(Storage_BaseDriver)& theDriver)
|
||||
{
|
||||
// Check driver open mode
|
||||
if (theDriver.OpenMode() != Storage_VSRead
|
||||
&& theDriver.OpenMode() != Storage_VSReadWrite)
|
||||
if (theDriver->OpenMode() != Storage_VSRead
|
||||
&& theDriver->OpenMode() != Storage_VSReadWrite)
|
||||
{
|
||||
myErrorStatus = Storage_VSModeError;
|
||||
myErrorStatusExt = "OpenMode";
|
||||
@@ -38,7 +38,7 @@ Standard_Boolean Storage_TypeData::Read (Storage_BaseDriver& theDriver)
|
||||
}
|
||||
|
||||
// Read type section
|
||||
myErrorStatus = theDriver.BeginReadTypeSection();
|
||||
myErrorStatus = theDriver->BeginReadTypeSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "BeginReadTypeSection";
|
||||
@@ -48,13 +48,13 @@ Standard_Boolean Storage_TypeData::Read (Storage_BaseDriver& theDriver)
|
||||
Standard_Integer aTypeNum;
|
||||
TCollection_AsciiString aTypeName;
|
||||
|
||||
Standard_Integer len = theDriver.TypeSectionSize();
|
||||
Standard_Integer len = theDriver->TypeSectionSize();
|
||||
for (Standard_Integer i = 1; i <= len; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.ReadTypeInformations (aTypeNum, aTypeName);
|
||||
theDriver->ReadTypeInformations (aTypeNum, aTypeName);
|
||||
}
|
||||
catch (const Storage_StreamTypeMismatchError&)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ Standard_Boolean Storage_TypeData::Read (Storage_BaseDriver& theDriver)
|
||||
myPt.Add (aTypeName, aTypeNum);
|
||||
}
|
||||
|
||||
myErrorStatus = theDriver.EndReadTypeSection();
|
||||
myErrorStatus = theDriver->EndReadTypeSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "EndReadTypeSection";
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
Standard_EXPORT Storage_TypeData();
|
||||
|
||||
Standard_EXPORT Standard_Boolean Read (Storage_BaseDriver& theDriver);
|
||||
Standard_EXPORT Standard_Boolean Read (const Handle(Storage_BaseDriver)& theDriver);
|
||||
|
||||
Standard_EXPORT Standard_Integer NumberOfTypes() const;
|
||||
|
||||
|
Reference in New Issue
Block a user