NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
s_FStateID.hpp
1#pragma once
2#include <dol/sLib/s_StateID.hpp>
3#include <lib/MSL_C/string.h>
4
9template<class T>
10class sFStateID_c : public sStateID_c {
11public:
12 typedef void (T::*stateFunc)();
13
22 sFStateID_c(const char *name, stateFunc initialize, stateFunc execute, stateFunc finalize) :
24 mpInitialize(initialize),
25 mpExecute(execute),
26 mpFinalize(finalize) {}
27
29 virtual bool isSameName(const char *otherName) const {
30 char *part = strrchr(otherName, ':');
31 if (part != nullptr) {
32 otherName = part + 1;
33 }
34 const char *thisName = strrchr(name(), ':') + 1;
35 if (strcmp(thisName, otherName) == 0) {
36 return true;
37 } else {
38 return false;
39 }
40 }
41
44 virtual void initializeState(T &owner) const { (owner.*mpInitialize)(); }
45
48 virtual void executeState(T &owner) const { (owner.*mpExecute)(); }
49
52 virtual void finalizeState(T &owner) const { (owner.*mpFinalize)(); }
53
54private:
55 stateFunc mpInitialize;
56 stateFunc mpExecute;
57 stateFunc mpFinalize;
58};
An implementation of a state ID for a given class.
stateFunc mpFinalize
The finalize method for this state ID.
virtual void finalizeState(T &owner) const
Calls the finalize method on the owner.
stateFunc mpInitialize
The initialize method for this state ID.
virtual void executeState(T &owner) const
Calls the execute method on the owner.
virtual void initializeState(T &owner) const
Calls the initialize method on the owner.
stateFunc mpExecute
The execute method for this state ID.
virtual bool isSameName(const char *otherName) const
Returns true if the given name matches this state ID's name.
sFStateID_c(const char *name, stateFunc initialize, stateFunc execute, stateFunc finalize)
Constructs a new sFStateID_c instance.
A generic implementation of a state ID.
Definition s_StateID.hpp:7
virtual const char * name() const
Returns the name of this state ID.
Definition s_StateID.cpp:35