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
ObjBase.cpp
Go to the documentation of this file.
1#include <FpConfig.hpp>
2#include <Fw/Obj/ObjBase.hpp>
3#include <cstring>
4#include <cstdio>
5#include <Fw/Types/Assert.hpp>
6
7namespace Fw {
8
9#if FW_OBJECT_REGISTRATION == 1
10 ObjRegistry* ObjBase::s_objRegistry = nullptr;
11#endif
12
13#if FW_OBJECT_NAMES == 1
14 ObjBase::ObjBase(const char* objName) {
15 if (nullptr == objName) {
16 this->setObjName("NoName");
17 } else {
18 this->setObjName(objName);
19 }
20 }
21#else
22 ObjBase::ObjBase(const char* objName) {
23
24 }
25#endif
26
28#if FW_OBJECT_REGISTRATION
29 if (ObjBase::s_objRegistry) {
30 ObjBase::s_objRegistry->regObject(this);
31 }
32#endif
33 }
34
36
37 }
38
39#if FW_OBJECT_NAMES == 1
40 const char* ObjBase::getObjName() {
41 return this->m_objName;
42 }
43
44 void ObjBase::setObjName(const char* name) {
45 strncpy(this->m_objName, name, sizeof(this->m_objName));
46 this->m_objName[sizeof(this->m_objName)-1] = 0;
47 }
48#if FW_OBJECT_TO_STRING == 1
49 void ObjBase::toString(char* str, NATIVE_INT_TYPE size) {
50 FW_ASSERT(size > 0);
51 if (snprintf(str, size, "Obj: %s",this->m_objName) < 0) {
52 str[0] = 0;
53 }
54 }
55#endif
56#endif
57
58#if FW_OBJECT_REGISTRATION == 1
59 void ObjBase::setObjRegistry(ObjRegistry* reg) {
60 ObjBase::s_objRegistry = reg;
61 }
62
63 ObjRegistry::~ObjRegistry() {
64 }
65
66#endif
67} // Fw
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
C++-compatible configuration header for fprime configuration.
Declarations for Fw::ObjBase and Fw::ObjRegistry.
void init()
Object initializer.
Definition ObjBase.cpp:27
virtual ~ObjBase()
Destructor.
Definition ObjBase.cpp:35
ObjBase(const char *name)
ObjBase constructor.
Definition ObjBase.cpp:22
Definition Buffer.cpp:21