EmbeddedProto  2.0.0
EmbeddedProto is a C++ Protocol Buffer implementation specifically suitable for microcontrollers.
WriteBufferInterface.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 _WRITE_BUFFER_INTERFACE_H_
32 #define _WRITE_BUFFER_INTERFACE_H_
33 
34 #include <cstdint>
35 
36 
37 namespace EmbeddedProto
38 {
40 
47  {
48  public:
49 
50  WriteBufferInterface() = default;
51  virtual ~WriteBufferInterface() = default;
52 
54  virtual void clear() = 0;
55 
57  virtual uint32_t get_size() const = 0;
58 
60  virtual uint32_t get_max_size() const = 0;
61 
63  virtual uint32_t get_available_size() const = 0;
64 
66 
70  virtual bool push(const uint8_t byte) = 0;
71 
73 
79  virtual bool push(const uint8_t* bytes, const uint32_t length) = 0;
80 
81  };
82 
83 } // End of namespace EmbeddedProto
84 
85 #endif // End of _WRITE_BUFFER_INTERFACE_H_
EmbeddedProto::WriteBufferInterface::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::WriteBufferInterface::get_size
virtual uint32_t get_size() const =0
Obtain the total number of bytes currently stored in the buffer.
EmbeddedProto::WriteBufferInterface::WriteBufferInterface
WriteBufferInterface()=default
EmbeddedProto::WriteBufferInterface::~WriteBufferInterface
virtual ~WriteBufferInterface()=default
EmbeddedProto
Definition: Errors.h:34
EmbeddedProto::WriteBufferInterface::push
virtual bool push(const uint8_t byte)=0
Push a single byte into the buffer.
EmbeddedProto::WriteBufferInterface
The pure virtual definition of a message buffer used for writing .
Definition: WriteBufferInterface.h:46
EmbeddedProto::WriteBufferInterface::get_available_size
virtual uint32_t get_available_size() const =0
Obtain the total number of bytes still available in the buffer.
EmbeddedProto::WriteBufferInterface::clear
virtual void clear()=0
Delete all data in the buffer.