blob: a5d3d3f44b0c9f7251d088736f9f0854f798e862 (
plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#ifndef S_STATEMGR_H
#define S_STATEMGR_H
#include "s/s_StateID.hpp"
#include "s/s_StateInterfaces.hpp"
// Note: Ported from https://github.com/NSMBW-Community/NSMBW-Decomp/tree/master/include/dol/sLib
// See include/s/README.txt for changes made
/**
* @brief An implementation of sStateMgrIf_c.
*
* @tparam T The parent class for this state manager.
* @tparam Method The state method handler to use.
* @tparam Factory The state factory to use.
* @tparam Check The state ID checker to use.
* @ingroup state
*/
template <class T, class Method, template <class> class Factory, class Check>
class sStateMgr_c : public sStateMgrIf_c {
public:
sStateMgr_c(T &owner)
: mFactory(owner), mMethod(mCheck, mFactory, sStateID::null) {}
sStateMgr_c(T &owner, const sStateIDIf_c &initialState)
: mFactory(owner), mMethod(mCheck, mFactory, initialState) {}
virtual void initializeState() {
mMethod.initializeStateMethod();
}
virtual void executeState() {
mMethod.executeStateMethod();
}
virtual void finalizeState() {
mMethod.finalizeStateMethod();
}
virtual void changeState(const sStateIDIf_c &newState) {
mMethod.changeStateMethod(newState);
}
virtual void refreshState() {
mMethod.refreshStateMethod();
}
virtual sStateIf_c *getState() const {
return mMethod.getState();
}
virtual const sStateIDIf_c *getNewStateID() const {
return mMethod.getNewStateID();
}
virtual const sStateIDIf_c *getStateID() const {
return mMethod.getStateID();
}
virtual const sStateIDIf_c *getOldStateID() const {
return mMethod.getOldStateID();
}
// SS addition
bool isState(const sStateIDIf_c &other) const {
return *getStateID() == other;
}
private:
Check mCheck;
Factory<T> mFactory;
Method mMethod;
};
#endif
|