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 <StdObjMgt_MapOfInstantiators.hxx>
26 #include <TColStd_HSequenceOfAsciiString.hxx>
27 class Storage_BaseDriver;
29 class StdStorage_TypeData;
30 DEFINE_STANDARD_HANDLE(StdStorage_TypeData, Standard_Transient)
32 //! Storage type data section keeps association between
33 //! persistent textual types and their numbers
34 class StdStorage_TypeData
35 : public Standard_Transient
37 friend class StdStorage_Data;
41 DEFINE_STANDARD_RTTIEXT(StdStorage_TypeData, Standard_Transient)
43 //! Reads the type data section from the container defined by theDriver.
44 //! Returns Standard_True in case of success. Otherwise, one need to get
45 //! an error code and description using ErrorStatus and ErrorStatusExtension
46 //! functions correspondingly.
47 Standard_EXPORT Standard_Boolean Read(const Handle(Storage_BaseDriver)& theDriver);
49 //! Writes the type data section to the container defined by theDriver.
50 //! Returns Standard_True in case of success. Otherwise, one need to get
51 //! an error code and description using ErrorStatus and ErrorStatusExtension
52 //! functions correspondingly.
53 Standard_EXPORT Standard_Boolean Write(const Handle(Storage_BaseDriver)& theDriver);
55 //! Returns the number of registered types
56 Standard_EXPORT Standard_Integer NumberOfTypes() const;
58 //! Add a type to the list in case of reading data
59 Standard_EXPORT void AddType (const TCollection_AsciiString& aTypeName, const Standard_Integer aTypeNum);
61 //! Add a type of the persistent object in case of writing data
62 Standard_EXPORT Standard_Integer AddType (const Handle(StdObjMgt_Persistent)& aPObj);
64 //! Returns the name of the type with number <aTypeNum>
65 Standard_EXPORT TCollection_AsciiString Type (const Standard_Integer aTypeNum) const;
67 //! Returns the name of the type with number <aTypeNum>
68 Standard_EXPORT Standard_Integer Type (const TCollection_AsciiString& aTypeName) const;
70 //! Returns a persistent object instantiator of <aTypeName>
71 Standard_EXPORT StdObjMgt_Persistent::Instantiator Instantiator(const Standard_Integer aTypeNum) const;
73 //! Checks if <aName> is a registered type
74 Standard_EXPORT Standard_Boolean IsType (const TCollection_AsciiString& aName) const;
76 //! Returns a sequence of all registered types
77 Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) Types() const;
79 //! Returns a status of the latest call to Read / Write functions
80 Standard_EXPORT Storage_Error ErrorStatus() const;
82 //! Returns an error message if any of the latest call to Read / Write functions
83 Standard_EXPORT TCollection_AsciiString ErrorStatusExtension() const;
85 //! Clears error status
86 Standard_EXPORT void ClearErrorStatus();
88 //! Unregisters all types
89 Standard_EXPORT void Clear();
93 Standard_EXPORT StdStorage_TypeData();
95 Standard_EXPORT void SetErrorStatus (const Storage_Error anError);
97 Standard_EXPORT void SetErrorStatusExtension (const TCollection_AsciiString& anErrorExt);
99 Standard_Integer myTypeId;
100 StdObjMgt_MapOfInstantiators myMapOfPInst;
101 StdStorage_MapOfTypes myPt;
102 Storage_Error myErrorStatus;
103 TCollection_AsciiString myErrorStatusExt;
107 #endif // _StdStorage_TypeData_HeaderFile