kwave  18.07.70
Kwave::TypesMap< IDX, DATA > Class Template Referenceabstract

#include <TypesMap.h>

Collaboration diagram for Kwave::TypesMap< IDX, DATA >:
Collaboration graph

Public Member Functions

 TypesMap ()
 
virtual ~TypesMap ()
 
virtual void fill ()=0
 
virtual void append (IDX index, DATA data, const QString &name, const QString &description)
 
unsigned int count () const
 
IDX findFromData (const DATA &data) const
 
IDX findFromName (const QString &name) const
 
DATA data (IDX type) const
 
QString name (IDX type) const
 
QString description (IDX type, bool localized) const
 
QStringList allNames () const
 
QList< IDX > keys () const
 

Private Types

typedef QMap< IDX, Kwave::Triple< DATA, QString, QString > > TripleMap
 

Private Attributes

TripleMap m_list
 

Detailed Description

template<class IDX, class DATA>
class Kwave::TypesMap< IDX, DATA >

Definition at line 37 of file TypesMap.h.

Member Typedef Documentation

◆ TripleMap

template<class IDX, class DATA>
typedef QMap<IDX, Kwave::Triple <DATA, QString, QString> > Kwave::TypesMap< IDX, DATA >::TripleMap
private

Definition at line 40 of file TypesMap.h.

Constructor & Destructor Documentation

◆ TypesMap()

template<class IDX, class DATA>
Kwave::TypesMap< IDX, DATA >::TypesMap ( )
inline

Default constructor. Must be overwritten to initialize the list with useful values.

Definition at line 47 of file TypesMap.h.

48  :m_list()
49  {
50  }
TripleMap m_list
Definition: TypesMap.h:158

◆ ~TypesMap()

template<class IDX, class DATA>
virtual Kwave::TypesMap< IDX, DATA >::~TypesMap ( )
inlinevirtual

Destructor

Definition at line 53 of file TypesMap.h.

54  {
55  m_list.clear();
56  }
TripleMap m_list
Definition: TypesMap.h:158

Member Function Documentation

◆ allNames()

template<class IDX, class DATA>
QStringList Kwave::TypesMap< IDX, DATA >::allNames ( ) const
inline

Returns a string list with all names,

Definition at line 138 of file TypesMap.h.

139  {
140  QStringList names;
141  foreach (const IDX &it, m_list.keys()) {
142  names.append(m_list[it].second());
143  }
144  return names;
145  }
TripleMap m_list
Definition: TypesMap.h:158

◆ append()

template<class IDX, class DATA>
virtual void Kwave::TypesMap< IDX, DATA >::append ( IDX  index,
DATA  data,
const QString &  name,
const QString &  description 
)
inlinevirtual

Appends a new type into the map.

Parameters
indexunique index within the map
datathe data associated with the entry
namestring representation of the type, for internal usage in Kwave commands.
descriptiontext for the user interface

Definition at line 72 of file TypesMap.h.

74  {
76  triple(data, name, description);
77  m_list.insert(index, triple);
78  }
QString description(IDX type, bool localized) const
Definition: TypesMap.h:128
DATA data(IDX type) const
Definition: TypesMap.h:110
TripleMap m_list
Definition: TypesMap.h:158
QString name(IDX type) const
Definition: TypesMap.h:117

◆ count()

template<class IDX, class DATA>
unsigned int Kwave::TypesMap< IDX, DATA >::count ( ) const
inline

Returns the number of types.

Definition at line 81 of file TypesMap.h.

Referenced by Kwave::Functions::count(), Kwave::Interpolation::descriptions(), Kwave::Functions::function(), Kwave::Functions::name(), Kwave::PlayBackDialog::PlayBackDialog(), and Kwave::RecordDialog::RecordDialog().

81  {
82  return m_list.count();
83  }
TripleMap m_list
Definition: TypesMap.h:158
Here is the caller graph for this function:

◆ data()

template<class IDX, class DATA>
DATA Kwave::TypesMap< IDX, DATA >::data ( IDX  type) const
inline

Returns the data item of a type.

Definition at line 110 of file TypesMap.h.

Referenced by Kwave::TypesMap< window_function_t, unsigned int >::findFromData(), Kwave::Functions::function(), Kwave::RecordDialog::methodSelected(), Kwave::PlayBackDialog::PlayBackDialog(), and Kwave::FileInfoDialog::setupFileInfoTab().

111  {
112  Q_ASSERT(m_list.contains(type));
113  return m_list[type].first();
114  }
TripleMap m_list
Definition: TypesMap.h:158
Here is the caller graph for this function:

