F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
Buffer.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title Buffer.hpp
3// \author mstarch
4// \brief hpp file for Fw::Buffer definition
5//
6// \copyright
7// Copyright 2009-2020, by the California Institute of Technology.
8// ALL RIGHTS RESERVED. United States Government Sponsorship
9// acknowledged.
10//
11// ======================================================================
12#ifndef BUFFER_HPP_
13#define BUFFER_HPP_
14
15#include <FpConfig.hpp>
17#if FW_SERIALIZABLE_TO_STRING
19 #include <cstdio> // snprintf
20 #ifdef BUILD_UT
21 #include <iostream>
22 #include <Fw/Types/String.hpp>
23 #endif
24#endif
25
26namespace Fw {
27
43class Buffer : public Fw::Serializable {
44
45public:
46
47 enum {
48 SERIALIZED_SIZE = sizeof(U32) + sizeof(U32) + sizeof(U8*),
49 NO_CONTEXT = 0xFFFFFFFF
50 };
51
56 Buffer();
57
60 Buffer(const Buffer& src);
61
69 Buffer(U8* data, U32 size, U32 context=NO_CONTEXT);
70
73 Buffer& operator=(const Buffer& src);
74
82 bool operator==(const Buffer& src) const;
83
84 // ----------------------------------------------------------------------
85 // Serialization functions
86 // ----------------------------------------------------------------------
87
95
105
115
116
117 // ----------------------------------------------------------------------
118 // Accessor functions
119 // ----------------------------------------------------------------------
120
123 U8* getData() const;
124
127 U32 getSize() const;
128
131 U32 getContext() const;
132
135 void setData(U8* data);
136
139 void setSize(U32 size);
140
143 void setContext(U32 context);
144
149 void set(U8* data, U32 size, U32 context=NO_CONTEXT);
150
151#if FW_SERIALIZABLE_TO_STRING || BUILD_UT
153 void toString(Fw::StringBase& text) const;
154#endif
155
156#ifdef BUILD_UT
159 friend std::ostream& operator<<(std::ostream& os, const Buffer& obj);
160#endif
161
162PRIVATE:
163 Fw::ExternalSerializeBuffer m_serialize_repr; //<! Representation for serialization and deserialization functions
164 U8* m_bufferData; //<! data - A pointer to the data
165 U32 m_size; //<! size - The data size in bytes
166 U32 m_context;
167
168};
169} // end namespace Fw
170#endif /* BUFFER_HPP_ */
171
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
C++-compatible configuration header for fprime configuration.
Declares ISF string base class.
bool operator==(const Buffer &src) const
Definition Buffer.cpp:56
U8 * getData() const
Definition Buffer.cpp:60
void set(U8 *data, U32 size, U32 context=NO_CONTEXT)
Definition Buffer.cpp:90
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Definition Buffer.cpp:126
U32 getSize() const
Definition Buffer.cpp:64
void setData(U8 *data)
Definition Buffer.cpp:72
void setContext(U32 context)
Definition Buffer.cpp:86
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &serialBuffer) const
Definition Buffer.cpp:103
Buffer & operator=(const Buffer &src)
Definition Buffer.cpp:48
void setSize(U32 size)
Definition Buffer.cpp:79
U32 getContext() const
Definition Buffer.cpp:68
SerializeBufferBase & getSerializeRepr()
Definition Buffer.cpp:99
@ NO_CONTEXT
Value representing no context.
Definition Buffer.hpp:49
@ SERIALIZED_SIZE
Size of Fw::Buffer when serialized.
Definition Buffer.hpp:48
forward declaration
Definition Buffer.cpp:21
SerializeStatus
forward declaration for string