OpenRTM-aist 2.0.2
Loading...
Searching...
No Matches
RTC::PostFsmActionListener Class Referenceabstract

PostFsmActionListener class. More...

#include <FsmActionListener.h>

Public Member Functions

virtual ~PostFsmActionListener ()
 Destructor .
 
virtual void operator() (const char *state, ReturnCode_t ret)=0
 Virtual Callback function.
 

Static Public Member Functions

static const char * toString (PostFsmActionListenerType type)
 Convert PostFsmActionListenerType into the string.
 

Detailed Description

PostFsmActionListener class.

PostFsmActionListener class is a base class for the listener objects which realize callback to hook FSM related post-actions. To hook execution just before a FSM action, the callback object should be defined as follows, and set to RTObject through appropriate callback set function.

class MyListener
  : public PostFsmActionListener
{
  std::string m_name;
public:
  MyListener(const char* name) : m_name(name) {}
  virtual ~MyListener() {}

  virtual void operator()(const char* state_name, ReturnCode\t ret)
  {
    std::cout << "Listner name:  " m_name << std::endl;
    std::cout << "Current state: " state_name << std::endl;
  };
};

The listener class defined above is set to RTObject as follows.

RTC::ReturnCode_t ConsoleIn::onInitialize()
{
    addPostFsmActionListener(PostFsmActionListenerType::POST_ON_STATE_CHANGE,
                            new MyListener("init listener"),
                            true);
   :

The first argument "POST_ON_STATE_CHANGE" specifies callback hook point, and the following values are available. Not all the callback points are implemented. It depends on the FSM implementations.

  • POST_ON_INIT: just after "init" action
  • POST_ON_ENTRY: just after "entry" action
  • POST_ON_DO: just after "do" action
  • POST_ON_EXIT: just after "exit" action
  • POST_ON_STATE_CHANGE: just after state transition action

The second argument is a pointers to the listener object. The third argument is a flag for automatic object destruction. When "true" is given to the third argument, the given object in second argument is automatically destructed with RTObject. In the "false " case, the ownership of the object is left in the caller side, and then destruction of the object must be done by users' responsibility.

It is good for setting "true" as third argument, if the listener object life span is equals to the RTObject's life cycle. On the otehr hand, if callbacks are required to set/unset depending on its situation, the third argument could be "false". In that case, listener objects pointers must be stored to member variables, and set/unset of the listener objects shoud be paerformed throguh RTObject_impl::addPostFsmActionListener()/removePostFsmActionListener() functions.

Constructor & Destructor Documentation

◆ ~PostFsmActionListener()

virtual RTC::PostFsmActionListener::~PostFsmActionListener ( )
virtual

Destructor .

Member Function Documentation

◆ operator()()

virtual void RTC::PostFsmActionListener::operator() ( const char * state,
ReturnCode_t ret )
pure virtual

Virtual Callback function.

This is a the Callback function for PostFsmActionListener.

◆ toString()

static const char * RTC::PostFsmActionListener::toString ( PostFsmActionListenerType type)
inlinestatic

Convert PostFsmActionListenerType into the string.

Convert PostFsmActionListenerType into the string.

Parameters
typeThe target PostFsmActionListenerType for transformation
Returns
Trnasformation result of string representation

References RTC::POST_FSM_ACTION_LISTENER_NUM.


The documentation for this class was generated from the following file: