aboutsummaryrefslogtreecommitdiff
path: root/sensor/include/trygvis
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-03-28 22:22:16 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-03-28 22:22:16 +0100
commit34669098e138d595aadc39fbf8c0cdd004c0916d (patch)
tree88baf25b2632cb60b4845ebe983c333c9418de89 /sensor/include/trygvis
parent8d9760f9bfc8be9b1abad9a8212b14ffd4552fd7 (diff)
downloadble-toys-34669098e138d595aadc39fbf8c0cdd004c0916d.tar.gz
ble-toys-34669098e138d595aadc39fbf8c0cdd004c0916d.tar.bz2
ble-toys-34669098e138d595aadc39fbf8c0cdd004c0916d.tar.xz
ble-toys-34669098e138d595aadc39fbf8c0cdd004c0916d.zip
o Adding back SQL output.
Diffstat (limited to 'sensor/include/trygvis')
-rw-r--r--sensor/include/trygvis/sensor.h3
-rw-r--r--sensor/include/trygvis/sensor/io.h86
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 &copy) : 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));