F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PassiveComponentBase.cpp
Go to the documentation of this file.
2 #include <Fw/Types/Assert.hpp>
3 #include <FpConfig.hpp>
4 
6 
7 namespace Fw {
8 
9  PassiveComponentBase::PassiveComponentBase(const char* name) : Fw::ObjBase(name), m_idBase(0), m_instance(0) {
10  }
11 
12 #if FW_OBJECT_TO_STRING == 1
13  const char* PassiveComponentBase::getToStringFormatString() {
14  return "Comp: %s";
15  }
16 
17  void PassiveComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) {
18  FW_ASSERT(size > 0);
19  FW_ASSERT(buffer != nullptr);
20  Fw::FormatStatus status = Fw::ExternalString(buffer, static_cast<Fw::ExternalString::SizeType>(size)).format(
21  this->getToStringFormatString(),
22 #if FW_OBJECT_NAMES == 1
23  this->m_objName.toChar()
24 #else
25  "UNKNOWN"
26 #endif
27  );
28  if (status != Fw::FormatStatus::SUCCESS) {
29  buffer[0] = 0;
30  }
31  }
32 #endif
33 
35  }
36 
38  ObjBase::init();
39  this->m_instance = instance;
40  }
41 
43  return this->m_instance;
44  }
45 
47  setIdBase(const U32 idBase)
48  {
49  this->m_idBase = idBase;
50  }
51 
53  getIdBase() const
54  {
55  return this->m_idBase;
56  }
57 
58 }
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:55
PassiveComponentBase(const char *name)
Named constructor.
void init()
Object initializer.
Definition: ObjBase.cpp:26
void setIdBase(const U32)
Set the ID base.
Brief class description.
Definition: ObjBase.hpp:35
virtual ~PassiveComponentBase()
Destructor.
A string backed by an external buffer.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
C++-compatible configuration header for fprime configuration.
NATIVE_INT_TYPE getInstance() const
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:148
#define FW_ASSERT(...)
Definition: Assert.hpp:14
FormatStatus
status of string format calls
Definition: format.hpp:18