25CircularBuffer :: CircularBuffer() :
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);
64 FW_ASSERT(m_allocated_size <= m_store_size, m_allocated_size);
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);
77 if (size > get_free_size()) {
82 for (U32 i = 0; i < size; i++) {
84 m_store[idx] = buffer[i];
85 idx = advance_idx(idx);
87 m_allocated_size += size;
88 FW_ASSERT(m_allocated_size <= this->get_capacity(), m_allocated_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;
165void CircularBuffer ::clear_high_water_mark() {
166 m_high_water_mark = 0;
170void CircularBuffer :: print() {
175 idx = advance_idx(idx);
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
C++-compatible configuration header for fprime configuration.
static void logMsg(const char *fmt, POINTER_CAST a0=0, POINTER_CAST a1=0, POINTER_CAST a2=0, POINTER_CAST a3=0, POINTER_CAST a4=0, POINTER_CAST a5=0, POINTER_CAST a6=0, POINTER_CAST a7=0, POINTER_CAST a8=0, POINTER_CAST a9=0)
void setup(U8 *const buffer, const NATIVE_UINT_TYPE size)
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.