Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[3e4acc]: libkwave / MetaDataList.h Maximize Restore History

Download this file

MetaDataList.h    327 lines (284 with data), 10.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/***************************************************************************
MetaDataList.h - list with meta data objects
-------------------
begin : Sat Mar 06 2010
copyright : (C) 2010 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _META_DATA_LIST_H_
#define _META_DATA_LIST_H_
#include "config.h"
#include <QList>
#include <QMap>
#include <QString>
#include <QVariant>
#include <QMapIterator>
#include <QMutableMapIterator>
#include <kdemacros.h>
#include "libkwave/FileInfo.h"
#include "libkwave/MetaData.h"
#include "libkwave/Sample.h"
namespace Kwave {
class KDE_EXPORT MetaDataList: public QMap<QString, MetaData>
{
public:
/** const iterator for the meta data list */
typedef QMapIterator<QString, MetaData> Iterator;
/** mutable iterator for the meta data list */
typedef QMutableMapIterator<QString, MetaData> MutableIterator;
/** Default constructor */
MetaDataList();
/**
* Constructor, creates a meta data list with only one single meta
* data item. In some cases you need to pass a meta data list to a
* function but you have only a single meta data item, so this might
* be quite handy
* @param meta const reference to a single meta data item
*/
MetaDataList(const MetaData &meta);
/** Destructor */
virtual ~MetaDataList();
/**
* Create a simple list of meta data items, sorted by the position
* of the first sample. All meta data items that do not correspond
* to a position or a "first" sample are mapped to the start (zero).
* @return a QList of meta data, sorted by position
*/
virtual QList<Kwave::MetaData> toSortedList() const;
/**
* select elements from the meta data list that have the standard
* property STDPROP_TYPE set to a specific value.
*
* @param type the type to select @see Kwave::MetaData::STDPROP_TYPE
* @return list with found meta data objects
*/
virtual MetaDataList selectByType(const QString &type) const;
/**
* select elements from the meta data list that have a specific scope
*
* @param scope the scope to select @see Kwave::MetaData::Scope
* @return list with found meta data objects
*/
virtual MetaDataList selectByScope(MetaData::Scope scope) const;
/**
* select elements from the meta data list that belong to
* a given track.
*
* @param tracks list of track indices to select
* @return list with found meta data objects
*/
virtual MetaDataList selectByTracks(const QList<unsigned int> &tracks) const;
/**
* select elements from the meta data list that overlap a given
* range of samples (selects elements with scope "Range" as well
* as elements with scope "Position")
*
* @param first index of the first sample
* @param last index of the last sample
* @return list with found meta data objects
*/
virtual MetaDataList selectByRange(
sample_index_t first, sample_index_t last) const;
/**
* select elements from the meta data list that are exactly at a
* given position.
*
* @param pos index of the sample to select
* @return list with found meta data objects
*/
virtual MetaDataList selectByPosition(sample_index_t pos) const;
/**
* select elements from the meta data list that contain a given
* property.
*
* @param property the property to search for
* @return list with found meta data objects
*/
virtual MetaDataList selectByProperty(const QString &property) const;
/**
* select elements from the meta data list that contain a given
* property and a given value
*
* @param property the property to search for
* @param value the value that the property should have
* @return list with found meta data objects
*/
virtual MetaDataList selectByValue(
const QString &property, QVariant value) const;
/**
* Checks whether a meta data object is contained in this list,
* the check is based on the unique id of the meta data object.
*
* @param metadata the object to search
* @return true if found, otherwise false
*/
virtual bool contains(const MetaData &metadata) const;
/**
* Replaces all meta data objects that have the same type as one
* of the objects in the passed list with newer versions. If an
* object did not exist, it will be created. If an object is not
* in the passed list, it will be deleted.
*
* @param list listof meta data objects that should be replaced
* @note affects only objects with a type that was found in the
* passed list
*/
virtual void replace(const MetaDataList &list);
/**
* Adds a single meta data object to the list. If it is already
* present, the old version will be silently replaced.
* If the object is a null object and an object with the same
* ID exists in the list, this will work as remove().
*
* @param metadata the meta data object that should be added
*/
virtual void add(const MetaData &metadata);
/**
* Adds a list of meta data objects to the list. Old versions of
* existing objects will be silently replaced.
*
* @param list list of meta data objects that should be added
*/
virtual void add(const MetaDataList &list);
/**
* Removes one meta data object from the list (if it exists).
*
* @param metadata the object that should be removed
*/
virtual void remove(const MetaData &metadata);
/**
* Removes a list of meta data objects from this list (if they exist).
*
* @param list the list of meta data objects to remove
*/
virtual void remove(const MetaDataList &list);
/**
* Crops this list to a given range of samples. All position aware
* elements that are not covered by the given range will be removed,
* all covered elements will be adjusted.
*
* @param first index of the first sample
* @param last index of the last sample
*/
virtual void cropByRange(sample_index_t first, sample_index_t last);
/**
* Crops this list to a given set of tracks. All elements that are
* bound to a track or list of tracks which are not covered by the
* given selection will be removed. The tracks of the remaining
* elements will be re-numbered to start from zero and counted up
* without gaps.
*
* @param tracks list of track indices
*/
virtual void cropByTracks(const QList<unsigned int> &tracks);
/**
* copy elements from the meta data list that overlap a given
* range of samples (selects elements with scope "Range" as well
* as elements with scope "Position") and have a binding to a
* track.
*
* @param offset index of the first sample
* @param length number of samples of the range
* @param tracks list of track indices
* @return list with a copy of found meta data objects
*/
virtual MetaDataList copy(
sample_index_t offset,
sample_index_t length,
const QList<unsigned int> &tracks
) const;
/**
* Merges a list of other meta data items
* @param meta_data list of meta data items
*/
void merge(const MetaDataList &meta_data);
/**
* delete elements from the meta data list that overlap a given
* range of samples (selects elements with scope "Range" as well
* as elements with scope "Position") and have a binding to a
* track.
*
* @param offset index of the first sample
* @param length number of samples to delete
* @param tracks list of track indices
* @return list with a copy of found meta data objects
*/
virtual void deleteRange(
sample_index_t offset,
sample_index_t length,
const QList<unsigned int> &tracks
);
/**
* shift the positions or start/end of all elements that are after
* a given offset to the left.
*
* @param offset index of the first sample
* @param shift number of samples to shift left
* @param tracks list of track indices
*/
virtual void shiftLeft(
sample_index_t offset,
sample_index_t shift,
const QList<unsigned int> &tracks
);
/**
* shift the positions or start/end of all elements that are after
* a given offset to the right.
*
* @param offset index of the first sample
* @param shift number of samples to shift right
* @param tracks list of track indices
*/
virtual void shiftRight(
sample_index_t offset,
sample_index_t shift,
const QList<unsigned int> &tracks
);
/**
* scale the positions or start/end of all elements by a given factor
*
* @param scale the factor that is applied to all positions
* @param tracks list of track indices
*/
virtual void scalePositions(
double scale,
const QList<unsigned int> &tracks
);
/**
* makes place for a new track by adjusting the track indices of all
* meta data items after that track by plus one
*
* @param track index of the track that is inserted
*/
virtual void insertTrack(unsigned int track);
/**
* delete all meta data that was bound to a specific track and
* adjust the track indices of all meta data items after that
* track by minus one
*
* @param track index of the track that is to be deleted
*/
virtual void deleteTrack(unsigned int track);
/** dump all meta data to stdout (for debugging) */
virtual void dump() const;
protected:
/**
* Splits the list at a given position. The given position will
* be the start of the new fragment(s), so that splitting multiple
* times at the same offset does not produce further fragments.
* @param offset index of the sample position before which the
* list should be split
* @param tracks list of track indices
*/
void split(sample_index_t offset, const QList<unsigned int> &tracks);
};
}
#endif /* _META_DATA_LIST_H_ */