WriterEmbedded.h@1:578d6bbe9f09, 2011-12-16 (annotated)
- Committer:
- daan
- Date:
- Fri Dec 16 07:14:05 2011 +0000
- Revision:
- 1:578d6bbe9f09
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
daan | 1:578d6bbe9f09 | 1 | #ifndef WRITER_EMBEDDED_H |
daan | 1:578d6bbe9f09 | 2 | #define WRITER_EMBEDDED_H |
daan | 1:578d6bbe9f09 | 3 | |
daan | 1:578d6bbe9f09 | 4 | #include "stdint.h" |
daan | 1:578d6bbe9f09 | 5 | #include "WriterBase.h" |
daan | 1:578d6bbe9f09 | 6 | #include "RingBuffer.h" |
daan | 1:578d6bbe9f09 | 7 | |
daan | 1:578d6bbe9f09 | 8 | namespace olc { |
daan | 1:578d6bbe9f09 | 9 | |
daan | 1:578d6bbe9f09 | 10 | /** |
daan | 1:578d6bbe9f09 | 11 | * write ol commands to a bytestring. |
daan | 1:578d6bbe9f09 | 12 | **/ |
daan | 1:578d6bbe9f09 | 13 | |
daan | 1:578d6bbe9f09 | 14 | template <class T> |
daan | 1:578d6bbe9f09 | 15 | class WriterEmbedded : public WriterBase { |
daan | 1:578d6bbe9f09 | 16 | |
daan | 1:578d6bbe9f09 | 17 | public: |
daan | 1:578d6bbe9f09 | 18 | WriterEmbedded(T& aBuffer) : mBuffer(aBuffer) { |
daan | 1:578d6bbe9f09 | 19 | }; |
daan | 1:578d6bbe9f09 | 20 | inline int size() |
daan | 1:578d6bbe9f09 | 21 | { |
daan | 1:578d6bbe9f09 | 22 | return mBuffer.size(); |
daan | 1:578d6bbe9f09 | 23 | }; |
daan | 1:578d6bbe9f09 | 24 | inline int spaceLeft() |
daan | 1:578d6bbe9f09 | 25 | { |
daan | 1:578d6bbe9f09 | 26 | return mBuffer.capacityLeft(); |
daan | 1:578d6bbe9f09 | 27 | }; |
daan | 1:578d6bbe9f09 | 28 | |
daan | 1:578d6bbe9f09 | 29 | |
daan | 1:578d6bbe9f09 | 30 | protected: |
daan | 1:578d6bbe9f09 | 31 | T& mBuffer; |
daan | 1:578d6bbe9f09 | 32 | void put(uint8_t aValue) { |
daan | 1:578d6bbe9f09 | 33 | mBuffer.pushBack(aValue); |
daan | 1:578d6bbe9f09 | 34 | }; |
daan | 1:578d6bbe9f09 | 35 | }; |
daan | 1:578d6bbe9f09 | 36 | |
daan | 1:578d6bbe9f09 | 37 | } // end namespace ol |
daan | 1:578d6bbe9f09 | 38 | |
daan | 1:578d6bbe9f09 | 39 | #endif // WRITER_BASE_H |