Overture
Version 25
Main Page
Namespaces
Classes
Files
File List
File Members
Overture.v25.d
include
HDF_DataBase.h
Go to the documentation of this file.
1
#ifndef HDF_DATABASE_H
2
#define HDF_DATABASE_H "HDF_DataBase.h"
3
4
#include "
GenericDataBase.h
"
5
#include "
ListOfHDF_DataBaseRCData.h
"
6
7
#ifdef OV_USE_HDF5
8
#include "
HDF5_DataBase.h
"
9
#else
10
11
#ifdef NO_OVREFCOUNTING
12
#include "ReferenceCounting_hdf.h"
13
#else
14
#include "
ReferenceCounting.h
"
15
#endif
16
17
//--------------------------------------------------------------------------
18
//
19
// HDF_DataBase: This is a class to support access to and from a data-base.
20
// This class knows how to get and put the types
21
// o int, float, double, aString
22
// as well as A++ arrays
23
// o intArray, floatArray, doubleArray
24
// as well as
25
// o "c" arrays of Strings.
26
//
27
// This implementation acts as a front end to the HDF Library from NCSA
28
//
29
// Notes:
30
// In HDF directories (nodes) in the hierarchy are called vgroups.
31
// Every time we open a vgroup we need to close it. Therefore we keep
32
// a list of vgroup's that are open and we keep a reference count of
33
// how many data-bases are referencing that vgroup. When the reference
34
// count goes to zero we can close the vgroup. The list is called dbList
35
// and the nodes in the list are reference-counted objects of type
36
// HDF_DataBaseRCData (RCdata=ReferenceCountedData). Every element in the
37
// list will refer to a different vgroup so that the vgroup_id's will
38
// be different for all elements in the list.
39
//
40
//--------------------------------------------------------------------------
41
42
// Since we need to keep track of properly closing the Vgroup that was
43
// opened we keep a reference count to the vgroup using the following class:
44
class
HDF_DataBaseRCData :
public
ReferenceCounting
45
{
46
friend
class
HDF_DataBase
;
47
int
vgroup_id;
48
// int vgroup_ref;
49
50
public
:
51
HDF_DataBaseRCData(){};
52
~HDF_DataBaseRCData(){};
53
54
};
55
56
57
class
DataBaseBuffer
;
58
59
// include "tlist.h"
60
// typedef List<HDF_DataBaseRCData> ListOfHDF_DataBaseRCData;
61
62
class
HDF_DataBase
:
public
GenericDataBase
63
{
64
protected
:
65
int
file_id, sd_id;
// file identifiers, two types needed
66
// dbList: a list of all the data-bases associated with a given file
67
// we need this list so we can unmount the file
68
ListOfHDF_DataBaseRCData
*dbList;
69
70
HDF_DataBaseRCData *rcData;
71
72
enum
modesOfAccess
73
{
74
none
,
75
write
,
76
read
77
}
accessMode
;
78
79
80
// close the directory, flush data
81
int
close
();
82
void
reference
(
const
HDF_DataBase
& db );
83
void
breakReference();
84
void
destroy
();
85
86
public
:
87
HDF_DataBase
();
88
HDF_DataBase
(
const
HDF_DataBase
&);
89
HDF_DataBase
(
const
GenericDataBase
&);
90
virtual
GenericDataBase
*
virtualConstructor
()
const
;
91
~HDF_DataBase
();
92
HDF_DataBase
&
operator=
(
const
HDF_DataBase
& );
93
GenericDataBase
&
operator=
(
const
GenericDataBase
& );
94
95
// open a data-base file
96
int
mount
(
const
aString
&
fileName
,
const
aString
& flags =
"I"
);
97
// flush data, close the file
98
int
unmount
();
99
// flush the data to the file
100
int
flush
();
101
102
virtual
int
getID
()
const
;
// get the identifier for this directory
103
104
// build a directory with the given ID
105
virtual
int
build
(
GenericDataBase
& db,
int
id
);
106
107
int
isNull
()
const
;
108
109
// create a sub-directory
110
int
create
(
GenericDataBase
& db,
const
aString
& name,
const
aString
& dirClassName );
111
// find a sub-directory (crash if not found)
112
int
find
(
GenericDataBase
& db,
const
aString
& name,
const
aString
& dirClassName )
const
;
113
// locate a sub-directory
114
int
locate
(
GenericDataBase
& db,
const
aString
& name,
const
aString
& dirClassName )
const
;
115
116
// find the names of all objects with a given class-name
117
virtual
int
find
(
aString
*name,
const
aString
& dirClassName,
118
const
int
& maxNumber,
int
& actualNumber)
const
;
119
// find all sub-directories (and their names) with a given class-name
120
virtual
int
find
(
GenericDataBase
*db,
aString
*name,
const
aString
& dirClassName,
121
const
int
& maxNumber,
int
& actualNumber)
const
;
122
123
// put a float/int/double/aString
124
int
put
(
const
float
& x,
const
aString
& name );
125
int
put
(
const
double
& x,
const
aString
& name );
126
int
put
(
const
int
& x,
const
aString
& name );
127
int
put
(
const
aString
& x,
const
aString
& name );
128
#ifdef OV_BOOL_DEFINED
129
int
put
(
const
bool
& x,
const
aString
& name );
130
#endif
131
132
// get a float/int/double/aString
133
int
get
(
float
&
x
,
const
aString
& name )
const
;
134
int
get
(
double
&
x
,
const
aString
& name )
const
;
135
int
get
(
int
&
x
,
const
aString
& name )
const
;
136
int
get
(
aString
&
x
,
const
aString
& name )
const
;
137
#ifdef OV_BOOL_DEFINED
138
int
get
(
bool
&
x
,
const
aString
& name )
const
;
139
#endif
140
141
// put a float/int/double A++ array
142
virtual
int
put
(
const
floatSerialArray & x,
const
aString
& name );
143
virtual
int
put
(
const
doubleSerialArray & x,
const
aString
& name );
144
virtual
int
put
(
const
intSerialArray & x,
const
aString
& name );
145
146
virtual
int
putDistributed
(
const
floatArray & x,
const
aString
& name );
147
virtual
int
putDistributed
(
const
doubleArray & x,
const
aString
& name );
148
virtual
int
putDistributed
(
const
intArray & x,
const
aString
& name );
149
150
// get a float/int/double A++ array
151
virtual
int
get
( floatSerialArray &
x
,
const
aString
& name, Index *Iv=
NULL
)
const
;
152
virtual
int
get
( doubleSerialArray &
x
,
const
aString
& name, Index *Iv=
NULL
)
const
;
153
virtual
int
get
( intSerialArray &
x
,
const
aString
& name, Index *Iv=
NULL
)
const
;
154
155
virtual
int
getDistributed
( floatArray & x,
const
aString
& name )
const
;
156
virtual
int
getDistributed
( doubleArray & x,
const
aString
& name )
const
;
157
virtual
int
getDistributed
( intArray & x,
const
aString
& name )
const
;
158
159
// put/get a "c" array of float/int/double/Strings
160
int
put
(
const
int
x[],
const
aString
& name,
const
int
number );
161
int
put
(
const
float
x[],
const
aString
& name,
const
int
number );
162
int
put
(
const
double
x[],
const
aString
& name,
const
int
number );
163
int
put
(
const
aString
x[],
const
aString
& name,
const
int
number );
164
165
int
get
(
int
x
[],
const
aString
& name,
const
int
number )
const
;
166
int
get
(
float
x
[],
const
aString
& name,
const
int
number )
const
;
167
int
get
(
double
x
[],
const
aString
& name,
const
int
number )
const
;
168
int
get
(
aString
x
[],
const
aString
& name,
const
int
number )
const
;
169
170
// output statistics on the file such as number of vgroups, vdatas
171
void
printStatistics
()
const
;
172
173
virtual
void
setMode
(
const
InputOutputMode
&
mode
=
normalMode
);
174
175
int
putSM
(
const
floatArray & x,
const
aString
& name );
176
int
getSM
( floatArray & x,
const
aString
& name );
177
178
// int putSM( const float & x, const aString & name );
179
// int getSM( float & x, const aString & name );
180
181
182
183
static
int
debug
;
184
185
protected
:
186
DataBaseBuffer
*
dataBaseBuffer
;
187
bool
bufferWasCreatedInThisDirectory
;
// indicates when stream buffers were really opened
188
void
closeStream
()
const
;
// close the stream buffers, if they are open (not really const!)
189
190
};
191
192
// end hdf4 header
193
#endif
194
195
#endif
Generated on Fri Jan 4 2013 10:17:53 for Overture by
1.8.3