F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CircularBuffer.hpp
Go to the documentation of this file.
1/*
2 * CircularBuffer.hpp:
3 *
4 * Buffer used to efficiently store data in ring data structure. Uses an externally supplied
5 * data store as the backing for this buffer. Thus it is dependent on receiving sole ownership
6 * of the supplied buffer.
7 *
8 * Note: this given implementation loses one byte of the data store in order to ensure that a
9 * separate wrap-around tracking variable is not needed.
10 *
11 * Created on: Apr 4, 2019
12 * Author: lestarch
13 * Revised March 2022
14 * Author: bocchino
15 */
16
17#ifndef TYPES_CIRCULAR_BUFFER_HPP
18#define TYPES_CIRCULAR_BUFFER_HPP
19
20#include <FpConfig.hpp>
22
23//#define CIRCULAR_DEBUG
24
25namespace Types {
26
28 public:
36
47 CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size);
48
58 void setup(U8* const buffer, const NATIVE_UINT_TYPE size);
59
67 Fw::SerializeStatus serialize(const U8* const buffer, const NATIVE_UINT_TYPE size);
68
75 Fw::SerializeStatus peek(char& value, NATIVE_UINT_TYPE offset = 0) const;
82 Fw::SerializeStatus peek(U8& value, NATIVE_UINT_TYPE offset = 0) const;
89 Fw::SerializeStatus peek(U32& value, NATIVE_UINT_TYPE offset = 0) const;
90
98 Fw::SerializeStatus peek(U8* buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset = 0) const;
99
107
113
120
126
131
136
137#ifdef CIRCULAR_DEBUG
138 void print();
139#endif
140 PRIVATE:
147 NATIVE_UINT_TYPE advance_idx(NATIVE_UINT_TYPE idx, NATIVE_UINT_TYPE amount = 1) const;
149 U8* m_store;
151 NATIVE_UINT_TYPE m_store_size;
154 NATIVE_UINT_TYPE m_head_idx;
156 NATIVE_UINT_TYPE m_allocated_size;
158 NATIVE_UINT_TYPE m_high_water_mark;
159};
160} //End Namespace Types
161#endif
162
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
C++-compatible configuration header for fprime configuration.
Fw::SerializeStatus serialize(const U8 *const buffer, const NATIVE_UINT_TYPE size)
NATIVE_UINT_TYPE get_free_size() const
NATIVE_UINT_TYPE get_allocated_size() const
NATIVE_UINT_TYPE get_high_water_mark() const
void setup(U8 *const buffer, const NATIVE_UINT_TYPE size)
NATIVE_UINT_TYPE get_capacity() const
Fw::SerializeStatus peek(char &value, NATIVE_UINT_TYPE offset=0) const
Fw::SerializeStatus rotate(NATIVE_UINT_TYPE amount)
SerializeStatus
forward declaration for string