F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
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_FwIndexType "]",
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_FwIndexType "]",
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 
81  {
82  FW_ASSERT(
83  (0 <= portNum) && (portNum < this->getNum_bufferAllocate_InputPorts()),
84  static_cast<FwAssertArgType>(portNum)
85  );
86 
87  return &this->m_bufferAllocate_InputPort[portNum];
88  }
89 
92  {
93  FW_ASSERT(
94  (0 <= portNum) && (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 
106  StaticMemoryComponentBase(const char* compName) :
107  Fw::PassiveComponentBase(compName)
108  {
109 
110  }
111 
114  {
115 
116  }
117 
118  // ----------------------------------------------------------------------
119  // Port handler base-class functions for typed input ports
120  //
121  // Call these functions directly to bypass the corresponding ports
122  // ----------------------------------------------------------------------
123 
126  FwIndexType portNum,
127  FwSizeType size
128  )
129  {
130  // Make sure port number is valid
131  FW_ASSERT(
132  (0 <= portNum) && (portNum < this->getNum_bufferAllocate_InputPorts()),
133  static_cast<FwAssertArgType>(portNum)
134  );
135 
136  Fw::Buffer retVal;
137 
138  // Lock guard mutex before calling
139  this->lock();
140 
141  // Call handler function
142  retVal = this->bufferAllocate_handler(
143  portNum,
144  size
145  );
146 
147  // Unlock guard mutex
148  this->unLock();
149 
150  return retVal;
151  }
152 
155  FwIndexType portNum,
156  Fw::Buffer& fwBuffer
157  )
158  {
159  // Make sure port number is valid
160  FW_ASSERT(
161  (0 <= portNum) && (portNum < this->getNum_bufferDeallocate_InputPorts()),
162  static_cast<FwAssertArgType>(portNum)
163  );
164 
165  // Lock guard mutex before calling
166  this->lock();
167 
168  // Call handler function
170  portNum,
171  fwBuffer
172  );
173 
174  // Unlock guard mutex
175  this->unLock();
176  }
177 
178  // ----------------------------------------------------------------------
179  // Mutex operations for guarded ports
180  //
181  // You can override these operations to provide more sophisticated
182  // synchronization
183  // ----------------------------------------------------------------------
184 
187  {
188  this->m_guardedPortMutex.lock();
189  }
190 
193  {
194  this->m_guardedPortMutex.unLock();
195  }
196 
197  // ----------------------------------------------------------------------
198  // Calls for messages received on typed input ports
199  // ----------------------------------------------------------------------
200 
201  Fw::Buffer StaticMemoryComponentBase ::
202  m_p_bufferAllocate_in(
203  Fw::PassiveComponentBase* callComp,
204  FwIndexType portNum,
205  FwSizeType size
206  )
207  {
208  FW_ASSERT(callComp);
209  StaticMemoryComponentBase* compPtr = static_cast<StaticMemoryComponentBase*>(callComp);
210  return compPtr->bufferAllocate_handlerBase(
211  portNum,
212  size
213  );
214  }
215 
216  void StaticMemoryComponentBase ::
217  m_p_bufferDeallocate_in(
218  Fw::PassiveComponentBase* callComp,
219  FwIndexType portNum,
220  Fw::Buffer& fwBuffer
221  )
222  {
223  FW_ASSERT(callComp);
224  StaticMemoryComponentBase* compPtr = static_cast<StaticMemoryComponentBase*>(callComp);
225  compPtr->bufferDeallocate_handlerBase(
226  portNum,
227  fwBuffer
228  );
229  }
230 
231 }
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
PlatformSizeType FwSizeType
Fw::InputBufferGetPort * get_bufferAllocate_InputPort(FwIndexType portNum)
I32 FwEnumStoreType
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
Fw::Buffer bufferAllocate_handlerBase(FwIndexType portNum, FwSizeType size)
Handler base-class function for input port bufferAllocate.
void init()
Object initializer.
Definition: ObjBase.cpp:24
static constexpr FwIndexType getNum_bufferAllocate_InputPorts()
virtual void bufferDeallocate_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferDeallocate.
virtual void unLock()
Unlock the guarded mutex.
void init()
Initialization function.
virtual void lock()
Lock the guarded mutex.
Fw::InputBufferSendPort * get_bufferDeallocate_InputPort(FwIndexType portNum)
const char * toChar() const
Definition: ObjectName.hpp:50
static constexpr FwIndexType getNum_bufferDeallocate_InputPorts()
void bufferDeallocate_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferDeallocate.
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
virtual ~StaticMemoryComponentBase()
Destroy StaticMemoryComponentBase object.
void setPortNum(FwIndexType portNum)
void init()
Initialization function.
StaticMemoryComponentBase(const char *compName="")
Construct StaticMemoryComponentBase object.
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
Auto-generated base for StaticMemory component.
Implementation of malloc based allocator.
virtual Fw::Buffer bufferAllocate_handler(FwIndexType portNum, FwSizeType size)=0
Handler for input port bufferAllocate.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34