kwave  18.07.70
MetaData.h
Go to the documentation of this file.
1 /***************************************************************************
2  MetaData.h - base class for associated meta data
3  -------------------
4  begin : Sat Jan 23 2010
5  copyright : (C) 2010 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef META_DATA_H
18 #define META_DATA_H
19 
20 #include "config.h"
21 
22 #include <QtGlobal>
23 #include <QList>
24 #include <QMap>
25 #include <QMutex>
26 #include <QSharedData>
27 #include <QSharedDataPointer>
28 #include <QString>
29 #include <QStringList>
30 #include <QVariant>
31 
32 #include "libkwave/Sample.h"
33 
34 namespace Kwave
35 {
36 
37  class Q_DECL_EXPORT MetaData
38  {
39  public:
41  static const QString STDPROP_TYPE;
42 
44  static const QString STDPROP_TRACKS;
45 
47  static const QString STDPROP_START;
48 
50  static const QString STDPROP_END;
51 
53  static const QString STDPROP_POS;
54 
56  static const QString STDPROP_DESCRIPTION;
57 
58  typedef enum
59  {
61  None = 0,
62 
64  Signal = (1 << 0),
65 
71  Track = (1 << 1),
72 
78  Range = (1 << 2),
79 
84  Position = (1 << 3),
85 
87  All = ~0
88  } Scope;
89 
91  typedef QMap<QString, QVariant> PropertyList;
92 
97  MetaData();
98 
103  MetaData(const MetaData &other);
104 
106  explicit MetaData(Scope scope);
107 
109  virtual ~MetaData();
110 
112  virtual void clear();
113 
115  virtual bool isNull() const;
116 
118  QString id() const;
119 
121  Scope scope() const;
122 
127  void setScope(Scope scope);
128 
137  void setProperty(const QString &p, const QVariant &value);
138 
144  bool hasProperty(const QString &p) const;
145 
152  QVariant property(const QString &p) const;
153 
155  inline QVariant operator [] (const QString p) const
156  {
157  return property(p);
158  }
159 
166  QVariant &property(const QString &p);
167 
169  inline QVariant &operator [] (const QString p)
170  {
171  return property(p);
172  }
173 
175  bool operator == (const MetaData &other) const;
176 
178  inline bool operator != (const MetaData &other) const
179  {
180  return !(operator == (other));
181  }
182 
184  QStringList keys() const;
185 
187  static QStringList positionBoundPropertyNames();
188 
194  sample_index_t firstSample() const;
195 
201  sample_index_t lastSample() const;
202 
207  QList<unsigned int> boundTracks() const;
208 
210  virtual void dump() const;
211 
212  private:
213 
215  class MetaDataPriv: public QSharedData
216  {
217  public:
218 
220  MetaDataPriv();
221 
223  MetaDataPriv(const MetaDataPriv &other);
224 
226  virtual ~MetaDataPriv();
227 
229  QString m_id;
230 
233 
235  PropertyList m_properties;
236 
237  private:
238 
240  static QString newUid();
241 
243  static quint64 m_id_counter;
244 
246  static QMutex m_id_lock;
247  };
248 
250  QSharedDataPointer<MetaDataPriv> m_data;
251  };
252 }
253 
254 #endif /* META_DATA_H */
255 
256 //***************************************************************************
257 //***************************************************************************
static const QString STDPROP_POS
Definition: MetaData.h:53
Definition: App.h:33
static const QString STDPROP_TRACKS
Definition: MetaData.h:44
quint64 sample_index_t
Definition: Sample.h:28
QMap< QString, QVariant > PropertyList
Definition: MetaData.h:91
QSharedDataPointer< MetaDataPriv > m_data
Definition: MetaData.h:250
static const QString STDPROP_TYPE
Definition: MetaData.h:41
static const QString STDPROP_START
Definition: MetaData.h:47
static quint64 m_id_counter
Definition: MetaData.h:243
static const QString STDPROP_END
Definition: MetaData.h:50
static const QString STDPROP_DESCRIPTION
Definition: MetaData.h:56