EmbeddedProto  2.0.0
EmbeddedProto is a C++ Protocol Buffer implementation specifically suitable for microcontrollers.
ReadBufferInterface.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Embedded AMS B.V. - All Rights Reserved
3  *
4  * This file is part of Embedded Proto.
5  *
6  * Embedded Proto is open source software: you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as published
8  * by the Free Software Foundation, version 3 of the license.
9  *
10  * Embedded Proto is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Embedded Proto. If not, see <https://www.gnu.org/licenses/>.
17  *
18  * For commercial and closed source application please visit:
19  * <https://EmbeddedProto.com/license/>.
20  *
21  * Embedded AMS B.V.
22  * Info:
23  * info at EmbeddedProto dot com
24  *
25  * Postal address:
26  * Johan Huizingalaan 763a
27  * 1066 VH, Amsterdam
28  * the Netherlands
29  */
30 
31 #ifndef _READ_BUFFER_INTERFACE_H_
32 #define _READ_BUFFER_INTERFACE_H_
33 
34 #include <cstdint>
35 
36 
37 namespace EmbeddedProto
38 {
40 
44  {
45  public:
46 
47  ReadBufferInterface() = default;
48  virtual ~ReadBufferInterface() = default;
49 
51  virtual uint32_t get_size() const = 0;
52 
54  virtual uint32_t get_max_size() const = 0;
55 
57 
65  virtual bool peek(uint8_t& byte) const = 0;
66 
68  virtual void advance() = 0;
69 
71 
75  virtual void advance(const uint32_t N) = 0;
76 
78 
86  virtual bool pop(uint8_t& byte) = 0;
87 
88  };
89 
90 } // End of namespace EmbeddedProto
91 
92 #endif // End of _READ_BUFFER_INTERFACE_H_
EmbeddedProto::ReadBufferInterface
The pure virtual definition of a message buffer to read from.
Definition: ReadBufferInterface.h:43
EmbeddedProto
Definition: Errors.h:34
EmbeddedProto::ReadBufferInterface::pop
virtual bool pop(uint8_t &byte)=0
Obtain the value of the oldest byte in the buffer and remove it from the buffer.
EmbeddedProto::ReadBufferInterface::advance
virtual void advance()=0
Advances the internal read index by one when the buffer is not empty.
EmbeddedProto::ReadBufferInterface::peek
virtual bool peek(uint8_t &byte) const =0
Obtain the value of the oldest byte in the buffer.
EmbeddedProto::ReadBufferInterface::get_max_size
virtual uint32_t get_max_size() const =0
Obtain the total number of bytes which can at most be stored in the buffer.
EmbeddedProto::ReadBufferInterface::ReadBufferInterface
ReadBufferInterface()=default
EmbeddedProto::ReadBufferInterface::get_size
virtual uint32_t get_size() const =0
Obtain the total number of bytes currently stored in the buffer.
EmbeddedProto::ReadBufferInterface::~ReadBufferInterface
virtual ~ReadBufferInterface()=default