Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-03 08:34:11

0001 // Created on: 1997-02-06
0002 // Created by: Kernel
0003 // Copyright (c) 1997-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Storage_Data_HeaderFile
0018 #define _Storage_Data_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Storage_Error.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <TColStd_SequenceOfExtendedString.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <Storage_HSeqOfRoot.hxx>
0028 #include <TColStd_HSequenceOfAsciiString.hxx>
0029 class Storage_HeaderData;
0030 class Storage_RootData;
0031 class Storage_TypeData;
0032 class Storage_InternalData;
0033 class TCollection_ExtendedString;
0034 class Standard_Persistent;
0035 class Storage_Root;
0036 
0037 class Storage_Data;
0038 DEFINE_STANDARD_HANDLE(Storage_Data, Standard_Transient)
0039 
0040 //! A picture memorizing the data stored in a
0041 //! container (for example, in a file).
0042 //! A Storage_Data object represents either:
0043 //! -   persistent data to be written into a container,
0044 //! or
0045 //! -   persistent data which are read from a container.
0046 //! A Storage_Data object is used in both the
0047 //! storage and retrieval operations:
0048 //! -   Storage mechanism: create an empty
0049 //! Storage_Data object, then add successively
0050 //! persistent objects (roots) to be stored using
0051 //! the function AddRoot. When the set of data is
0052 //! complete, write it to a container using the
0053 //! function Write in your Storage_Schema
0054 //! storage/retrieval algorithm.
0055 //! -   Retrieval mechanism: a Storage_Data
0056 //! object is returned by the Read function from
0057 //! your Storage_Schema storage/retrieval
0058 //! algorithm. Use the functions NumberOfRoots
0059 //! and Roots to find the roots which were stored
0060 //! in the read container.
0061 //! The roots of a Storage_Data object may share
0062 //! references on objects. The shared internal
0063 //! references of a Storage_Data object are
0064 //! maintained by the storage/retrieval mechanism.
0065 //! Note: References shared by objects which are
0066 //! contained in two distinct Storage_Data objects
0067 //! are not maintained by the storage/retrieval
0068 //! mechanism: external references are not
0069 //! supported by Storage_Schema algorithm
0070 class Storage_Data : public Standard_Transient
0071 {
0072 
0073 public:
0074   //! Creates an empty set of data.
0075   //! You explicitly create a Storage_Data object
0076   //! when preparing the set of objects to be stored
0077   //! together in a container (for example, in a file).
0078   //! Then use the function AddRoot to add
0079   //! persistent objects to the set of data.
0080   //! A Storage_Data object is also returned by the
0081   //! Read function of a Storage_Schema
0082   //! storage/retrieval algorithm. Use the functions
0083   //! NumberOfRoots and Roots to find the roots
0084   //! which were stored in the read container.
0085   Standard_EXPORT Storage_Data();
0086 
0087   //! Returns Storage_VSOk if
0088   //! -   the last storage operation performed with the
0089   //! function Read, or
0090   //! -   the last retrieval operation performed with the function Write
0091   //! by a Storage_Schema algorithm, on this set of data was successful.
0092   //! If the storage or retrieval operation was not
0093   //! performed, the returned error status indicates the
0094   //! reason why the operation failed. The algorithm
0095   //! stops its analysis at the first detected error
0096   Standard_EXPORT Storage_Error ErrorStatus() const;
0097 
0098   //! Clears the error status positioned either by:
0099   //! -   the last storage operation performed with the
0100   //! Read function, or
0101   //! -   the last retrieval operation performed with the Write function
0102   //! by a Storage_Schema algorithm, on this set of data.
0103   //! This error status may be read by the function ErrorStatus.
0104   Standard_EXPORT void ClearErrorStatus();
0105 
0106   Standard_EXPORT TCollection_AsciiString ErrorStatusExtension() const;
0107 
0108   //! return the creation date
0109   Standard_EXPORT TCollection_AsciiString CreationDate() const;
0110 
0111   //! return the Storage package version
0112   Standard_EXPORT TCollection_AsciiString StorageVersion() const;
0113 
0114   //! get the version of the schema
0115   Standard_EXPORT TCollection_AsciiString SchemaVersion() const;
0116 
0117   //! get the schema's name
0118   Standard_EXPORT TCollection_AsciiString SchemaName() const;
0119 
0120   //! set the version of the application
0121   Standard_EXPORT void SetApplicationVersion(const TCollection_AsciiString& aVersion);
0122 
0123   //! get the version of the application
0124   Standard_EXPORT TCollection_AsciiString ApplicationVersion() const;
0125 
0126   //! set the name of the application
0127   Standard_EXPORT void SetApplicationName(const TCollection_ExtendedString& aName);
0128 
0129   //! get the name of the application
0130   Standard_EXPORT TCollection_ExtendedString ApplicationName() const;
0131 
0132   //! set the data type
0133   Standard_EXPORT void SetDataType(const TCollection_ExtendedString& aType);
0134 
0135   //! returns data type
0136   Standard_EXPORT TCollection_ExtendedString DataType() const;
0137 
0138   //! add <theUserInfo> to the user information
0139   Standard_EXPORT void AddToUserInfo(const TCollection_AsciiString& anInfo);
0140 
0141   //! return the user information
0142   Standard_EXPORT const TColStd_SequenceOfAsciiString& UserInfo() const;
0143 
0144   //! add <theUserInfo> to the user information
0145   Standard_EXPORT void AddToComments(const TCollection_ExtendedString& aComment);
0146 
0147   //! return the user information
0148   Standard_EXPORT const TColStd_SequenceOfExtendedString& Comments() const;
0149 
0150   //! the number of persistent objects
0151   //! Return:
0152   //! the number of persistent objects readed
0153   Standard_EXPORT Standard_Integer NumberOfObjects() const;
0154 
0155   //! Returns the number of root objects in this set of data.
0156   //! -   When preparing a storage operation, the
0157   //! result is the number of roots inserted into this
0158   //! set of data with the function AddRoot.
0159   //! -   When retrieving an object, the result is the
0160   //! number of roots stored in the read container.
0161   //! Use the Roots function to get these roots in a sequence.
0162   Standard_EXPORT Standard_Integer NumberOfRoots() const;
0163 
0164   //! add a persistent root to write. the name of the root
0165   //! is a driver reference number.
0166   Standard_EXPORT void AddRoot(const Handle(Standard_Persistent)& anObject) const;
0167 
0168   //! Adds the root anObject to this set of data.
0169   //! The name of the root is aName if given; if not, it
0170   //! will be a reference number assigned by the driver
0171   //! when writing the set of data into the container.
0172   //! When naming the roots, it is easier to retrieve
0173   //! objects by significant references rather than by
0174   //! references without any semantic values.
0175   Standard_EXPORT void AddRoot(const TCollection_AsciiString&     aName,
0176                                const Handle(Standard_Persistent)& anObject) const;
0177 
0178   //! Removes from this set of data the root object named aName.
0179   //! Warning
0180   //! Nothing is done if there is no root object whose
0181   //! name is aName in this set of data.
0182   Standard_EXPORT void RemoveRoot(const TCollection_AsciiString& aName);
0183 
0184   //! Returns the roots of this set of data in a sequence.
0185   //! -   When preparing a storage operation, the
0186   //! sequence contains the roots inserted into this
0187   //! set of data with the function AddRoot.
0188   //! -   When retrieving an object, the sequence
0189   //! contains the roots stored in the container read.
0190   //! -   An empty sequence is returned if there is no root in this set of data.
0191   Standard_EXPORT Handle(Storage_HSeqOfRoot) Roots() const;
0192 
0193   //! Gives the root object whose name is aName in
0194   //! this set of data. The returned object is a
0195   //! Storage_Root object, from which the object it
0196   //! encapsulates may be extracted.
0197   //! Warning
0198   //! A null handle is returned if there is no root object
0199   //! whose name is aName in this set of data.
0200   Standard_EXPORT Handle(Storage_Root) Find(const TCollection_AsciiString& aName) const;
0201 
0202   //! returns Standard_True if <me> contains a root named <aName>
0203   Standard_EXPORT Standard_Boolean IsRoot(const TCollection_AsciiString& aName) const;
0204 
0205   //! Returns the number of types of objects used in this set of data.
0206   Standard_EXPORT Standard_Integer NumberOfTypes() const;
0207 
0208   //! Returns true if this set of data contains an object of type aName.
0209   //! Persistent objects from this set of data must
0210   //! have types which are recognized by the
0211   //! Storage_Schema algorithm used to store or retrieve them.
0212   Standard_EXPORT Standard_Boolean IsType(const TCollection_AsciiString& aName) const;
0213 
0214   //! Gives the list of types of objects used in this set of data in a sequence.
0215   Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) Types() const;
0216 
0217   friend class Storage_Schema;
0218 
0219   DEFINE_STANDARD_RTTIEXT(Storage_Data, Standard_Transient)
0220 
0221   Standard_EXPORT Handle(Storage_HeaderData) HeaderData() const;
0222 
0223   Standard_EXPORT Handle(Storage_RootData) RootData() const;
0224 
0225   Standard_EXPORT Handle(Storage_TypeData) TypeData() const;
0226 
0227   Standard_EXPORT Handle(Storage_InternalData) InternalData() const;
0228 
0229   Standard_EXPORT void Clear() const;
0230 
0231 private:
0232   Standard_EXPORT void SetErrorStatus(const Storage_Error anError);
0233 
0234   Standard_EXPORT void SetErrorStatusExtension(const TCollection_AsciiString& anErrorExt);
0235 
0236   Handle(Storage_HeaderData)   myHeaderData;
0237   Handle(Storage_RootData)     myRootData;
0238   Handle(Storage_TypeData)     myTypeData;
0239   Handle(Storage_InternalData) myInternal;
0240   Storage_Error                myErrorStatus;
0241   TCollection_AsciiString      myErrorStatusExt;
0242 };
0243 
0244 #endif // _Storage_Data_HeaderFile