Program Listing for File event.hpp

Return to documentation for file (rcppsw/patterns/fsm/event.hpp)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "rcppsw/rcppsw.hpp"

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace rcppsw::patterns::fsm {

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
class event_signal {
 public:
  enum type {
    ekIGNORED = 0xFE,
    ekFATAL = 0xFF,

    ekHANDLED = 0,

    ekUNHANDLED = 1,

    ekRUN = 2,

    ekEXTERNAL_SIGNALS,
  };
};

class event_type {
 public:
  enum {
    ekNORMAL = 0,

    ekCHILD = 1,

    ekEXTERNAL_TYPES,
  };
};

class event_data {
 public:
  event_data(void) = default;
  explicit event_data(int signal, int type = event_type::ekNORMAL)
      : m_signal(signal), m_type(type) {}
  virtual ~event_data(void) = default;

  int signal(void) const { return m_signal; }
  void signal(int signal) { m_signal = signal; }
  int type(void) const { return m_type; }
  void type(int type) { m_type = type; }

  void reset(void) {
    signal(event_signal::ekIGNORED);
    type(event_type::ekNORMAL);
  }

 private:
  /* clang-format off */
  int m_signal{event_signal::ekIGNORED};
  int m_type{event_type::ekNORMAL};
  /* clang-format on */
};

class no_event_data {};

} /* namespace rcppsw::patterns::fsm */