ec964372 |
1 | // Copyright (c) 2017 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 _StdStorage_RootData_HeaderFile |
15 | #define _StdStorage_RootData_HeaderFile |
16 | |
17 | #include <Standard.hxx> |
18 | #include <Standard_Type.hxx> |
19 | |
20 | #include <Storage_Error.hxx> |
21 | #include <TCollection_AsciiString.hxx> |
25e59720 |
22 | #include <Standard_Transient.hxx> |
ec964372 |
23 | #include <Standard_Integer.hxx> |
24 | #include <StdStorage_MapOfRoots.hxx> |
25 | #include <StdStorage_HSequenceOfRoots.hxx> |
ec964372 |
26 | class Storage_BaseDriver; |
27 | class StdStorage_Root; |
ec964372 |
28 | |
29 | class StdStorage_RootData; |
25e59720 |
30 | DEFINE_STANDARD_HANDLE(StdStorage_RootData, Standard_Transient) |
ec964372 |
31 | |
32 | //! Storage root data section contains root persistent objects |
33 | class StdStorage_RootData |
25e59720 |
34 | : public Standard_Transient |
ec964372 |
35 | { |
36 | friend class StdStorage_Data; |
37 | |
38 | public: |
39 | |
25e59720 |
40 | DEFINE_STANDARD_RTTIEXT(StdStorage_RootData, Standard_Transient) |
ec964372 |
41 | |
42 | //! Reads the root data section from the container defined by theDriver. |
43 | //! Returns Standard_True in case of success. Otherwise, one need to get |
44 | //! an error code and description using ErrorStatus and ErrorStatusExtension |
45 | //! functions correspondingly. |
39c8dc70 |
46 | Standard_EXPORT Standard_Boolean Read(const Handle(Storage_BaseDriver)& theDriver); |
ec964372 |
47 | |
48 | //! Writes the root data section to the container defined by theDriver. |
49 | //! Returns Standard_True in case of success. Otherwise, one need to get |
50 | //! an error code and description using ErrorStatus and ErrorStatusExtension |
51 | //! functions correspondingly. |
39c8dc70 |
52 | Standard_EXPORT Standard_Boolean Write(const Handle(Storage_BaseDriver)& theDriver); |
ec964372 |
53 | |
54 | //! Returns the number of roots. |
55 | Standard_EXPORT Standard_Integer NumberOfRoots() const; |
56 | |
57 | //! Add a root to <me>. If a root with same name is present, it |
58 | //! will be replaced by <aRoot>. |
59 | Standard_EXPORT void AddRoot(const Handle(StdStorage_Root)& aRoot); |
60 | |
61 | //! Returns a sequence of all roots |
62 | Standard_EXPORT Handle(StdStorage_HSequenceOfRoots) Roots() const; |
63 | |
64 | //! Finds a root with name <aName>. |
65 | Standard_EXPORT Handle(StdStorage_Root) Find(const TCollection_AsciiString& aName) const; |
66 | |
67 | //! Returns Standard_True if <me> contains a root named <aName> |
68 | Standard_EXPORT Standard_Boolean IsRoot(const TCollection_AsciiString& aName) const; |
69 | |
70 | //! Removes the root named <aName>. |
71 | Standard_EXPORT void RemoveRoot(const TCollection_AsciiString& aName); |
72 | |
73 | //! Returns a status of the latest call to Read / Write functions |
74 | Standard_EXPORT Storage_Error ErrorStatus() const; |
75 | |
76 | //! Returns an error message if any of the latest call to Read / Write functions |
77 | Standard_EXPORT TCollection_AsciiString ErrorStatusExtension() const; |
78 | |
79 | //! Clears error status |
80 | Standard_EXPORT void ClearErrorStatus(); |
81 | |
82 | //! Removes all persistent root objects |
83 | Standard_EXPORT void Clear(); |
84 | |
85 | private: |
86 | |
87 | Standard_EXPORT StdStorage_RootData(); |
88 | |
89 | Standard_EXPORT void SetErrorStatus(const Storage_Error anError); |
90 | |
91 | Standard_EXPORT void SetErrorStatusExtension(const TCollection_AsciiString& anErrorExt); |
92 | |
93 | StdStorage_MapOfRoots myObjects; |
94 | Storage_Error myErrorStatus; |
95 | TCollection_AsciiString myErrorStatusExt; |
96 | |
97 | }; |
98 | |
99 | #endif // _StdStorage_RootData_HeaderFile |