ESP  0.1
The Example-based Sensor Predictions (ESP) system tries to bring machine learning to the maker community.
stream.h
Go to the documentation of this file.
1 #pragma once
2 #include <atomic>
3 
4 #include <atomic>
5 
6 class Stream {
7  public:
8  Stream() : has_started_(false) {}
9 
13  virtual bool start() { has_started_ = true; return true; }
14  virtual void stop() { has_started_ = false; }
15 
16  void toggle() {
17  if (has_started_) { stop(); }
18  else { start(); }
19  }
20 
21  bool hasStarted() { return has_started_; }
22 
23  protected:
24  std::atomic_bool has_started_;
25 };
Definition: stream.h:6
bool hasStarted()
Definition: stream.h:21
std::atomic_bool has_started_
Definition: stream.h:24
virtual bool start()
Definition: stream.h:13
void toggle()
Definition: stream.h:16
Stream()
Definition: stream.h:8
virtual void stop()
Definition: stream.h:14