fprime/Fw/Comp/ActiveComponentBase.hpp
Joshua Anderson 3cccd731d9
Refactor FW_OBJECT_NAMES switches and fix building without object names
Instead of adding the name argument to a constructor when FW_OBJECT_NAMES
is enabled, always supply a name argument.

Add a marco that conditionally sets the name to "" if FW_OBJECT_NAMES is not set.
This cleans up a lot of the conditional compilation switches that weren't being tested
and would silently break, while still stripping the strings from the binary.
2020-10-07 17:19:05 -07:00

48 lines
1.8 KiB
C++

/*
* ActiveComponentBase.hpp
*
* Created on: Aug 14, 2012
* Author: tcanham
*/
/*
* Description:
*/
#ifndef FW_ACTIVE_COMPONENT_BASE_HPP
#define FW_ACTIVE_COMPONENT_BASE_HPP
#include <Fw/Comp/QueuedComponentBase.hpp>
#include <Os/Task.hpp>
#include <FpConfig.hpp>
namespace Fw {
class ActiveComponentBase : public QueuedComponentBase {
public:
void start(NATIVE_INT_TYPE identifier, NATIVE_INT_TYPE priority, NATIVE_INT_TYPE stackSize, NATIVE_INT_TYPE cpuAffinity = -1); //!< called by instantiator when task is to be started
void exit(void); //!< exit task in active component
Os::Task::TaskStatus join(void **value_ptr); //!< provide return value of thread if value_ptr is not NULL
enum {
ACTIVE_COMPONENT_EXIT //!< message to exit active component task
};
PROTECTED:
ActiveComponentBase(const char* name); //!< Constructor
virtual ~ActiveComponentBase(); //!< Destructor
void init(NATIVE_INT_TYPE instance); //!< initialization code
virtual void preamble(void); //!< A function that will be called before the event loop is entered
virtual void loop(void); //!< The function that will loop dispatching messages
virtual void finalizer(void); //!< A function that will be called after exiting the loop
Os::Task m_task; //!< task object for active component
#if FW_OBJECT_TO_STRING == 1
virtual void toString(char* str, NATIVE_INT_TYPE size); //!< create string description of component
#endif
PRIVATE:
static void s_baseTask(void*); //!< function provided to task class for new thread.
static void s_baseBareTask(void*); //!< function provided to task class for new thread.
};
}
#endif