F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimpleObjRegistry.cpp
Go to the documentation of this file.
1 #include <Fw/Logger/Logger.hpp>
3 #include <FpConfig.hpp>
4 #include <Fw/Types/Assert.hpp>
5 #include <stdio.h>
6 #include <string.h>
7 
8 #if FW_OBJECT_REGISTRATION == 1
9 
10 namespace Fw {
11 
12  SimpleObjRegistry::SimpleObjRegistry(void) {
13  ObjBase::setObjRegistry(this);
14  this->m_numEntries = 0;
15  // Initialize pointer array
16  for (NATIVE_INT_TYPE entry = 0; entry < FW_OBJ_SIMPLE_REG_ENTRIES; entry++) {
17  this->m_objPtrArray[entry] = 0;
18  }
19  }
20 
21  SimpleObjRegistry::~SimpleObjRegistry(void) {
22  ObjBase::setObjRegistry(0);
23  }
24 
25  void SimpleObjRegistry::dump(void) {
26  for (NATIVE_INT_TYPE obj = 0; obj < this->m_numEntries; obj++) {
27 #if FW_OBJECT_NAMES == 1
28 #if FW_OBJECT_TO_STRING == 1
29  char objDump[FW_OBJ_SIMPLE_REG_BUFF_SIZE];
30  this->m_objPtrArray[obj]->toString(objDump,sizeof(objDump));
31  Fw::Logger::logMsg("Entry: %d Ptr: %p Str: %s\n", obj,
32  reinterpret_cast<POINTER_CAST>(this->m_objPtrArray[obj]), reinterpret_cast<POINTER_CAST>(objDump));
33 #else
34  Fw::Logger::logMsg("Entry: %d Ptr: %p Name: %s\n",obj,
35  reinterpret_cast<POINTER_CAST>(this->m_objPtrArray[obj]),
36  reinterpret_cast<POINTER_CAST>(this->m_objPtrArray[obj]->getObjName()));
37 #endif // FW_OBJECT_TO_STRING
38 #else
39  Fw::Logger::logMsg("Entry: %d Ptr: %p Str:\n", obj, reinterpret_cast<POINTER_CAST>(this->m_objPtrArray[obj]));
40 #endif
41  }
42  }
43 
44 #if FW_OBJECT_NAMES == 1
45  void SimpleObjRegistry::dump(const char* objName) {
46  for (NATIVE_INT_TYPE obj = 0; obj < this->m_numEntries; obj++) {
47  char objDump[FW_OBJ_SIMPLE_REG_BUFF_SIZE];
48  if (strncmp(objName,this->m_objPtrArray[obj]->getObjName(),sizeof(objDump)) == 0) {
49 #if FW_OBJECT_TO_STRING == 1
50  this->m_objPtrArray[obj]->toString(objDump,sizeof(objDump));
51  Fw::Logger::logMsg("Entry: %d Ptr: %p Str: %s\n", obj,
52  reinterpret_cast<POINTER_CAST>(this->m_objPtrArray[obj]), reinterpret_cast<POINTER_CAST>(objDump));
53 #else
54  Fw::Logger::logMsg("Entry: %d Ptr: %p Name: %s\n",obj,
55  reinterpret_cast<POINTER_CAST>(this->m_objPtrArray[obj]),
56  reinterpret_cast<POINTER_CAST>(this->m_objPtrArray[obj]->getObjName()));
57 #endif
58  }
59  }
60  }
61 #endif
62  void SimpleObjRegistry::regObject(ObjBase* obj) {
63  FW_ASSERT(this->m_numEntries < FW_OBJ_SIMPLE_REG_ENTRIES);
64  this->m_objPtrArray[this->m_numEntries++] = obj;
65 
66  }
67 
68  void SimpleObjRegistry::clear(void) {
69  this->m_numEntries = 0;
70  }
71 
72 }
73 
74 #endif
75 
Assert.hpp
SimpleObjRegistry.hpp
Class declaration for a simple object registry.
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
FpConfig.hpp
ISF configuration file.
Fw::Logger::logMsg
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)
Definition: Logger.cpp:18
FW_OBJ_SIMPLE_REG_ENTRIES
#define FW_OBJ_SIMPLE_REG_ENTRIES
Number of objects stored in simple object registry.
Definition: FpConfig.hpp:192
FW_OBJ_SIMPLE_REG_BUFF_SIZE
#define FW_OBJ_SIMPLE_REG_BUFF_SIZE
Size of object registry dump string.
Definition: FpConfig.hpp:196
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Logger.hpp
Fw
Definition: Buffer.cpp:21