Numworks Epsilon  1.4.1
Graphing Calculator Operating System
streamable.h
Go to the documentation of this file.
1 #ifndef ION_DEVICE_USB_STREAMABLE_H
2 #define ION_DEVICE_USB_STREAMABLE_H
3 
4 #include <stdint.h>
5 #include <stddef.h>
6 
7 namespace Ion {
8 namespace USB {
9 namespace Device {
10 
11 class Streamable {
12 public:
13  uint16_t copy(void * target, size_t maxSize) const;
14 protected:
15  class Channel {
16  public:
17  Channel(void * pointer, size_t maxSize) :
18  m_pointer(pointer),
19  m_sizeLeft(maxSize)
20  {
21  }
22  template<typename T>
23  void push(T data) {
24  if (m_sizeLeft >= sizeof(T)) {
25  T * typedPointer = static_cast<T *>(m_pointer);
26  *typedPointer++ = data; // Actually push the data
27  m_pointer = static_cast<void *>(typedPointer);
28  m_sizeLeft -= sizeof(T);
29  }
30  }
31  size_t sizeLeft() { return m_sizeLeft; }
32  private:
33  void * m_pointer;
34  size_t m_sizeLeft;
35  };
36  virtual void push(Channel * c) const = 0;
37 };
38 
39 
40 }
41 }
42 }
43 
44 #endif
def data
Definition: i18n.py:176
#define T(x)
Definition: events.cpp:26
unsigned short uint16_t
Definition: stdint.h:5
Channel(void *pointer, size_t maxSize)
Definition: streamable.h:17
uint16_t copy(void *target, size_t maxSize) const
Definition: streamable.cpp:7
c(generic_all_nodes)
Definition: app.cpp:5
virtual void push(Channel *c) const =0
Definition: backlight.h:6