20 #ifndef ESSENTIA_FILEOUTPUT_H
21 #define ESSENTIA_FILEOUTPUT_H
24 #include "../streamingalgorithm.h"
25 #include "../../streamutil.h"
31 template <
typename TokenType>
inline void write_binary(std::ostream* _stream,
32 const TokenType& value) {
33 _stream->write((
const char*) &value,
sizeof(TokenType));
36 template <>
void inline write_binary<std::vector<Real> >(std::ostream* _stream,
37 const std::vector<Real>& value) {
38 _stream->write((
const char*) &value[0], value.size() *
sizeof(
Real));
42 template <
typename TokenType,
typename StorageType = TokenType>
53 declareInput(
_data, 1,
"data",
"the incoming data to be stored in the output file");
63 declareParameter(
"filename",
"the name of the output file (use '-' for stdout)",
"",
"out.txt");
68 if (!
parameter(
"filename").isConfigured()) {
111 void write(
const TokenType& value) {
const Parameter & parameter(const std::string &key) const
Definition: configurable.h:105
void declareParameter(const std::string &name, const std::string &desc, const std::string &range, const Parameter &defaultValue)
void setName(const std::string &name)
Definition: configurable.h:53
std::string toString(int precision=12) const
Definition: streamingalgorithm.h:140
void declareInput(SinkBase &sink, const std::string &name, const std::string &desc)
Definition: fileoutput.h:43
std::ostream * _stream
Definition: fileoutput.h:46
FileOutput()
Definition: fileoutput.h:51
Sink< TokenType > _data
Definition: fileoutput.h:45
AlgorithmStatus process()
Definition: fileoutput.h:95
std::string _filename
Definition: fileoutput.h:47
void createOutputStream()
Definition: fileoutput.h:81
void declareParameters()
Definition: fileoutput.h:62
~FileOutput()
Definition: fileoutput.h:58
bool _binary
Definition: fileoutput.h:48
void configure()
Definition: fileoutput.h:67
void write(const TokenType &value)
Definition: fileoutput.h:111
#define EXEC_DEBUG(msg)
Definition: debugging.h:161
void write_binary(std::ostream *_stream, const TokenType &value)
Definition: fileoutput.h:31
AlgorithmStatus
Definition: streamingalgorithm.h:106
@ OK
Definition: streamingalgorithm.h:107
@ NO_INPUT
Definition: streamingalgorithm.h:111
Definition: algorithm.h:28
float Real
Definition: types.h:69
#define NULL
Definition: tnt_i_refvec.h:33