1 // Copyright (c) 2017 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _StdStorage_TypeData_HeaderFile
15 #define _StdStorage_TypeData_HeaderFile
17 #include <Standard.hxx>
18 #include <Standard_Type.hxx>
20 #include <StdStorage_MapOfTypes.hxx>
21 #include <Storage_Error.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <Standard_Transient.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <StdObjMgt_MapOfInstantiators.hxx>
27 #include <TColStd_HSequenceOfAsciiString.hxx>
28 class Standard_NoSuchObject;
29 class Storage_BaseDriver;
30 class TCollection_AsciiString;
32 class StdStorage_TypeData;
33 DEFINE_STANDARD_HANDLE(StdStorage_TypeData, Standard_Transient)
35 //! Storage type data section keeps association between
36 //! persistent textual types and their numbers
37 class StdStorage_TypeData
38 : public Standard_Transient
40 friend class StdStorage_Data;
44 DEFINE_STANDARD_RTTIEXT(StdStorage_TypeData, Standard_Transient)
46 //! Reads the type data section from the container defined by theDriver.
47 //! Returns Standard_True in case of success. Otherwise, one need to get
48 //! an error code and description using ErrorStatus and ErrorStatusExtension
49 //! functions correspondingly.
50 Standard_EXPORT Standard_Boolean Read(Storage_BaseDriver& theDriver);
52 //! Writes the type data section to the container defined by theDriver.
53 //! Returns Standard_True in case of success. Otherwise, one need to get
54 //! an error code and description using ErrorStatus and ErrorStatusExtension
55 //! functions correspondingly.
56 Standard_EXPORT Standard_Boolean Write(Storage_BaseDriver& theDriver);
58 //! Returns the number of registered types
59 Standard_EXPORT Standard_Integer NumberOfTypes() const;
61 //! Add a type to the list in case of reading data
62 Standard_EXPORT void AddType (const TCollection_AsciiString& aTypeName, const Standard_Integer aTypeNum);
64 //! Add a type of the persistent object in case of writing data
65 Standard_EXPORT Standard_Integer AddType (const Handle(StdObjMgt_Persistent)& aPObj);
67 //! Returns the name of the type with number <aTypeNum>
68 Standard_EXPORT TCollection_AsciiString Type (const Standard_Integer aTypeNum) const;
70 //! Returns the name of the type with number <aTypeNum>
71 Standard_EXPORT Standard_Integer Type (const TCollection_AsciiString& aTypeName) const;
73 //! Returns a persistent object instantiator of <aTypeName>
74 Standard_EXPORT StdObjMgt_Persistent::Instantiator Instantiator(const Standard_Integer aTypeNum) const;
76 //! Checks if <aName> is a registered type
77 Standard_EXPORT Standard_Boolean IsType (const TCollection_AsciiString& aName) const;
79 //! Returns a sequence of all registered types
80 Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) Types() const;
82 //! Returns a status of the latest call to Read / Write functions
83 Standard_EXPORT Storage_Error ErrorStatus() const;
85 //! Returns an error message if any of the latest call to Read / Write functions
86 Standard_EXPORT TCollection_AsciiString ErrorStatusExtension() const;
88 //! Clears error status
89 Standard_EXPORT void ClearErrorStatus();
91 //! Unregisters all types
92 Standard_EXPORT void Clear();
96 Standard_EXPORT StdStorage_TypeData();
98 Standard_EXPORT void SetErrorStatus (const Storage_Error anError);
100 Standard_EXPORT void SetErrorStatusExtension (const TCollection_AsciiString& anErrorExt);
102 Standard_Integer myTypeId;
103 StdObjMgt_MapOfInstantiators myMapOfPInst;
104 StdStorage_MapOfTypes myPt;
105 Storage_Error myErrorStatus;
106 TCollection_AsciiString myErrorStatusExt;
110 #endif // _StdStorage_TypeData_HeaderFile