kwave  18.07.70
FileInfo.h
Go to the documentation of this file.
1 /***************************************************************************
2  FileInfo.h - information about an audio file
3  -------------------
4  begin : Mar 13 2002
5  copyright : (C) 2002 by Thomas Eschenbacher
6  email : Thomas Eschenbacher <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 
18 #ifndef FILE_INFO_H
19 #define FILE_INFO_H
20 
21 #include "config.h"
22 
23 #include <QtGlobal>
24 #include <QFlags>
25 #include <QList>
26 #include <QMap>
27 #include <QString>
28 #include <QVariant>
29 
30 #include "libkwave/MetaData.h"
31 #include "libkwave/Sample.h"
32 #include "libkwave/TypesMap.h"
33 
34 namespace Kwave
35 {
36 
37  class MetaDataList;
38 
45  typedef enum {
46  INF_UNKNOWN = -1,
47  // please sort in new items alphabetically...
48  INF_ALBUM = 0,
101  } FileProperty;
102 
104  static inline FileProperty operator ++ (FileProperty &prop) {
105  prop = static_cast<FileProperty>(static_cast<unsigned int>(prop) + 1);
106  return prop;
107  }
108 
113  class Q_DECL_EXPORT FileInfo: public Kwave::MetaData
114  {
115  public:
120  typedef enum {
122  FP_NONE = 0,
123 
125  FP_INTERNAL = 1,
126 
128  FP_READONLY = 2,
129 
131  FP_NO_LOAD_SAVE = 4,
132 
134  FP_FORMAT_NUMERIC = 8
135 
136  } Flag;
137 
138  Q_DECLARE_FLAGS(Flags, Flag)
139 
140 
141  FileInfo();
142 
148  explicit FileInfo(const Kwave::MetaDataList &meta_data_list);
149 
151  virtual ~FileInfo() Q_DECL_OVERRIDE;
152 
154  static QString metaDataType() {
155  return QString::fromLatin1("FILE INFO");
156  }
157 
159  sample_index_t length() const;
160 
162  void setLength(sample_index_t length);
163 
165  double rate() const;
166 
168  void setRate(double rate);
169 
171  unsigned int bits() const;
172 
174  void setBits(unsigned int bits);
175 
177  unsigned int tracks() const;
178 
180  void setTracks(unsigned int tracks);
181 
183  bool contains(const FileProperty property) const;
184 
192  void set(FileProperty key, const QVariant &value);
193 
200  QVariant get(FileProperty key) const;
201 
205  inline Flags flags(FileProperty key) const {
206  return m_property_map.data(key);
207  }
208 
212  inline bool isInternal(FileProperty key) const {
213  return (flags(key) & FP_INTERNAL);
214  }
215 
220  inline bool canLoadSave(FileProperty key) const {
221  return !(flags(key) & FP_NO_LOAD_SAVE);
222  }
223 
227  inline QString name(FileProperty key) const {
228  return m_property_map.name(key);
229  }
230 
234  inline QString description(FileProperty key) const {
235  return m_property_map.description(key, false);
236  }
237 
241  inline FileProperty fromName(const QString &name) const {
242  return m_property_map.findFromName(name);
243  }
244 
246  const QMap<FileProperty, QVariant> properties() const;
247 
249  QList<FileProperty> allKnownProperties() const;
250 
252  virtual void dump() const Q_DECL_OVERRIDE;
253 
254  private:
255 
259  class PropertyTypesMap: public Kwave::TypesMap<FileProperty, Flags>
260  {
261  public:
263  explicit PropertyTypesMap()
264  :Kwave::TypesMap<FileProperty, Flags>()
265  {
266  fill();
267  }
268 
270  virtual void fill() Q_DECL_OVERRIDE;
271 
273  virtual QList<FileProperty> all() const;
274  };
275 
278 
279  };
280 }
281 
282 Q_DECLARE_OPERATORS_FOR_FLAGS(Kwave::FileInfo::Flags)
283 
284 #endif /* FILE_INFO_H */
285 
286 //***************************************************************************
287 //***************************************************************************
Definition: App.h:33
bool isInternal(FileProperty key) const
Definition: FileInfo.h:212
QString name(FileProperty key) const
Definition: FileInfo.h:227
PropertyTypesMap m_property_map
Definition: FileInfo.h:277
bool canLoadSave(FileProperty key) const
Definition: FileInfo.h:220
quint64 sample_index_t
Definition: Sample.h:28
const char name[16]
Definition: memcpy.c:510
QString description(FileProperty key) const
Definition: FileInfo.h:234
FileProperty fromName(const QString &name) const
Definition: FileInfo.h:241
static FileProperty operator++(FileProperty &prop)
Definition: FileInfo.h:104
Flags flags(FileProperty key) const
Definition: FileInfo.h:205
FileProperty
Definition: FileInfo.h:45