-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathstate_base.hpp
47 lines (37 loc) · 1019 Bytes
/
state_base.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef THE_STATE_HPP
#define THE_STATE_HPP
#include <memory>
#include <iostream>
#include <string>
class Session;
typedef std::shared_ptr<Session> session_ptr;
/**
* @class StateBase
* @author Michael Griffin
* @date 9/1/2015
* @file state_base.hpp
* @brief Virtual Class to manager Individual Interfaces
*/
class StateBase
{
public:
virtual ~StateBase()
{
m_session_data.reset();
}
virtual void update(const std::string &character_buffer, const bool &is_utf8) = 0;
virtual bool onEnter() = 0;
virtual bool onExit() = 0;
virtual void resume() {}
virtual std::string getStateID() const = 0;
explicit StateBase(session_ptr session_data)
: m_session_data(session_data)
, m_is_active(false)
{}
// This holds session data passed to each session.
session_ptr m_session_data;
bool m_is_active;
};
typedef std::shared_ptr<StateBase> state_ptr;
typedef std::weak_ptr<StateBase> state_wptr;
#endif // THE_STATE_HPP