48 FW_ASSERT(m_store ==
nullptr && m_store_size == 0);
55 m_high_water_mark = 0;
59 return m_allocated_size;
63 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
65 return m_store_size - m_allocated_size;
70 return (idx + amount) % m_store_size;
74 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
82 for (U32 i = 0; i < size; i++) {
84 m_store[idx] = buffer[i];
85 idx = advance_idx(idx);
87 m_allocated_size += size;
89 m_high_water_mark = (m_high_water_mark > m_allocated_size) ? m_high_water_mark : m_allocated_size;
94 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
95 return peek(
reinterpret_cast<U8&
>(value), offset);
99 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
101 if ((
sizeof(
U8) + offset) > m_allocated_size) {
106 value = m_store[idx];
111 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
113 if ((
sizeof(U32) + offset) > m_allocated_size) {
122 value = (value << 8) | static_cast<U32>(m_store[idx]);
123 idx = advance_idx(idx);
129 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
132 if ((size + offset) > m_allocated_size) {
139 buffer[i] = m_store[idx];
140 idx = advance_idx(idx);
146 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
148 if (amount > m_allocated_size) {
151 m_head_idx = advance_idx(m_head_idx, amount);
152 m_allocated_size -= amount;
157 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
162 return m_high_water_mark;
166 m_high_water_mark = 0;
169 #ifdef CIRCULAR_DEBUG
170 void CircularBuffer :: print() {
175 idx = advance_idx(idx);
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
PlatformAssertArgType FwAssertArgType
C++-compatible configuration header for fprime configuration.
static void log(const char *format,...)
log a formated string with supplied arguments
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)
void clear_high_water_mark()
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
@ FW_DESERIALIZE_BUFFER_EMPTY
Deserialization buffer was empty when trying to read more data.
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
@ FW_SERIALIZE_NO_ROOM_LEFT
No room left in the buffer to serialize data.