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