53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
#ifndef __WECHATSESSION_H__
|
|
#define __WECHATSESSION_H__
|
|
|
|
#include <boost/statechart/custom_reaction.hpp>
|
|
#include <boost/statechart/simple_state.hpp>
|
|
#include <boost/statechart/state_machine.hpp>
|
|
#include <chrono>
|
|
#include <string_view>
|
|
|
|
class ProcessInputEvent : public boost::statechart::event<ProcessInputEvent> {
|
|
public:
|
|
std::string text;
|
|
};
|
|
|
|
class IdleState;
|
|
|
|
class WeChatSession : public boost::statechart::state_machine<WeChatSession, IdleState> {
|
|
public:
|
|
WeChatSession(const std::string_view &username);
|
|
std::string processInput(const std::string_view &text);
|
|
void printHelp();
|
|
void printCurrentDateTime();
|
|
void playRandomMusic();
|
|
void stopPlayMusic();
|
|
std::chrono::system_clock::time_point lastAccessedTime() const;
|
|
void setReply(std::string &&reply);
|
|
|
|
private:
|
|
std::string m_username;
|
|
std::chrono::system_clock::time_point m_lastAccessedTime;
|
|
std::string m_reply;
|
|
};
|
|
|
|
class IdleState : public boost::statechart::simple_state<IdleState, WeChatSession> {
|
|
public:
|
|
typedef boost::statechart::custom_reaction<ProcessInputEvent> reactions;
|
|
boost::statechart::result react(const ProcessInputEvent &);
|
|
};
|
|
|
|
class SetAlarmState : public boost::statechart::simple_state<SetAlarmState, WeChatSession> {
|
|
public:
|
|
typedef boost::statechart::custom_reaction<ProcessInputEvent> reactions;
|
|
boost::statechart::result react(const ProcessInputEvent &);
|
|
SetAlarmState();
|
|
};
|
|
|
|
class SetTtsState : public boost::statechart::simple_state<SetTtsState, WeChatSession> {
|
|
public:
|
|
typedef boost::statechart::custom_reaction<ProcessInputEvent> reactions;
|
|
boost::statechart::result react(const ProcessInputEvent &);
|
|
};
|
|
|
|
#endif // __WECHATSESSION_H__
|