代码拉取完成,页面将自动刷新
同步操作将从 Alex/hfsm2_test 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/**
* @file penguin_fsm.h
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2022-08-03
*
* @copyright Copyright (c) 2022
*
*/
#ifndef PENGUIN_FSM_H_
#define PENGUIN_FSM_H_
#define HFSM2_ENABLE_LOG_INTERFACE
#define HFSM2_ENABLE_STRUCTURE_REPORT
#include "hfsm2/machine.hpp"
#include <iostream>
class Penguin;
/*************** 定义事件 ***************/
// 日出
struct Sunrise{};
// 日落
struct Sunset{};
// 豆豆
struct Doudou{};
/**************** 定义事件 ***************/
using M = hfsm2::MachineT<hfsm2::Config::ContextT<Penguin*>>;
#define S(s) struct s
using FSM = M::PeerRoot<S(Eatting), S(Sleep), S(BeatDoudou)>;
#undef S
struct Base : FSM::State {
template <typename TEvent>
void react(const TEvent&, FullControl&) noexcept {
std::cout << "nothing happend" << std::endl;
}
};
struct Eatting:Base{
using Base::react;
void react(const Doudou&, FullControl& f) noexcept; // NOLINT
};
struct Sleep: Base
{
using Base::react;
void react(const Sunrise&, FullControl& f) noexcept; // NOLINT
};
struct BeatDoudou: Base
{
using Base::react;
void react(const Sunset&, FullControl& f) noexcept; // NOLINT
};
// 状态变化记录
struct FSM_Logger:M::LoggerInterface{
static const char* stateName(const StateID stateId) noexcept {
switch (stateId) {
case 1:
return "Eatting";
case 2:
return "Sleep";
case 3:
return "BeatDoudou";
default:
return "###################";
}
}
void recordTransition(Context& ctx, const StateID origin,
const TransitionType,
const StateID target) noexcept override;
};
#endif // PENGUIN_FSM_H_
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。