[6f8185]: libkwave / ArtsMultiIO.h Maximize Restore History

Download this file

ArtsMultiIO.h    107 lines (89 with data), 3.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
/***************************************************************************
ArtsMultiIO.h - template for multi-track aRts Source/Sink
-------------------
begin : Sun Dec 9 2001
copyright : (C) 2001 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _ARTS_MULTI_IO_H_
#define _ARTS_MULTI_IO_H_
#include "config.h"
#ifdef HAVE_ARTS_SUPPORT
#include <qglobal.h> // for qWarning()
#include <qptrvector.h>
#include <arts/artsflow.h>
template <class BASE, class ARTS_IO, class ARTS_IMPL, class KWAVE_IO>
class ArtsMultiIO:public BASE
{
public:
/**
* Constructor. Creates all i/o objects and holds them in
* an internal vector. If the creation of an object failed,
* the initialization will be aborted and the count of
* objects will be reduced.
* @param io something like a MultiTrackReader or MultiTrackWriter
*/
ArtsMultiIO(KWAVE_IO &io)
:m_count(io.tracks()), m_ios(io.tracks())
{
unsigned int t;
for (t=0; t < m_count; t++) {
m_ios.insert(t, 0);
ARTS_IMPL *r = new ARTS_IMPL(io[t]);
Q_ASSERT(r);
if (r) m_ios.insert(t, new ARTS_IO(
ARTS_IO::_from_base(r)));
Q_ASSERT(m_ios[t]);
if (!m_ios[t]) {
qWarning("ArtsMultiIO: creation of adapter failed!!!");
m_count = t;
break;
}
}
};
/**
* Destructor.
* Deletes all i/o objects in reverse order
*/
virtual ~ArtsMultiIO() {
m_ios.setAutoDelete(true);
while (m_count--) {
m_ios.remove(m_count);
}
};
/**
* Returns one of the aRts i/o objects.
* @param i index of the track [0..count-1]
* @return pointer to the object or 0 if index is out of range
*/
virtual Arts::Object *operator[](unsigned int i)
{
Q_ASSERT(i < m_count);
return (i < m_count) ? m_ios[i] : 0;
};
/** Calls start() for each aRts i/o object. */
virtual void start() {
for (unsigned int t=0; t < m_count; ++t) m_ios[t]->start();
};
/** Calls stop() for each aRts i/o object. */
virtual void stop() {
for (unsigned int t=0; t < m_count; ++t) m_ios[t]->stop();
};
protected:
/** number of aRts i/o objects */
unsigned int m_count;
/** vector of aRts i/o objects */
QPtrVector<ARTS_IO> m_ios;
};
#else /* HAVE_ARTS_SUPPORT */
#warning aRts support is disabled
#endif /* HAVE_ARTS_SUPPORT */
#endif /* _ARTS_MULTI_IO_H_ */