comparison base/UnitDatabase.h @ 116:a08718723b20

* Add units repository, and unit property on time-value and note layers.
author Chris Cannam
date Thu, 11 May 2006 15:02:14 +0000
parents
children 1d789d688f59
comparison
equal deleted inserted replaced
115:90ade4fa63be 116:a08718723b20
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _UNIT_DATABASE_H_
17 #define _UNIT_DATABASE_H_
18
19 #include <QObject>
20 #include <QString>
21 #include <QStringList>
22 #include <map>
23
24 // This grandly named class is just a list of the names of known scale
25 // units for the various models, for use as the set of fixed values in
26 // unit dropdown menus etc. Of course, the user should be allowed to
27 // enter their own as well.
28
29 class UnitDatabase : public QObject
30 {
31 Q_OBJECT
32
33 public:
34 static UnitDatabase *getInstance();
35
36 QStringList getKnownUnits() const;
37 void registerUnit(QString unit);
38
39 int getUnitId(QString unit);
40 QString getUnitById(int id);
41
42 signals:
43 void unitDatabaseChanged();
44
45 protected:
46 UnitDatabase();
47
48 typedef std::map<QString, int> UnitMap;
49 UnitMap m_units;
50 int m_nextId;
51
52 static UnitDatabase m_instance;
53 };
54
55 #endif
56