comparison transform/FeatureWriter.h @ 604:4541581067f3

* Better handling of failed-to-open-output-stream situations; ensure CSV writer closes files when they're finished rather than when it's finished
author Chris Cannam
date Tue, 08 Sep 2009 16:52:36 +0000
parents 1aefb666ecfc
children 608b4dc5ff34
comparison
equal deleted inserted replaced
603:e43368ec5ff0 604:4541581067f3
57 QString title; 57 QString title;
58 QString maker; 58 QString maker;
59 }; 59 };
60 virtual void setTrackMetadata(QString trackid, TrackMetadata metadata) { } 60 virtual void setTrackMetadata(QString trackid, TrackMetadata metadata) { }
61 61
62 class FailedToOpenOutputStream : virtual public std::exception
63 {
64 public:
65 FailedToOpenOutputStream(QString trackId, QString transformId) throw() :
66 m_trackId(trackId),
67 m_transformId(transformId)
68 { }
69 virtual ~FailedToOpenOutputStream() throw() { }
70 virtual const char *what() const throw() {
71 return QString("Failed to open output stream for track id \"%1\", transform id \"%2\"")
72 .arg(m_trackId).arg(m_transformId).toLocal8Bit().data();
73 }
74
75 protected:
76 QString m_trackId;
77 QString m_transformId;
78 };
79
62 // may throw FailedToOpenFile or other exceptions 80 // may throw FailedToOpenFile or other exceptions
63 81
64 virtual void write(QString trackid, 82 virtual void write(QString trackid,
65 const Transform &transform, 83 const Transform &transform,
66 const Vamp::Plugin::OutputDescriptor &output, 84 const Vamp::Plugin::OutputDescriptor &output,
68 std::string summaryType = "") = 0; 86 std::string summaryType = "") = 0;
69 87
70 virtual void flush() { } // whatever the last stream was 88 virtual void flush() { } // whatever the last stream was
71 89
72 virtual void finish() = 0; 90 virtual void finish() = 0;
91
92 virtual QString getWriterTag() const = 0;
73 }; 93 };
74 94
75 #endif 95 #endif