Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-mrsid / include / metadata / lti_metadataRecord.h @ 3539

History | View | Annotate | Download (9.77 KB)

1
/* $Id: lti_metadataRecord.h 3539 2006-01-09 12:23:20Z nacho $ */
2
/* //////////////////////////////////////////////////////////////////////////
3
//                                                                         //
4
// This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue,   //
5
// Suite 200, Seattle, WA 98104.  Unauthorized use or distribution         //
6
// prohibited.  Access to and use of this code is permitted only under     //
7
// license from LizardTech, Inc.  Portions of the code are protected by    //
8
// US and foreign patents and other filings. All Rights Reserved.          //
9
//                                                                         //
10
////////////////////////////////////////////////////////////////////////// */
11
/* PUBLIC */
12

    
13
#ifndef LTIMETADATARECORD_H
14
#define LTIMETADATARECORD_H
15

    
16
// lt_lib_base
17
#include "lt_base.h"
18

    
19
// lt_lib_mrsid_metadata
20
#include "lti_metadataTypes.h"
21

    
22
LT_BEGIN_NAMESPACE(LizardTech)
23

    
24
#if defined(LT_COMPILER_MS)
25
   #pragma warning(push,4)
26
#endif
27

    
28

    
29
/**
30
 * representation of a metadata record
31
 *
32
 * This class stores the data associated with a single record in the database.
33
 * The data consists of:
34
 *   - the tag (a string), used to uniquely identify the record
35
 *   - the type of the data, e.g. string, byte, etc
36
 *   - the dimensionality of the data, e.g. scalar, 2x3 array, etc
37
 *   - the actual data
38
 *
39
 * It is assumed each record has only a single set of data of a single datatype.
40
 * (That is, a record can't contain both a float and two ints.)
41
 *
42
 * Some of the functions for operating on records are cast in the guise
43
 * of scalar, vector, or array data.  This is for notational convenience only;
44
 * the internal representation does not distinguish and treats everything as
45
 * a (possibly degenerate) array.
46
 */