◆ description()

template<class IDX, class DATA>
QString Kwave::TypesMap< IDX, DATA >::description ( IDX  type,
bool  localized 
) const
inline

Returns the description of a type.

Parameters
typeindex of the type
localizedif true, the returned description is localized

Definition at line 128 of file TypesMap.h.

Referenced by Kwave::RecordPlugin::changeSampleFormat(), Kwave::Interpolation::descriptions(), Kwave::RecordPulseAudio::detectSupportedFormats(), Kwave::RecordALSA::initialize(), Kwave::RecordPulseAudio::initialize(), Kwave::AudiofileDecoder::open(), Kwave::PlayBackDialog::PlayBackDialog(), Kwave::RecordDialog::RecordDialog(), Kwave::RecordDialog::setSupportedSampleFormats(), and Kwave::FileInfoDialog::setupFileInfoTab().

129  {
130  if (!m_list.contains(type)) return QString();
131  QString s(m_list[type].third());
132  return (localized) ? i18n(s.toLatin1()) : s;
133  }
TripleMap m_list
Definition: TypesMap.h:158
Here is the caller graph for this function:

◆ fill()

template<class IDX, class DATA>
virtual void Kwave::TypesMap< IDX, DATA >::fill ( )
pure virtual

This function is abstract and must be overwritten to initially fill the map if it was empty.

Implemented in Kwave::FileInfo::PropertyTypesMap, Kwave::Interpolation::InterpolationMap, Kwave::WindowFunction::InitializedTypesMap, Kwave::SampleFormat::Map, Kwave::Functions::FunctionTypesMap, Kwave::PlayBackTypesMap, and Kwave::RecordTypesMap.

Referenced by Kwave::TypesMap< window_function_t, unsigned int >::~TypesMap().

Here is the caller graph for this function:

◆ findFromData()

template<class IDX, class DATA>
IDX Kwave::TypesMap< IDX, DATA >::findFromData ( const DATA &  data) const
inline

Try to find the type from the data. If the data item is not found, the return value is the default value of the type (casted from 0).

Definition at line 89 of file TypesMap.h.

Referenced by Kwave::RecordPlugin::changeSampleFormat(), Kwave::PlaybackController::checkMethod(), Kwave::PlayBackPlugin::createDevice(), Kwave::Interpolation::descriptions(), Kwave::RecordPulseAudio::detectSupportedFormats(), Kwave::SampleFormat::fromInt(), Kwave::RecordALSA::initialize(), Kwave::RecordPulseAudio::initialize(), Kwave::PlayBackDialog::methodSelected(), Kwave::PlayBackDialog::setMethod(), Kwave::RecordDialog::setMethod(), and Kwave::RecordDialog::setSupportedSampleFormats().

90  {
91  foreach (const IDX &it, m_list.keys()) {
92  if (m_list[it].first() == data) return it;
93  }
94  return IDX(0);
95  }
DATA data(IDX type) const
Definition: TypesMap.h:110
TripleMap m_list
Definition: TypesMap.h:158
Here is the caller graph for this function:

◆ findFromName()

template<class IDX, class DATA>
IDX Kwave::TypesMap< IDX, DATA >::findFromName ( const QString &  name) const
inline

Try to find the type from a name. If the name is not found, the return value is the default value of the type (casted from 0).

Definition at line 101 of file TypesMap.h.

102  {
103  foreach (const IDX &it, m_list.keys()) {
104  if (m_list[it].second() == name) return it;
105  }
106  return IDX(0);
107  }
TripleMap m_list
Definition: TypesMap.h:158
QString name(IDX type) const
Definition: TypesMap.h:117

◆ keys()

template<class IDX, class DATA>
QList<IDX> Kwave::TypesMap< IDX, DATA >::keys ( ) const
inline

Returns a list with all keys

Definition at line 150 of file TypesMap.h.

Referenced by Kwave::FileInfo::contains(), Kwave::FileInfo::dump(), Kwave::FileInfo::FileInfo(), Kwave::FileInfo::get(), Kwave::FileInfo::properties(), Kwave::FileInfo::set(), and Kwave::FileInfoDialog::setupFileInfoTab().

151  {
152  return m_list.keys();
153  }
TripleMap m_list
Definition: TypesMap.h:158
Here is the caller graph for this function:

◆ name()

template<class IDX, class DATA>
QString Kwave::TypesMap< IDX, DATA >::name ( IDX  type) const
inline

Member Data Documentation

◆ m_list


The documentation for this class was generated from the following file: