F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
StaticMemoryComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title StaticMemoryComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for StaticMemory component base class
5// ======================================================================
6
8#include "Fw/Types/Assert.hpp"
10#if FW_ENABLE_TEXT_LOGGING
11#include "Fw/Types/String.hpp"
12#endif
13
14namespace Svc {
15
16 // ----------------------------------------------------------------------
17 // Component initialization
18 // ----------------------------------------------------------------------
19
20 void StaticMemoryComponentBase ::
21 init(FwEnumStoreType instance)
22 {
23 // Initialize base class
25
26 // Connect input port bufferAllocate
27 for (
28 FwIndexType port = 0;
29 port < static_cast<FwIndexType>(this->getNum_bufferAllocate_InputPorts());
30 port++
31 ) {
32 this->m_bufferAllocate_InputPort[port].init();
33 this->m_bufferAllocate_InputPort[port].addCallComp(
34 this,
35 m_p_bufferAllocate_in
36 );
37 this->m_bufferAllocate_InputPort[port].setPortNum(port);
38
39#if FW_OBJECT_NAMES == 1
40 Fw::ObjectName portName;
41 portName.format(
42 "%s_bufferAllocate_InputPort[%" PRI_PlatformIntType "]",
43 this->m_objName.toChar(),
44 port
45 );
46 this->m_bufferAllocate_InputPort[port].setObjName(portName.toChar());
47#endif
48 }
49
50 // Connect input port bufferDeallocate
51 for (
52 FwIndexType port = 0;
53 port < static_cast<FwIndexType>(this->getNum_bufferDeallocate_InputPorts());
54 port++
55 ) {
56 this->m_bufferDeallocate_InputPort[port].init();
57 this->m_bufferDeallocate_InputPort[port].addCallComp(
58 this,
59 m_p_bufferDeallocate_in
60 );
61 this->m_bufferDeallocate_InputPort[port].setPortNum(port);
62
63#if FW_OBJECT_NAMES == 1
64 Fw::ObjectName portName;
65 portName.format(
66 "%s_bufferDeallocate_InputPort[%" PRI_PlatformIntType "]",
67 this->m_objName.toChar(),
68 port
69 );
70 this->m_bufferDeallocate_InputPort[port].setObjName(portName.toChar());
71#endif
72 }
73 }
74
75 // ----------------------------------------------------------------------
76 // Getters for typed input ports
77 // ----------------------------------------------------------------------
78
79 Fw::InputBufferGetPort* StaticMemoryComponentBase ::
80 get_bufferAllocate_InputPort(FwIndexType portNum)
81 {
83 portNum < this->getNum_bufferAllocate_InputPorts(),
84 static_cast<FwAssertArgType>(portNum)
85 );
86
87 return &this->m_bufferAllocate_InputPort[portNum];
88 }
89
90 Fw::InputBufferSendPort* StaticMemoryComponentBase ::
91 get_bufferDeallocate_InputPort(FwIndexType portNum)
92 {
94 portNum < this->getNum_bufferDeallocate_InputPorts(),
95 static_cast<FwAssertArgType>(portNum)
96 );
97
98 return &this->m_bufferDeallocate_InputPort[portNum];
99 }
100
101 // ----------------------------------------------------------------------
102 // Component construction and destruction
103 // ----------------------------------------------------------------------
104
105 StaticMemoryComponentBase ::
106 StaticMemoryComponentBase(const char* compName) :
107 Fw::PassiveComponentBase(compName)
108 {
109
110 }
111
112 StaticMemoryComponentBase ::
113 ~StaticMemoryComponentBase()
114 {
115
116 }
117
118 // ----------------------------------------------------------------------
119 // Getters for numbers of typed input ports
120 // ----------------------------------------------------------------------
121
122 FwIndexType StaticMemoryComponentBase ::
123 getNum_bufferAllocate_InputPorts() const
124 {
125 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferAllocate_InputPort));
126 }
127
128 FwIndexType StaticMemoryComponentBase ::
129 getNum_bufferDeallocate_InputPorts() const
130 {
131 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferDeallocate_InputPort));
132 }
133
134 // ----------------------------------------------------------------------
135 // Port handler base-class functions for typed input ports
136 //
137 // Call these functions directly to bypass the corresponding ports
138 // ----------------------------------------------------------------------
139
140 Fw::Buffer StaticMemoryComponentBase ::
141 bufferAllocate_handlerBase(
142 FwIndexType portNum,
143 U32 size
144 )
145 {
146 // Make sure port number is valid
147 FW_ASSERT(
148 portNum < this->getNum_bufferAllocate_InputPorts(),
149 static_cast<FwAssertArgType>(portNum)
150 );
151
152 Fw::Buffer retVal;
153
154 // Lock guard mutex before calling
155 this->lock();
156
157 // Call handler function
158 retVal = this->bufferAllocate_handler(
159 portNum,
160 size
161 );
162
163 // Unlock guard mutex
164 this->unLock();
165
166 return retVal;
167 }
168
169 void StaticMemoryComponentBase ::
170 bufferDeallocate_handlerBase(
171 FwIndexType portNum,
172 Fw::Buffer& fwBuffer
173 )
174 {
175 // Make sure port number is valid
176 FW_ASSERT(
177 portNum < this->getNum_bufferDeallocate_InputPorts(),
178 static_cast<FwAssertArgType>(portNum)
179 );
180
181 // Lock guard mutex before calling
182 this->lock();
183
184 // Call handler function
185 this->bufferDeallocate_handler(
186 portNum,
187 fwBuffer
188 );
189
190 // Unlock guard mutex
191 this->unLock();
192 }
193
194 // ----------------------------------------------------------------------
195 // Mutex operations for guarded ports
196 //
197 // You can override these operations to provide more sophisticated
198 // synchronization
199 // ----------------------------------------------------------------------
200
201 void StaticMemoryComponentBase ::
202 lock()
203 {
204 this->m_guardedPortMutex.lock();
205 }
206
207 void StaticMemoryComponentBase ::
208 unLock()
209 {
210 this->m_guardedPortMutex.unLock();
211 }
212
213 // ----------------------------------------------------------------------
214 // Calls for messages received on typed input ports
215 // ----------------------------------------------------------------------
216
217 Fw::Buffer StaticMemoryComponentBase ::
218 m_p_bufferAllocate_in(
219 Fw::PassiveComponentBase* callComp,
220 FwIndexType portNum,
221 U32 size
222 )
223 {
224 FW_ASSERT(callComp);
225 StaticMemoryComponentBase* compPtr = static_cast<StaticMemoryComponentBase*>(callComp);
226 return compPtr->bufferAllocate_handlerBase(
227 portNum,
228 size
229 );
230 }
231
232 void StaticMemoryComponentBase ::
233 m_p_bufferDeallocate_in(
234 Fw::PassiveComponentBase* callComp,
235 FwIndexType portNum,
236 Fw::Buffer& fwBuffer
237 )
238 {
239 FW_ASSERT(callComp);
240 StaticMemoryComponentBase* compPtr = static_cast<StaticMemoryComponentBase*>(callComp);
242 portNum,
243 fwBuffer
244 );
245 }
246
247}
#define FW_ASSERT(...)
Definition Assert.hpp:14
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:70
#define PRI_PlatformIntType
I32 FwEnumStoreType
Definition FpConfig.h:64
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:39
PlatformIndexType FwIndexType
Definition FpConfig.h:25
void init()
Object initializer.
Definition ObjBase.cpp:27
const char * toChar() const
void format(const CHAR *formatString,...)
write formatted string to buffer
Auto-generated base for StaticMemory component.
void bufferDeallocate_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferDeallocate.
Fw::Buffer bufferAllocate_handlerBase(FwIndexType portNum, U32 size)
Handler base-class function for input port bufferAllocate.