svcore  1.9
FileFeatureWriter.h
Go to the documentation of this file.
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 
7  Sonic Annotator
8  A utility for batch feature extraction from audio files.
9 
10  Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
11  Copyright 2007-2008 QMUL.
12 
13  This program is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License as
15  published by the Free Software Foundation; either version 2 of the
16  License, or (at your option) any later version. See the file
17  COPYING included with this distribution for more information.
18 */
19 
20 #ifndef _FILE_FEATURE_WRITER_H_
21 #define _FILE_FEATURE_WRITER_H_
22 
23 #include <string>
24 #include <map>
25 #include <set>
26 
27 #include "FeatureWriter.h"
28 
29 using std::string;
30 using std::map;
31 using std::set;
32 using std::pair;
33 
34 class QTextStream;
35 class QFile;
36 
38 {
39 public:
40  virtual ~FileFeatureWriter();
41 
42  virtual ParameterList getSupportedParameters() const;
43  virtual void setParameters(map<string, string> &params);
44 
45  virtual void testOutputFile(QString trackId, TransformId transformId);
46  virtual void flush();
47  virtual void finish();
48 
49 protected:
54  };
55 
56  FileFeatureWriter(int support, QString extension);
57  QTextStream *getOutputStream(QString, TransformId);
58 
59  typedef pair<QString, TransformId> TrackTransformPair;
60  typedef map<TrackTransformPair, QFile *> FileMap;
61  typedef map<QFile *, QTextStream *> FileStreamMap;
64  QTextStream *m_prevstream;
65 
66  QString getOutputFilename(QString, TransformId);
67  QFile *getOutputFile(QString, TransformId);
68 
69  // subclass can implement this to be called before file is opened for append
70  virtual void reviewFileForAppending(QString) { }
71 
72  int m_support;
73  QString m_extension;
74  QString m_baseDir;
77  bool m_stdout;
78  bool m_append;
79  bool m_force;
80 };
81 
82 #endif
virtual ParameterList getSupportedParameters() const
QFile * getOutputFile(QString, TransformId)
QTextStream * m_prevstream
FileStreamMap m_streams
vector< Parameter > ParameterList
Definition: FeatureWriter.h:47
virtual void testOutputFile(QString trackId, TransformId transformId)
Throw FailedToOpenOutputStream if we can already tell that we will be unable to write to the output f...
map< QFile *, QTextStream * > FileStreamMap
virtual void setParameters(map< string, string > &params)
map< TrackTransformPair, QFile * > FileMap
pair< QString, TransformId > TrackTransformPair
QString getOutputFilename(QString, TransformId)
FileFeatureWriter(int support, QString extension)
QTextStream * getOutputStream(QString, TransformId)
QString TransformId
Definition: Transform.h:30
virtual void reviewFileForAppending(QString)