diff options
Diffstat (limited to 'sensor/include')
-rw-r--r-- | sensor/include/trygvis/sensor.h | 3 | ||||
-rw-r--r-- | sensor/include/trygvis/sensor/io.h | 86 |
2 files changed, 57 insertions, 32 deletions
diff --git a/sensor/include/trygvis/sensor.h b/sensor/include/trygvis/sensor.h index 4662bab..f8cfbe5 100644 --- a/sensor/include/trygvis/sensor.h +++ b/sensor/include/trygvis/sensor.h @@ -148,6 +148,9 @@ public: : dict(dict), values(values) { } + SampleRecord(const SampleRecord ©) : dict(copy.dict), values(copy.values) { + } + inline vec::const_iterator cbegin() const { return values.cbegin(); diff --git a/sensor/include/trygvis/sensor/io.h b/sensor/include/trygvis/sensor/io.h index f92b800..f86f2d9 100644 --- a/sensor/include/trygvis/sensor/io.h +++ b/sensor/include/trygvis/sensor/io.h @@ -12,29 +12,37 @@ namespace io { using namespace std; using namespace boost::asio; -class sample_output_stream_option { -public: +struct sample_output_stream_option { virtual ~sample_output_stream_option() { }; }; -class output_fields_option : public sample_output_stream_option { -public: +struct output_fields_option : sample_output_stream_option { ~output_fields_option() { } vector<string> fields; }; -class timestamp_field_option : public sample_output_stream_option { -public: - timestamp_field_option(string name) : name(name) { +struct timestamp_field_option : sample_output_stream_option { + timestamp_field_option(const string name) : name(name) { } ~timestamp_field_option() { } - string name; + const string name; +}; + +class table_name_option : public sample_output_stream_option { +public: + table_name_option(const string name) : name(name) { + } + + ~table_name_option() { + } + + const string name; }; class sample_output_stream_options : public vector<sample_output_stream_option *> { @@ -56,6 +64,44 @@ public: } }; +struct missing_required_option_error : runtime_error { + missing_required_option_error(string what) : runtime_error(what) { + } + + ~missing_required_option_error() { + } +}; + +class SampleStreamParser; + +class SampleOutputStream; + +/** + * Throws missing_required_option_error + */ +unique_ptr<SampleStreamParser> open_sample_stream_parser( + shared_ptr<SampleOutputStream> output, + KeyDictionary &dict, + sample_format_type type = sample_format_type::AUTO); + +/** + * Throws missing_required_option_error + */ +unique_ptr<SampleOutputStream> open_sample_output_stream( + shared_ptr<ostream> output, + KeyDictionary &dict, + sample_format_type type, + sample_output_stream_options options); + +static inline +unique_ptr<SampleOutputStream> open_sample_output_stream( + shared_ptr<ostream> output, + KeyDictionary &dict, + sample_format_type type) { + sample_output_stream_options options; + return open_sample_output_stream(output, dict, type, options); +} + class SampleOutputStream { public: virtual void write(SampleRecord const &sample) = 0; @@ -104,10 +150,6 @@ public: void write(SampleRecord const &sample); - const KeyDictionary &getDict() { - return dict; - } - private: void writeHeader(); @@ -212,26 +254,6 @@ private: unique_ptr<KeyValueSampleStreamParser> keyValueParser; }; -unique_ptr<SampleStreamParser> open_sample_stream_parser( - shared_ptr<SampleOutputStream> output, - KeyDictionary &dict, - sample_format_type type = sample_format_type::AUTO); - -unique_ptr<SampleOutputStream> open_sample_output_stream( - shared_ptr<ostream> output, - KeyDictionary &dict, - sample_format_type type, - sample_output_stream_options options); - -static inline -unique_ptr<SampleOutputStream> open_sample_output_stream( - shared_ptr<ostream> output, - KeyDictionary &dict, - sample_format_type type) { - sample_output_stream_options options; - return open_sample_output_stream(output, dict, type, options); -} - static inline unique_ptr<ThreadSafeSampleOutputStream> thread_safe_sample_output_stream(unique_ptr<SampleOutputStream> underlying) { return make_unique<ThreadSafeSampleOutputStream>(move(underlying)); |