47
class LTIMetadataRecord
48
{
49
public:
50
   /**
51
    * default constructor for scalar data
52
    *
53
    * The constructor creates a record containing a scalar data value.
54
    *
55
    * Note that the object makes a local copy of the data passed into the
56
    * record.
57
    *
58
    * @param tag the tag number of the record 
59
    * @param type datatype of the data in the record 
60
    * @param data pointer to the data to insert into the record 
61
    */
62
   LTIMetadataRecord(LTIMetadataTag tag,
63
                     LTIMetadataDataType type,
64
                     const void* data);
65

    
66
   /**
67
    * default constructor for scalar data
68
    *
69
    * The constructor creates a record containing a scalar data value.
70
    *
71
    * Note that the object makes a local copy of the data passed into the
72
    * record.
73
    *
74
    * @param tagName the tag number of the record 
75
    * @param type datatype of the data in the record 
76
    * @param data pointer to the data to insert into the record 
77
    */
78
   LTIMetadataRecord(const char* tagName,
79
                     LTIMetadataDataType type,
80
                     const void* data);
81
   
82
   /**
83
    * default constructor for vector data
84
    *
85
    * The constructor creates a record containing a vector of data values.
86
    *
87
    * Note that the object makes a local copy of the data passed into the
88
    * record.
89
    *
90
    * @param tag the tag number of the record 
91
    * @param type datatype of the data in the record 
92
    * @param data pointer to the data to insert into the record 
93
    * @param vecLen the length of the data vector 
94
    */
95
   LTIMetadataRecord(LTIMetadataTag tag,
96
                     LTIMetadataDataType type,
97
                     const void* data,
98
                     lt_uint32 vecLen);
99
   /**
100
    * default constructor for vector data
101
    *
102
    * The constructor creates a record containing a vector of data values.
103
    *
104
    * Note that the object makes a local copy of the data passed into the
105
    * record.
106
    *
107
    * @param tagName the tag number of the record 
108
    * @param type datatype of the data in the record 
109
    * @param data pointer to the data to insert into the record 
110
    * @param vecLen the length of the data vector 
111
    */
112
   LTIMetadataRecord(const char* tagName,
113
                     LTIMetadataDataType type,
114
                     const void* data,
115
                     lt_uint32 vecLen);
116

    
117
   /**
118
    * default constructor for array data
119
    *
120
    * The constructor creates a record containing an array of data values.
121
    *
122
    * Note that the object makes a local copy of the data passed into the
123
    * record.
124
    *
125
    * @param tag the tag number of the record 
126
    * @param type datatype of the data in the record 
127
    * @param data pointer to the data to insert into the record 
128
    * @param numDims the length of the \a dims array 
129
    * @param dims the dimensionality of the data 
130
    */
131
   LTIMetadataRecord(LTIMetadataTag tag,
132
                     LTIMetadataDataType type,
133
                     const void* data,
134
                     lt_uint32 numDims,
135
                     const lt_uint32* dims);
136

    
137
   /**
138
    * default constructor for array data
139
    *
140
    * The constructor creates a record containing an array of data values.
141
    *
142
    * Note that the object makes a local copy of the data passed into the
143
    * record.
144
    *
145
    * @param tagName the tag number of the record 
146
    * @param type datatype of the data in the record 
147
    * @param data pointer to the data to insert into the record 
148
    * @param numDims the length of the \a dims array 
149
    * @param dims the dimensionality of the data 
150
    */
151
   LTIMetadataRecord(const char* tagName,
152
                     LTIMetadataDataType type,
153
                     const void* data,
154
                     lt_uint32 numDims,
155
                     const lt_uint32* dims);
156

    
157
   /**
158
    * copy constructor
159
    */
160
   LTIMetadataRecord(const LTIMetadataRecord&);
161

    
162
   /**
163
    * destructor
164
    */
165
   ~LTIMetadataRecord();
166

    
167
   /**
168
    * get tag
169
    *
170
    * This function returns the tag number (enum) associated with the record.
171
    *
172
    * @return the tag
173
    */
174
   LTIMetadataTag getTag() const;
175

    
176
   /**
177
    * get tag name
178
    *
179
    * This function returns the tag name (string) associated with the record.
180
    *
181
    * @return the tag name
182
    */
183
   const char* getTagName() const;
184

    
185
   /**
186
    * get datatype
187
    *
188
    * This function returns the datatype of the data in the record.
189
    *
190
    * @return the datatype
191
    */
192
   LTIMetadataDataType getDataType() const;
193

    
194
   /**
195
    * get number of dimensions of the data set
196
    *
197
    * This function returns the number of dimensions in the dimensionality
198
    * of the dataset.
199
    *
200
    * This is the length of the array returned by the getDims() function.
201
    *
202
    * @return the number of dimensions
203
    */
204
   lt_uint32 getNumDims() const;
205

    
206
   /**
207
    * get dimensionality of the data set
208
    *
209
    * This function returns an array with the length of each dimension of the
210
    * dataset.
211
    *
212
    * For example, a 2x3 dataset would return an array of length two with the
213
    * values {2,3}.
214
    *
215
    * This is the length of the returned array is equal to getNumDims().
216
    *
217
    * @return the number of dimensions
218
    */
219
   const lt_uint32* getDims() const;
220

    
221
   /**
222
    * is dataset a scalar?
223
    *
224
    * This function returns true iff the record's dataset consists only of a
225
    * single element.
226
    *
227
    * @return true if record data is a scalar value
228
    */
229
   bool isScalar() const;
230

    
231
   /**
232
    * is dataset a vector?
233
    *
234
    * This function returns true iff the record's dataset is a 1-D array.
235
    *
236
    * @return true if record data is a vector of values
237
    */
238
   bool isVector() const;
239

    
240
   /**
241
    * is dataset an array?
242
    *
243
    * This function returns true iff the record's dataset is neither
244
    * a scalar nor a vector.
245
    *
246
    * @return true if record data is not scalar or vector
247
    */
248
   bool isArray() const;
249

    
250
   /**
251
    * get scalar data value
252
    *
253
    * This function returns the record's data as a scalar value.  It is
254
    * the caller's responsibility to assure that the record does indeed
255
    * contain a scalar dataset.
256
    *
257
    * The user is responsible for casting the returned value to the correct
258
    * datatype.
259
    *
260
    * @return a pointer to the scalar data value
261
    */
262
   const void* getScalarData() const;
263

    
264
   /**
265
    * get vector data values
266
    *
267
    * This function returns the record's data as a vector of values.  It is
268
    * the caller's responsibility to assure that the record does indeed
269
    * contain a vector dataset.
270
    *
271
    * The user is responsible for casting the returned value to an array
272
    * of the correct datatype.
273
    *
274
    * @param vecLen the length of the returned vector 
275
    * @return a pointer to the vector of data values
276
    */
277
   const void* getVectorData(lt_uint32& vecLen) const;
278

    
279
   /**
280
    * get array data values
281
    *
282
    * This function returns the record's data as an array of values.
283
    *
284
    * Note the function returns via its parameters the same information as
285
    * getNumDims() and getDims().
286
    *
287
    * The user is responsible for casting the returned value to an array
288
    * of the correct datatype.
289
    *
290
    * @param numDims the number of dimensions in the \a dims parameter 
291
    * @param dims the dimensionality array 
292
    * @return a pointer to the array of data values
293
    */
294
   const void* getArrayData(lt_uint32& numDims, const lt_uint32*& dims) const;
295

    
296
   /**
297
    * get size of metadata record
298
    *
299
    * This function will return a close-enough estimate of the size of the
300
    * record, as if it were to be written directly to disk.
301
    *
302
    * @return  size in bytes of the record
303
    */
304
   lt_int32 getApproximateSize() const;
305

    
306
private:
307
   void initialize(LTIMetadataTag tag,
308
                   const void* data, const lt_uint32* dims);
309
   void initialize(const char* tagName,
310
                   const void* data, const lt_uint32* dims);
311

    
312
   lt_uint32 computeLen() const;
313

    
314
   char* m_tagName;
315
   LTIMetadataDataType m_type;
316
   lt_uint32 m_numDims;
317
   lt_uint32* m_dims;
318
   lt_uint8* m_data;
319
   
320
   // nope
321
   LTIMetadataRecord& operator=(const LTIMetadataRecord&);
322
};
323

    
324

    
325
LT_END_NAMESPACE(LizardTech)
326

    
327
#if defined(LT_COMPILER_MS)
328
        #pragma warning(pop)
329
#endif
330

    
331
#endif // LTIMETADATARECORD_H