aboutsummaryrefslogtreecommitdiff
path: root/apps/SoilMoistureIo.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/SoilMoistureIo.h')
-rw-r--r--apps/SoilMoistureIo.h62
1 files changed, 59 insertions, 3 deletions
diff --git a/apps/SoilMoistureIo.h b/apps/SoilMoistureIo.h
index fac518c..bdb0932 100644
--- a/apps/SoilMoistureIo.h
+++ b/apps/SoilMoistureIo.h
@@ -26,7 +26,8 @@ enum class sample_format_type {
CSV,
KEY_VALUE,
JSON,
- SQL
+ SQL,
+ RRD,
};
string to_string(const sample_format_type &arg);
@@ -48,10 +49,52 @@ unique_ptr<SampleStreamParser> open_sample_input_stream(
KeyDictionary &dict,
sample_format_type type = sample_format_type::AUTO);
+class sample_output_stream_option {
+public:
+ virtual ~sample_output_stream_option() {
+ };
+};
+
+class output_fields : public sample_output_stream_option {
+public:
+// output_fields() {
+// }
+//
+// output_fields(std::vector<string>::iterator begin, std::vector<string>::iterator end) :
+// fields(begin, end) {
+// }
+
+ ~output_fields() {
+ }
+
+ vector<string> fields;
+};
+
+
+class timestamp_field : public sample_output_stream_option {
+public:
+ timestamp_field(string name) : name(name) {
+ }
+
+ ~timestamp_field() {
+ }
+
+ string name;
+};
+
+unique_ptr<SampleOutputStream> open_sample_output_stream(
+ shared_ptr<ostream> output,
+ KeyDictionary &dict,
+ sample_format_type type,
+ vector<sample_output_stream_option *> options);
+
+static inline
unique_ptr<SampleOutputStream> open_sample_output_stream(
shared_ptr<ostream> output,
KeyDictionary &dict,
- sample_format_type type);
+ sample_format_type type) {
+ return open_sample_output_stream(output, dict, type);
+}
class sample_exception : public runtime_error {
public:
@@ -209,7 +252,7 @@ public:
return o<A>(boost::lexical_cast<A>(value.get()));
}
- string to_string() {
+ string to_string() const {
SampleKeyIndex i = 0;
string s;
for (auto ptr = values.begin(); ptr != values.end(); ptr++, i++) {
@@ -285,6 +328,18 @@ private:
shared_ptr<ostream> stream;
};
+class RrdSampleOutputStream : public SampleOutputStream {
+public:
+ RrdSampleOutputStream(shared_ptr<ostream> stream, KeyDictionary &dict, const SampleKey *timestamp_key, o<output_fields *> output_fields);
+
+ void write(SampleRecord const &sample) override;
+
+private:
+ vector<SampleKey *> keys;
+ shared_ptr<ostream> stream;
+ const SampleKey *timestamp_key;
+};
+
class SqlSampleOutputStream : public SampleOutputStream {
public:
SqlSampleOutputStream(shared_ptr<ostream> stream, KeyDictionary &dict, string table_name);
@@ -299,6 +354,7 @@ private:
class SampleStreamParser {
public:
+ // TODO: return number of samples found for progress indication?
virtual void process(mutable_buffers_1 buffer) = 0;
virtual sample_format_type type() {