1 // Created on: 1997-02-24
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Storage_Root_HeaderFile
18 #define _Storage_Root_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <Standard_Integer.hxx>
25 #include <MMgt_TShared.hxx>
26 class Standard_Persistent;
28 class TCollection_AsciiString;
32 DEFINE_STANDARD_HANDLE(Storage_Root, MMgt_TShared)
35 //! A root object extracted from a Storage_Data object.
36 //! A Storage_Root encapsulates a persistent
37 //! object which is a root of a Storage_Data object.
38 //! It contains additional information: the name and
39 //! the data type of the persistent object.
40 //! When retrieving a Storage_Data object from a
41 //! container (for example, a file) you access its
42 //! roots with the function Roots which returns a
43 //! sequence of root objects. The provided functions
44 //! allow you to request information about each root of the sequence.
45 //! You do not create explicit roots: when inserting
46 //! data in a Storage_Data object, you just provide
47 //! the persistent object and optionally its name to the function AddRoot.
48 class Storage_Root : public MMgt_TShared
54 Standard_EXPORT Storage_Root();
56 Standard_EXPORT Storage_Root(const TCollection_AsciiString& aName, const Handle(Standard_Persistent)& anObject);
58 Standard_EXPORT void SetName (const TCollection_AsciiString& aName);
61 //! Returns the name of this root object.
62 //! The name may have been given explicitly when
63 //! the root was inserted into the Storage_Data
64 //! object. If not, the name is a reference number
65 //! which was assigned automatically by the driver
66 //! when writing the set of data into the container.
67 //! When naming the roots, it is easier to retrieve
68 //! objects by significant references rather than by
69 //! references without any semantic values.
71 //! The returned string will be empty if you call this
72 //! function before having named this root object,
73 //! either explicitly, or when writing the set of data
74 //! into the container.
75 Standard_EXPORT TCollection_AsciiString Name() const;
77 Standard_EXPORT void SetObject (const Handle(Standard_Persistent)& anObject);
80 //! Returns the persistent object encapsulated by this root.
81 Standard_EXPORT Handle(Standard_Persistent) Object() const;
83 //! Returns the name of this root type.
84 Standard_EXPORT TCollection_AsciiString Type() const;
86 Standard_EXPORT void SetReference (const Standard_Integer aRef);
88 Standard_EXPORT Standard_Integer Reference() const;
90 Standard_EXPORT void SetType (const TCollection_AsciiString& aType);
93 friend class Storage_Schema;
96 DEFINE_STANDARD_RTTIEXT(Storage_Root,MMgt_TShared)
107 TCollection_AsciiString myName;
108 TCollection_AsciiString myType;
109 Handle(Standard_Persistent) myObject;
110 Standard_Integer myRef;
121 #endif // _Storage_Root_HeaderFile