0026961: Recover possibility to read files in old persistence format -- preparation
[occt.git] / src / Storage / Storage_Root.hxx
CommitLineData
42cf5bc1 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>
26class Standard_Persistent;
27class Storage_Schema;
28class TCollection_AsciiString;
29
30
31class Storage_Root;
32DEFINE_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.
48class Storage_Root : public MMgt_TShared
49{
50
51public:
52
53
54 Standard_EXPORT Storage_Root();
55
7ed7467d 56 Standard_EXPORT Storage_Root (const TCollection_AsciiString& theName,
57 const Handle(Standard_Persistent)& theObject);
58
59 Standard_EXPORT Storage_Root (const TCollection_AsciiString& theName,
60 const Standard_Integer theRef,
61 const TCollection_AsciiString& theType);
42cf5bc1 62
7ed7467d 63 Standard_EXPORT void SetName (const TCollection_AsciiString& theName);
42cf5bc1 64
65
66 //! Returns the name of this root object.
67 //! The name may have been given explicitly when
68 //! the root was inserted into the Storage_Data
69 //! object. If not, the name is a reference number
70 //! which was assigned automatically by the driver
71 //! when writing the set of data into the container.
72 //! When naming the roots, it is easier to retrieve
73 //! objects by significant references rather than by
74 //! references without any semantic values.
75 //! Warning
76 //! The returned string will be empty if you call this
77 //! function before having named this root object,
78 //! either explicitly, or when writing the set of data
79 //! into the container.
80 Standard_EXPORT TCollection_AsciiString Name() const;
81
82 Standard_EXPORT void SetObject (const Handle(Standard_Persistent)& anObject);
83
84
85 //! Returns the persistent object encapsulated by this root.
86 Standard_EXPORT Handle(Standard_Persistent) Object() const;
87
88 //! Returns the name of this root type.
89 Standard_EXPORT TCollection_AsciiString Type() const;
90
4ff92abe 91 Standard_EXPORT void SetReference (const Standard_Integer aRef);
92
93 Standard_EXPORT Standard_Integer Reference() const;
94
95 Standard_EXPORT void SetType (const TCollection_AsciiString& aType);
96
42cf5bc1 97
98friend class Storage_Schema;
99
100
92efcf78 101 DEFINE_STANDARD_RTTIEXT(Storage_Root,MMgt_TShared)
42cf5bc1 102
103protected:
104
105
106
107
108private:
109
110
42cf5bc1 111
112 TCollection_AsciiString myName;
113 TCollection_AsciiString myType;
114 Handle(Standard_Persistent) myObject;
115 Standard_Integer myRef;
116
117
118};
119
120
121
122
123
124
125
126#endif // _Storage_Root_HeaderFile