82f233513aa56110ae53d8e216718d0df6b7ad4d
[occt.git] / src / Storage / Storage_Root.hxx
1 // Created on: 1997-02-24
2 // Created by: Kernel
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Storage_Root_HeaderFile
18 #define _Storage_Root_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TCollection_AsciiString.hxx>
24 #include <Standard_Integer.hxx>
25 #include <MMgt_TShared.hxx>
26 class Standard_Persistent;
27 class Storage_Schema;
28 class TCollection_AsciiString;
29
30
31 class Storage_Root;
32 DEFINE_STANDARD_HANDLE(Storage_Root, MMgt_TShared)
33
34
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
49 {
50
51 public:
52
53   
54   Standard_EXPORT Storage_Root();
55   
56   Standard_EXPORT Storage_Root(const TCollection_AsciiString& aName, const Handle(Standard_Persistent)& anObject);
57   
58   Standard_EXPORT void SetName (const TCollection_AsciiString& aName);
59   
60
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.
70   //! Warning
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;
76   
77   Standard_EXPORT void SetObject (const Handle(Standard_Persistent)& anObject);
78   
79
80   //! Returns the persistent object encapsulated by this root.
81   Standard_EXPORT Handle(Standard_Persistent) Object() const;
82   
83   //! Returns the name of this root type.
84   Standard_EXPORT TCollection_AsciiString Type() const;
85
86   Standard_EXPORT void SetReference (const Standard_Integer aRef);
87
88   Standard_EXPORT Standard_Integer Reference() const;
89
90   Standard_EXPORT void SetType (const TCollection_AsciiString& aType);
91
92
93 friend class Storage_Schema;
94
95
96   DEFINE_STANDARD_RTTIEXT(Storage_Root,MMgt_TShared)
97
98 protected:
99
100
101
102
103 private:
104
105   
106
107   TCollection_AsciiString myName;
108   TCollection_AsciiString myType;
109   Handle(Standard_Persistent) myObject;
110   Standard_Integer myRef;
111
112
113 };
114
115
116
117
118
119
120
121 #endif // _Storage_Root_HeaderFile