Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:00

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 
0018 #include <Standard.hxx>
0019 #include <Standard_Handle.hxx>
0020 #include <Standard_Transient.hxx>
0021 #include <NCollection_Sequence.hxx>
0022 
0023 #include <TDF_Label.hxx>
0024 
0025 class StdObjMgt_ReadData;
0026 class StdObjMgt_WriteData;
0027 class TDocStd_Document;
0028 class TDF_Attribute;
0029 class TDF_Data;
0030 class TCollection_HAsciiString;
0031 class TCollection_HExtendedString;
0032 
0033 
0034 //! Root class for a temporary persistent object that reads data from a file
0035 //! and then creates transient object using the data.
0036 class StdObjMgt_Persistent : public Standard_Transient
0037 {
0038 public:
0039   Standard_EXPORT StdObjMgt_Persistent();
0040 
0041   //! Derived class instance create function.
0042   typedef Handle(StdObjMgt_Persistent) (*Instantiator)();
0043 
0044   //! Create a derived class instance.
0045   template <class Persistent>
0046   static Handle(StdObjMgt_Persistent) Instantiate()
0047     { return new Persistent; }
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
0067     (const Handle(TDocStd_Document)& theDocument) const;
0068 
0069   //! Create an empty transient attribute
0070   //! (to be overridden by attribute classes;
0071   //! does nothing and returns a null handle by default for other classes).
0072   Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
0073 
0074   //! Get transient attribute for the persistent data
0075   //! (to be overridden by attribute classes;
0076   //! returns a null handle by default for non-attribute classes).
0077   Standard_EXPORT virtual Handle(TDF_Attribute) GetAttribute() const;
0078 
0079   //! Import transient attribute from the persistent data
0080   //! (to be overridden by attribute classes;
0081   //! does nothing by default for non-attribute classes).
0082   Standard_EXPORT virtual void ImportAttribute();
0083 
0084   //! Get referenced ASCII string
0085   //! (to be overridden by ASCII string class;
0086   //! returns a null handle by default for other classes).
0087   Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const;
0088 
0089   //! Get referenced extended string
0090   //! (to be overridden by extended string class;
0091   //! returns a null handle by default for other classes).
0092   Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const;
0093 
0094   //! Get a label expressed by referenced extended string
0095   //! (to be overridden by extended string class;
0096   //! returns a null label by default for other classes).
0097   Standard_EXPORT virtual TDF_Label Label (const Handle(TDF_Data)& theDF) const;
0098 
0099   //! Returns the assigned persistent type number
0100   Standard_Integer TypeNum() const { return myTypeNum; }
0101 
0102   //! Assigns a persistent type number to the object
0103   void TypeNum(Standard_Integer theTypeNum) { myTypeNum = theTypeNum; }
0104 
0105   //! Returns the object reference number
0106   Standard_Integer RefNum() const { return myRefNum; }
0107 
0108   //! Sets an object reference number
0109   void RefNum(Standard_Integer theRefNum) { myRefNum = theRefNum; }
0110 
0111 private:
0112   Standard_Integer myTypeNum;
0113   Standard_Integer myRefNum;
0114 };
0115 
0116 #endif // _StdObjMgt_Persistent_HeaderFile