Statistics
| Revision:

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

History | View | Annotate | Download (7.6 KB)

1
/* $Id: lti_metadataDatabase.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 LTIMETADATADATABASE_H
14
#define LTIMETADATADATABASE_H
15

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

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

    
22

    
23
LT_BEGIN_NAMESPACE(LizardTech)
24

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

    
29
class LTIMetadataRecord;
30

    
31

    
32
/**
33
 * class for storing metadata associated with an image
34
 *
35
 * This class implements a simple database which holds a set of
36
 * LTIMetadataRecords.  Each record has a unique tag associated with it.
37
 *
38
 * Each LTIImage object contains an LTIMetadataDatabase
39
 * for the metadata associated with that image.
40
 *
41
 * The database (and records) are stored in memory in a format-neutral
42
 * manner.  For importing or exporting metadata records to permanent
43
 * storage, see the LTIMetadataReader and LTIMetadataWriter classes.
44
 */
45
class LTIMetadataDatabase
46
{
47
public:
48
   /**
49
    * default constructor
50
    *
51
    * This constructor creates an empty metadata database.
52
    */
53
   LTIMetadataDatabase();
54

    
55
   /**
56
    * copy constructor
57
    */
58
   LTIMetadataDatabase(const LTIMetadataDatabase&);
59

    
60
   /**
61
    * destructor
62
    */
63
   virtual ~LTIMetadataDatabase();
64

    
65

    
66
   /**
67
    * @name Add functions
68
    */
69
   /*@{*/
70

    
71
   /**
72
    * add a record
73
    *
74
    * This function adds the given record to the metadata database.
75
    *
76
    * If the database already contains a record with the given tag,
77
    * a status code of LT_STS_LTIMetadata_DuplicateTag is returned.
78
    *
79
    * @param record the record to add 
80
    * @return status code indicating success or failure
81
    */
82
   LT_STATUS add(const LTIMetadataRecord& record);
83

    
84
   /**
85
    * add all the records from a database
86
    *
87
    * This function adds all the records from the given database to this
88
    * database.
89
    *
90
    * If the database already contains a record with the same tag as one
91
    * of the records in the database being added, no records are added and
92
    * a status code of LT_STS_LTIMetadata_DuplicateTag is returned.
93
    *
94
    * @param database the database containing the records to add 
95
    * @return status code indicating success or failure
96
    */
97
   LT_STATUS add(const LTIMetadataDatabase& database);
98

    
99
   /*@}*/
100

    
101

    
102
   /**
103
    * @name Retrieval functions
104
    */
105
   /*@{*/
106

    
107
   /**
108
    * retrieve a record, given a tag name
109
    *
110
    * This function returns a pointer to the (first) record in the database
111
    * that matches the given tag name.
112
    *
113
    * If the tag is not found, the pointer will be set to NULL and
114
    * a status of LT_STS_LTIMetadata_TagNotFound will be returned.
115
    *
116
    * @param   tagName  the name of the tag of the record to retrieve 
117
    * @param   record   pointer to the retrieved record 
118
    * @return  status code indicating success or failure
119
    */
120
   LT_STATUS get(const char* tagName,
121
                 const LTIMetadataRecord*& record) const;
122

    
123
   /**
124
    * retrieve a record, given a tag number
125
    *
126
    * This function returns a pointer to the (first) record in the database
127
    * that matches the given tag number.
128
    *
129
    * If the tag is not found, the pointer will be set to NULL and
130
    * a status of LT_STS_LTIMetadata_TagNotFound will be returned.
131
    *
132
    * @param   tag     the number of the tag of the record to retrieve 
133
    * @param   record  pointer to the retrieved record 
134
    * @return  status code indicating success or failure
135
    */
136
   LT_STATUS get(LTIMetadataTag tag,
137
                 const LTIMetadataRecord*& record) const;
138

    
139
   /**
140
    * lookup a record, given a tag name
141
    *
142
    * This function returns a boolean indicating whether the database
143
    * contains a record with the given tag.
144
    *
145
    * @param   tagName  the name of the tag of the record to look up 
146
    * @return  true if the tag is found, otherwise false
147
    */
148
   bool has(const char* tagName) const;
149

    
150
   /**
151
    * lookup a record, given a tag number
152
    *
153
    * This function returns a boolean indicating whether the database
154
    * contains a record with the given tag.
155
    *
156
    * @param   tag  the number of the tag of the record to look up 
157
    * @return  true if the tag is found, otherwise false
158
    */
159
   bool has(LTIMetadataTag tag) const;
160

    
161
   /**
162
    * retrieve a record, given an index number
163
    *
164
    * This function returns a pointer to the (first) record in the database
165
    * that matches the given index number.
166
    *
167
    * In combination with getIndexCount(), this function can be used
168
    * to iterate through all the records in the database.  (However, removing
169
    * a record will change the index numbers, so be careful if iterating
170
    * and removing in the same loop.)
171
    *
172
    * If the index number is not found, the pointer will be set to NULL and
173
    * a status of LT_STS_LTIMetadata_TagNotFound will be returned.
174
    *
175
    * @param   index  the index number of the record to retrieve 
176
    * @param   record  pointer to the retrieved record 
177
    * @return  status code indicating success or failure
178
    */
179
   LT_STATUS getDataByIndex(lt_uint32 index,
180
                            const LTIMetadataRecord*& record) const;
181

    
182
   /**
183
    * get number of records
184
    *
185
    * This function will return the number of records in the database.
186
    *
187
    * @return  the number of records
188
    */
189
   lt_uint32 getIndexCount() const;
190

    
191
   /*@}*/
192

    
193

    
194
   /**
195
    * @name Removal functions
196
    */
197
   /*@{*/
198

    
199
   /**
200
    * remove a record, given a tag name
201
    *
202
    * This function will remove the record with the given tag from the
203
    * database.
204
    *
205
    * If the tag is not found, a status of LT_STS_LTIMetadata_TagNotFound
206
    * will be returned.
207
    *
208
    * @param   tagName  the name of the tag of the record to remove 
209
    * @return  status code indicating success or failure
210
    */
211
   LT_STATUS remove(const char* tagName);
212

    
213
   /**
214
    * remove a record, given a tag number
215
    *
216
    * This function will remove the record with the given tag from the
217
    * database.
218
    *
219
    * If the tag is not found, a status of LT_STS_LTIMetadata_TagNotFound
220
    * will be returned.
221
    *
222
    * @param   tag  the number of the tag of the record to remove 
223
    * @return  status code indicating success or failure
224
    */
225
   LT_STATUS remove(LTIMetadataTag tag);
226

    
227
   /**
228
    * remove all records
229
    *
230
    * This function will remove all the records from the database.
231
    *
232
    * @return  status code indicating success or failure
233
    */
234
   LT_STATUS removeAll();
235

    
236
   /*@}*/
237

    
238
   /**
239
    * get size of metadata database
240
    *
241
    * This function will return a close-enough estimate of the size of the
242
    * metadata database, as if it were to be written directly to disk.
243
    *
244
    * @return  size in bytes of the metadata database
245
    */
246
   lt_int32 getApproximateSize() const;
247

    
248
   /**
249
    * Sorts the database records by tag name.  This can be useful in certain
250
    * debugging and validation scenarios.
251
    */
252
   void sort(void);
253

    
254
private:
255
   class RecordListX;
256
   RecordListX* m_recordList;
257

    
258
   // nope
259
   LTIMetadataDatabase& operator=(const LTIMetadataDatabase&);
260
};
261

    
262

    
263
LT_END_NAMESPACE(LizardTech)
264

    
265
#if defined(LT_COMPILER_MS)
266
        #pragma warning(pop)
267
#endif
268

    
269
#endif // LTIMETADATADATABASE_H