Chris@498: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@498: 
Chris@498: /*
Chris@498:     Sonic Visualiser
Chris@498:     An audio file viewer and annotation editor.
Chris@498: 
Chris@498:     Sonic Annotator
Chris@498:     A utility for batch feature extraction from audio files.
Chris@498: 
Chris@498:     Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
Chris@498:     Copyright 2007-2008 QMUL.
Chris@498: 
Chris@498:     This program is free software; you can redistribute it and/or
Chris@498:     modify it under the terms of the GNU General Public License as
Chris@498:     published by the Free Software Foundation; either version 2 of the
Chris@498:     License, or (at your option) any later version.  See the file
Chris@498:     COPYING included with this distribution for more information.
Chris@498: */
Chris@498: 
Chris@498: #ifndef _FILE_FEATURE_WRITER_H_
Chris@498: #define _FILE_FEATURE_WRITER_H_
Chris@498: 
Chris@498: #include <string>
Chris@498: #include <map>
Chris@498: #include <set>
Chris@498: 
Chris@498: #include "FeatureWriter.h"
Chris@498: 
Chris@498: using std::string;
Chris@498: using std::map;
Chris@498: using std::set;
Chris@498: using std::pair;
Chris@498: 
Chris@498: class QTextStream;
Chris@498: class QFile;
Chris@498: 
Chris@498: class FileFeatureWriter : public FeatureWriter
Chris@498: {
Chris@498: public:
Chris@498:     virtual ~FileFeatureWriter();
Chris@498: 
Chris@498:     virtual ParameterList getSupportedParameters() const;
Chris@498:     virtual void setParameters(map<string, string> &params);
Chris@498: 
Chris@498: protected:
Chris@498:     enum FileWriteSupport {
Chris@498:         SupportOneFilePerTrackTransform = 1,
Chris@498:         SupportOneFilePerTrack = 2,
Chris@498:         SupportOneFileTotal = 4
Chris@498:     };
Chris@498: 
Chris@498:     FileFeatureWriter(int support, QString extension);
Chris@498:     QTextStream *getOutputStream(QString, TransformId);
Chris@498: 
Chris@498:     typedef pair<QString, TransformId> TrackTransformPair;
Chris@498:     typedef map<TrackTransformPair, QFile *> FileMap;
Chris@498:     typedef map<QFile *, QTextStream *> FileStreamMap;
Chris@498:     FileMap m_files;
Chris@498:     FileStreamMap m_streams;
Chris@498: 
Chris@498:     QString getOutputFilename(QString, TransformId);
Chris@498:     QFile *getOutputFile(QString, TransformId);
Chris@498: 
Chris@498:     int m_support;
Chris@498:     QString m_extension;
Chris@498:     QString m_baseDir;
Chris@498:     bool m_manyFiles;
Chris@498:     QString m_singleFileName;
Chris@498:     bool m_stdout;
Chris@498:     bool m_append;
Chris@498:     bool m_force;
Chris@498: };
Chris@498: 
Chris@498: #endif