v1.0
Dependencies: SDFileSystem mbed
RingBuffer/RingBuffer.h@0:0073c8def9f1, 2016-05-09 (annotated)
- Committer:
- jehoon
- Date:
- Mon May 09 00:13:40 2016 +0000
- Revision:
- 0:0073c8def9f1
WiFi Tracker
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jehoon | 0:0073c8def9f1 | 1 | /* |
jehoon | 0:0073c8def9f1 | 2 | Copyright (c) 2016 Jorj Bauer <jorj@jorj.org> |
jehoon | 0:0073c8def9f1 | 3 | |
jehoon | 0:0073c8def9f1 | 4 | |
jehoon | 0:0073c8def9f1 | 5 | Permission is hereby granted, free of charge, to any person obtaining |
jehoon | 0:0073c8def9f1 | 6 | a copy of this software and associated documentation files (the |
jehoon | 0:0073c8def9f1 | 7 | "Software"), to deal in the Software without restriction, including |
jehoon | 0:0073c8def9f1 | 8 | without limitation the rights to use, copy, modify, merge, publish, |
jehoon | 0:0073c8def9f1 | 9 | distribute, sublicense, and/or sell copies of the Software, and to |
jehoon | 0:0073c8def9f1 | 10 | permit persons to whom the Software is furnished to do so, subject to |
jehoon | 0:0073c8def9f1 | 11 | the following conditions: |
jehoon | 0:0073c8def9f1 | 12 | |
jehoon | 0:0073c8def9f1 | 13 | The above copyright notice and this permission notice shall be |
jehoon | 0:0073c8def9f1 | 14 | included in all copies or substantial portions of the Software. |
jehoon | 0:0073c8def9f1 | 15 | |
jehoon | 0:0073c8def9f1 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
jehoon | 0:0073c8def9f1 | 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
jehoon | 0:0073c8def9f1 | 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
jehoon | 0:0073c8def9f1 | 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
jehoon | 0:0073c8def9f1 | 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
jehoon | 0:0073c8def9f1 | 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
jehoon | 0:0073c8def9f1 | 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
jehoon | 0:0073c8def9f1 | 23 | |
jehoon | 0:0073c8def9f1 | 24 | https://github.com/JorjBauer/RingBuffer |
jehoon | 0:0073c8def9f1 | 25 | */ |
jehoon | 0:0073c8def9f1 | 26 | |
jehoon | 0:0073c8def9f1 | 27 | #include <mbed.h> |
jehoon | 0:0073c8def9f1 | 28 | |
jehoon | 0:0073c8def9f1 | 29 | typedef uint8_t byte; |
jehoon | 0:0073c8def9f1 | 30 | |
jehoon | 0:0073c8def9f1 | 31 | class RingBuffer { |
jehoon | 0:0073c8def9f1 | 32 | public: |
jehoon | 0:0073c8def9f1 | 33 | RingBuffer(); |
jehoon | 0:0073c8def9f1 | 34 | RingBuffer(int length); |
jehoon | 0:0073c8def9f1 | 35 | ~RingBuffer(); |
jehoon | 0:0073c8def9f1 | 36 | |
jehoon | 0:0073c8def9f1 | 37 | void init(int length); |
jehoon | 0:0073c8def9f1 | 38 | void clear(); |
jehoon | 0:0073c8def9f1 | 39 | |
jehoon | 0:0073c8def9f1 | 40 | bool isFull(); |
jehoon | 0:0073c8def9f1 | 41 | bool hasData(); |
jehoon | 0:0073c8def9f1 | 42 | bool addByte(byte b); |
jehoon | 0:0073c8def9f1 | 43 | byte consumeByte(); |
jehoon | 0:0073c8def9f1 | 44 | byte peek(int idx); |
jehoon | 0:0073c8def9f1 | 45 | int count(); |
jehoon | 0:0073c8def9f1 | 46 | int findBuf(char * str); |
jehoon | 0:0073c8def9f1 | 47 | |
jehoon | 0:0073c8def9f1 | 48 | |
jehoon | 0:0073c8def9f1 | 49 | private: |
jehoon | 0:0073c8def9f1 | 50 | byte *buffer; |
jehoon | 0:0073c8def9f1 | 51 | int max; |
jehoon | 0:0073c8def9f1 | 52 | int ptr; |
jehoon | 0:0073c8def9f1 | 53 | int fill; |
jehoon | 0:0073c8def9f1 | 54 | |
jehoon | 0:0073c8def9f1 | 55 | }; |