F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
TaskStatusEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TaskStatusEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for TaskStatus enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
10 #include "Fw/Types/Assert.hpp"
12 
13 namespace Os {
14 
15  // ----------------------------------------------------------------------
16  // Operators
17  // ----------------------------------------------------------------------
18 
20  operator=(const TaskStatus& obj)
21  {
22  this->e = obj.e;
23  return *this;
24  }
25 
27  operator=(T e1)
28  {
29  this->e = e1;
30  return *this;
31  }
32 
33 #ifdef BUILD_UT
34 
35  std::ostream& operator<<(std::ostream& os, const TaskStatus& obj) {
36  Fw::String s;
37  obj.toString(s);
38  os << s;
39  return os;
40  }
41 
42 #endif
43 
44  // ----------------------------------------------------------------------
45  // Member functions
46  // ----------------------------------------------------------------------
47 
49  isValid() const
50  {
51  return ((e >= OP_OK) && (e <= INVALID_STATE));
52  }
53 
56  {
57  const Fw::SerializeStatus status = buffer.serialize(
58  static_cast<SerialType>(this->e)
59  );
60  return status;
61  }
62 
65  {
66  SerialType es;
67  Fw::SerializeStatus status = buffer.deserialize(es);
68  if (status == Fw::FW_SERIALIZE_OK) {
69  this->e = static_cast<T>(es);
70  if (!this->isValid()) {
72  }
73  }
74  return status;
75  }
76 
77 #if FW_SERIALIZABLE_TO_STRING
78 
79  void TaskStatus ::
80  toString(Fw::StringBase& sb) const
81  {
82  Fw::String s;
83  switch (e) {
84  case OP_OK:
85  s = "OP_OK";
86  break;
87  case INVALID_HANDLE:
88  s = "INVALID_HANDLE";
89  break;
90  case INVALID_PARAMS:
91  s = "INVALID_PARAMS";
92  break;
93  case INVALID_STACK:
94  s = "INVALID_STACK";
95  break;
96  case UNKNOWN_ERROR:
97  s = "UNKNOWN_ERROR";
98  break;
99  case INVALID_AFFINITY:
100  s = "INVALID_AFFINITY";
101  break;
102  case DELAY_ERROR:
103  s = "DELAY_ERROR";
104  break;
105  case JOIN_ERROR:
106  s = "JOIN_ERROR";
107  break;
108  case ERROR_RESOURCES:
109  s = "ERROR_RESOURCES";
110  break;
111  case ERROR_PERMISSION:
112  s = "ERROR_PERMISSION";
113  break;
114  case INVALID_STATE:
115  s = "INVALID_STATE";
116  break;
117  default:
118  s = "[invalid]";
119  break;
120  }
121  sb.format("%s (%" PRIi32 ")", s.toChar(), e);
122  }
123 
124 #elif FW_ENABLE_TEXT_LOGGING
125 
126  void TaskStatus ::
127  toString(Fw::StringBase& sb) const
128  {
129  sb.format("%" PRIi32 "", e);
130  }
131 
132 #endif
133 
134 }
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
const char * toChar() const
Definition: String.hpp:50
FPP shadow-enum representing Os::Task::Status.
T e
The raw enum value.
I32 SerialType
The serial representation type.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialize raw enum value from SerialType.
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialize raw enum value to SerialType.
T
The raw enum type.
@ UNKNOWN_ERROR
unexpected error return value
@ INVALID_STATE
Task is in an invalid state for the operation.
@ INVALID_HANDLE
Task handle invalid.
@ INVALID_AFFINITY
unable to set the task affinity
@ DELAY_ERROR
error trying to delay the task
@ ERROR_RESOURCES
unable to allocate more tasks
@ OP_OK
message sent/received okay
@ ERROR_PERMISSION
permissions error setting-up tasks
@ JOIN_ERROR
error trying to join the task
@ INVALID_PARAMS
started task with invalid parameters
@ INVALID_STACK
started with invalid stack size
TaskStatus & operator=(const TaskStatus &obj)
Copy assignment operator (object)
bool isValid() const
Check raw enum value for validity.
SerializeStatus
forward declaration for string
@ FW_DESERIALIZE_FORMAT_ERROR
Deserialization data had incorrect values (unexpected data types)
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.