0026961: Recover possibility to read files in old persistence format
[occt.git] / src / StdObjMgt / StdObjMgt_Persistent.hxx
1 // Copyright (c) 2015 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _StdObjMgt_Persistent_HeaderFile
15 #define _StdObjMgt_Persistent_HeaderFile
16
17
18 #include <Standard.hxx>
19 #include <Standard_Handle.hxx>
20 #include <Standard_Transient.hxx>
21 #include <StdObjMgt_ContentTypes.hxx>
22
23 #include <TDF_Label.hxx>
24
25 class StdObjMgt_ReadData;
26 class TDocStd_Document;
27 class TDF_Attribute;
28 class TDF_Data;
29 class TCollection_HAsciiString;
30 class TCollection_HExtendedString;
31
32
33 //! Root class for a temporary persistent object that reads data from a file
34 //! and then creates transient object using the data.
35 class StdObjMgt_Persistent : public    Standard_Transient,
36                              protected StdObjMgt_ContentTypes
37 {
38 public:
39   //! Derived class instance create function.
40   typedef Handle(StdObjMgt_Persistent) (*Instantiator)();
41
42   //! Create a derived class instance.
43   template <class Persistent>
44   static Handle(StdObjMgt_Persistent) Instantiate()
45     { return new Persistent; }
46
47   //! Read persistent data from a file.
48   Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData) = 0;
49
50   //! Import transient document from the persistent data
51   //! (to be overriden by document class;
52   //! does nothing by default for other classes).
53   Standard_EXPORT virtual void ImportDocument
54     (const Handle(TDocStd_Document)& theDocument) const;
55
56   //! Create an empty transient attribuite
57   //! (to be overriden by attribute classes;
58   //! does nothing and returns a null handle by default for other classes).
59   Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
60
61   //! Get transient attribuite for the persistent data
62   //! (to be overriden by attribute classes;
63   //! returns a null handle by default for non-attribute classes).
64   Standard_EXPORT virtual Handle(TDF_Attribute) GetAttribute() const;
65
66   //! Import transient attribuite from the persistent data
67   //! (to be overriden by attribute classes;
68   //! does nothing by default for non-attribute classes).
69   Standard_EXPORT virtual void ImportAttribute();
70
71   //! Get referenced ASCII string
72   //! (to be overriden by ASCII string class;
73   //! returns a null handle by default for other classes).
74   Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const;
75
76   //! Get referenced extended string
77   //! (to be overriden by extended string class;
78   //! returns a null handle by default for other classes).
79   Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const;
80
81   //! Get a label expressed by referenced extended string
82   //! (to be overriden by extended string class;
83   //! returns a null label by default for other classes).
84   Standard_EXPORT virtual TDF_Label Label (const Handle(TDF_Data)& theDF) const;
85 };
86
87 #endif // _StdObjMgt_Persistent_HeaderFile