TECA
The Toolkit for Extreme Climate Analysis
teca_table_to_stream.h
1 #ifndef teca_table_to_stream_h
2 #define teca_table_to_stream_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 
8 #include <string>
9 #include <vector>
10 #include <iostream>
11 
12 TECA_SHARED_OBJECT_FORWARD_DECL(teca_table_to_stream)
13 
14 /// An algorithm that serializes a table to a C++ stream object.
16 {
17 public:
18  TECA_ALGORITHM_STATIC_NEW(teca_table_to_stream)
19  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_table_to_stream)
20  TECA_ALGORITHM_CLASS_NAME(teca_table_to_stream)
22 
23  // report/initialize to/from Boost program options
24  // objects.
25  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
26  TECA_SET_ALGORITHM_PROPERTIES()
27 
28  TECA_ALGORITHM_PROPERTY(std::string, header)
29  TECA_ALGORITHM_PROPERTY(std::string, footer)
30 
31  // set the stream object to store the table in.
32  // note that this stream must out live it's use here
33  // as streams are not copy-able and thus we store
34  // a reference to it.
35  void set_stream(std::ostream &s);
36 
37  // set the stream by name. stderr, stdout.
38  void set_stream(const std::string &s);
39  void set_stream_to_stderr();
40  void set_stream_to_stdout();
41 
42  // get the stream name
43  std::string get_stream();
44 
45 protected:
47 
48 private:
49  const_p_teca_dataset execute(
50  unsigned int port,
51  const std::vector<const_p_teca_dataset> &input_data,
52  const teca_metadata &request) override;
53 
54 private:
55  std::string header;
56  std::string footer;
57  std::ostream *stream;
58 };
59 
60 #endif
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:244
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:22
An algorithm that serializes a table to a C++ stream object.
Definition: teca_table_to_stream.h:16
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.