aboutsummaryrefslogtreecommitdiff
path: root/sensor/include
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-07-11 14:30:14 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-07-11 14:30:14 +0200
commit650fb016ce36cfda2e8073764196655ee6a50567 (patch)
tree3889f4d25f5ee58286dd8a31e1bd7985845179ff /sensor/include
parent178a32835f3405399979b8635b88ce71c57f6cd6 (diff)
downloadble-toys-650fb016ce36cfda2e8073764196655ee6a50567.tar.gz
ble-toys-650fb016ce36cfda2e8073764196655ee6a50567.tar.bz2
ble-toys-650fb016ce36cfda2e8073764196655ee6a50567.tar.xz
ble-toys-650fb016ce36cfda2e8073764196655ee6a50567.zip
o Adding a parser::finish() method that indicates that the stream is done and any possibly buffered data should be parsed and processed.
Diffstat (limited to 'sensor/include')
-rw-r--r--sensor/include/trygvis/sensor/io.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/sensor/include/trygvis/sensor/io.h b/sensor/include/trygvis/sensor/io.h
index f86f2d9..b69bd7a 100644
--- a/sensor/include/trygvis/sensor/io.h
+++ b/sensor/include/trygvis/sensor/io.h
@@ -206,8 +206,9 @@ private:
class SampleStreamParser {
public:
- // TODO: return number of samples found for progress indication?
- virtual void process(mutable_buffers_1 &buffer) = 0;
+ virtual int process(mutable_buffers_1 &buffer) = 0;
+
+ virtual int finish() = 0;
virtual sample_format_type type() {
return type_;
@@ -233,10 +234,12 @@ public:
line(make_shared<vector<uint8_t>>()) {
}
- void process(mutable_buffers_1 &buffer) override;
+ int process(mutable_buffers_1 &buffer) override;
+
+ int finish() override;
private:
- void process_line(shared_ptr<vector<uint8_t>> packet);
+ void process_line(shared_ptr<vector<uint8_t>> &packet);
static const uint8_t packet_delimiter = '\n';
shared_ptr<SampleOutputStream> output;
@@ -247,7 +250,9 @@ class AutoSampleParser : public SampleStreamParser {
public:
AutoSampleParser(shared_ptr<SampleOutputStream> output, KeyDictionary &dict);
- virtual void process(mutable_buffers_1 &buffer) override;
+ virtual int process(mutable_buffers_1 &buffer) override;
+
+ virtual int finish() override;
private:
unique_ptr<SampleStreamParser> parser;