ED247 Library  VA2.3.0
Implementation of ED247-A standard
ed247_stream_assistant.h
1 /* -*- mode: c++; c-basic-offset: 2 -*- */
2 #ifndef _ED247_STREAM_ASSISTANT_H_
3 #define _ED247_STREAM_ASSISTANT_H_
4 #include "ed247.h"
5 #include "ed247_xml.h"
6 #include "ed247_signal.h"
7 #include "ed247_sample.h"
8 
9 
10 // base structures for C API
13 };
14 
15 
16 namespace ed247
17 {
18  class Stream;
19 
21  {
22  public:
23 
24  StreamAssistant(Stream* stream);
25  virtual ~StreamAssistant();
26 
27  Stream* get_api_stream() { return _stream; }
28 
29  // Write a signal to the stream
30  virtual bool write(const Signal& signal, const void* data, uint32_t size) = 0;
31  // Read a signal from the stream
32  virtual bool read(const Signal& signal, const void** data, uint32_t* size) = 0;
33 
34  // See stream::push_sample() for details
35  virtual bool push(const ed247_timestamp_t* data_timestamp, bool* full) = 0;
36  // See stream::pop_sample() for details
37  virtual ed247_status_t pop(const ed247_timestamp_t** data_timestamp, const ed247_timestamp_t** recv_timestamp,
38  const ed247_sample_details_t** frame_details, bool* empty) = 0;
39 
40  // Check is some signals han been written since last push
41  bool was_written() { return _was_written; }
42 
43  // Push data only if was_written(). See stream::push_sample() for details
44  bool push_if_was_written(const ed247_timestamp_t* data_timestamp, bool* full);
45 
46  protected:
47  Stream* _stream;
48  Sample _buffer; // WARN: buffer content depend on stream type and direction for performances reasons
49  bool _was_written; // true if some signals has been written since last push
50 
51  ED247_FRIEND_TEST();
52  };
53 
54 
56  {
57  public:
59 
60  virtual bool write(const Signal& signal, const void* data, uint32_t size) override;
61  virtual bool read(const Signal& signal, const void** data, uint32_t * size) override;
62 
63  virtual bool push(const ed247_timestamp_t* data_timestamp, bool* full) override;
64  virtual ed247_status_t pop(const ed247_timestamp_t** data_timestamp, const ed247_timestamp_t** recv_timestamp,
65  const ed247_sample_details_t** frame_details, bool* empty) override;
66  };
67 
69  {
70  public:
71  VNADStreamAssistant(Stream* stream);
72 
73  virtual bool write(const Signal& signal, const void* data, uint32_t size) override;
74  virtual bool read(const Signal& signal, const void** data, uint32_t * size) override;
75 
76  virtual bool push(const ed247_timestamp_t* data_timestamp, bool* full) override;
77  virtual ed247_status_t pop(const ed247_timestamp_t** data_timestamp, const ed247_timestamp_t** recv_timestamp,
78  const ed247_sample_details_t** frame_details, bool* empty) override;
79 
80  private:
81  // signal position -> Sample.
82  // Position may not be continuous so we cannot use a vector
83  std::unordered_map<uint32_t, Sample> _signal_samples;
84  };
85 
86 }
87 
88 #endif
Definition: ed247_sample.h:14
Definition: ed247_signal.h:42
Timestamp structure, seconds from EPOCH (January 1st 1970) and nanoseconds offset with reference to p...
Definition: ed247.h:209
Definition: ed247_stream_assistant.h:55
Definition: ed247_stream.h:43
Definition: ed247_stream_assistant.h:68
ed247_status_t
Status codes.
Definition: ed247.h:67
Definition: ed247_channel.cpp:37
Definition: ed247_stream_assistant.h:11
Definition: ed247_stream_assistant.h:20
Sample Details.
Definition: ed247.h:909