Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-12 08:32:46

0001 // Copyright (c) 2015 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _StdObjMgt_Persistent_HeaderFile
0015 #define _StdObjMgt_Persistent_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_Handle.hxx>
0019 #include <Standard_Transient.hxx>
0020 #include <NCollection_Sequence.hxx>
0021 
0022 #include <TDF_Label.hxx>
0023 
0024 class StdObjMgt_ReadData;
0025 class StdObjMgt_WriteData;
0026 class TDocStd_Document;
0027 class TDF_Attribute;
0028 class TDF_Data;
0029 class TCollection_HAsciiString;
0030 class TCollection_HExtendedString;
0031 
0032 //! Root class for a temporary persistent object that reads data from a file
0033 //! and then creates transient object using the data.
0034 class StdObjMgt_Persistent : public Standard_Transient
0035 {
0036 public:
0037   Standard_EXPORT StdObjMgt_Persistent();
0038 
0039   //! Derived class instance create function.
0040   typedef Handle(StdObjMgt_Persistent) (*Instantiator)();
0041 
0042   //! Create a derived class instance.
0043   template <class Persistent>
0044   static Handle(StdObjMgt_Persistent) Instantiate()
0045   {
0046     return new Persistent;
0047   }
0048 
0049   //! Read persistent data from a file.
0050   virtual void Read(StdObjMgt_ReadData& theReadData) = 0;
0051 
0052   //! Write persistent data to a file.
0053   virtual void Write(StdObjMgt_WriteData& theWriteData) const = 0;
0054 
0055   typedef NCollection_Sequence<Handle(StdObjMgt_Persistent)> SequenceOfPersistent;
0056 
0057   //! Gets persistent child objects
0058   virtual void PChildren(SequenceOfPersistent&) const = 0;
0059 
0060   //! Returns persistent type name
0061   virtual Standard_CString PName() const = 0;
0062 
0063   //! Import transient document from the persistent data
0064   //! (to be overridden by document class;
0065   //! does nothing by default for other classes).
0066   Standard_EXPORT virtual void ImportDocument(const Handle(TDocStd_Document)& theDocument) const;
0067 
0068   //! Create an empty transient attribute
0069   //! (to be overridden by attribute classes;
0070   //! does nothing and returns a null handle by default for other classes).
0071   Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
0072 
0073   //! Get transient attribute for the persistent data
0074   //! (to be overridden by attribute classes;
0075   //! returns a null handle by default for non-attribute classes).
0076   Standard_EXPORT virtual Handle(TDF_Attribute) GetAttribute() const;
0077 
0078   //! Import transient attribute from the persistent data
0079   //! (to be overridden by attribute classes;
0080   //! does nothing by default for non-attribute classes).
0081   Standard_EXPORT virtual void ImportAttribute();
0082 
0083   //! Get referenced ASCII string
0084   //! (to be overridden by ASCII string class;
0085   //! returns a null handle by default for other classes).
0086   Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const;
0087 
0088   //! Get referenced extended string
0089   //! (to be overridden by extended string class;
0090   //! returns a null handle by default for other classes).
0091   Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const;
0092 
0093   //! Get a label expressed by referenced extended string
0094   //! (to be overridden by extended string class;
0095   //! returns a null label by default for other classes).
0096   Standard_EXPORT virtual TDF_Label Label(const Handle(TDF_Data)& theDF) const;
0097 
0098   //! Returns the assigned persistent type number
0099   Standard_Integer TypeNum() const { return myTypeNum; }
0100 
0101   //! Assigns a persistent type number to the object
0102   void TypeNum(Standard_Integer theTypeNum) { myTypeNum = theTypeNum; }
0103 
0104   //! Returns the object reference number
0105   Standard_Integer RefNum() const { return myRefNum; }
0106 
0107   //! Sets an object reference number
0108   void RefNum(Standard_Integer theRefNum) { myRefNum = theRefNum; }
0109 
0110 private:
0111   Standard_Integer myTypeNum;
0112   Standard_Integer myRefNum;
0113 };
0114 
0115 #endif // _StdObjMgt_Persistent_HeaderFile