Chris@116: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@116: 
Chris@116: /*
Chris@116:     Sonic Visualiser
Chris@116:     An audio file viewer and annotation editor.
Chris@116:     Centre for Digital Music, Queen Mary, University of London.
Chris@116:     This file copyright 2006 Chris Cannam.
Chris@116:     
Chris@116:     This program is free software; you can redistribute it and/or
Chris@116:     modify it under the terms of the GNU General Public License as
Chris@116:     published by the Free Software Foundation; either version 2 of the
Chris@116:     License, or (at your option) any later version.  See the file
Chris@116:     COPYING included with this distribution for more information.
Chris@116: */
Chris@116: 
Chris@116: #ifndef _UNIT_DATABASE_H_
Chris@116: #define _UNIT_DATABASE_H_
Chris@116: 
Chris@116: #include <QObject>
Chris@116: #include <QString>
Chris@116: #include <QStringList>
Chris@116: #include <map>
Chris@116: 
Chris@116: // This grandly named class is just a list of the names of known scale
Chris@116: // units for the various models, for use as the set of fixed values in
Chris@116: // unit dropdown menus etc.  Of course, the user should be allowed to
Chris@116: // enter their own as well.
Chris@116: 
Chris@116: class UnitDatabase : public QObject
Chris@116: {
Chris@116:     Q_OBJECT
Chris@116: 
Chris@116: public:
Chris@116:     static UnitDatabase *getInstance();
Chris@116: 
Chris@116:     QStringList getKnownUnits() const;
Chris@116:     void registerUnit(QString unit);
Chris@116:     
Chris@116:     int getUnitId(QString unit);
Chris@116:     QString getUnitById(int id);
Chris@116: 
Chris@116: signals:
Chris@116:     void unitDatabaseChanged();
Chris@116: 
Chris@116: protected:
Chris@116:     UnitDatabase();
Chris@116: 
Chris@116:     typedef std::map<QString, int> UnitMap;
Chris@116:     UnitMap m_units;
Chris@116:     int m_nextId;
Chris@116: 
Chris@116:     static UnitDatabase m_instance;
Chris@116: };
Chris@116: 
Chris@116: #endif
Chris@116: