NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
s_StateInterfaces.hpp
1#pragma once
2
3/// @addtogroup state
4/// @{
5
6/// @brief The interface for state IDs.
7/// @details A state ID is made up of a name string and a unique number, where 0 denotes a null state.
8/// Null states do not have any corresponding behaviour. They can be used, for example,
9/// if a state holder needs to be initialized but the initial state ID is not known yet.
11public:
12 virtual ~sStateIDIf_c() {}
13
14 virtual bool isNull() const = 0; ///< Returns whether this is a null state.
15 virtual bool isEqual(const sStateIDIf_c &other) const = 0; ///< Returns whether both states have the same number.
16
17 virtual bool operator==(const sStateIDIf_c &other) const = 0; ///< Overloaded equality operator, using ::isEqual.
18 virtual bool operator!=(const sStateIDIf_c &other) const = 0; ///< Overloaded inequality operator, using ::isEqual.
19
20 virtual bool isSameName(const char *name) const = 0; ///< Returns whether this state ID is called @p name.
21 virtual const char *name() const = 0; ///< Returns the name of this state ID.
22 virtual unsigned int number() const = 0; ///< Returns the number of this state ID.
23};
24
25/// @brief The interface for a state holder.
26/// @details A state holder is linked to a state ID and can execute its corresponding behaviour.
28public:
29 virtual ~sStateIf_c() {}
30 virtual const void initialize() = 0; ///< Initializes the state.
31 virtual const void execute() = 0; ///< Executes the state.
32 virtual const void finalize() = 0; ///< Prepares the state for termination.
33};
34
35/// @brief The interface for state factories.
36/// @details A state factory produces a state holder from a given state ID.
38public:
39 virtual ~sStateFctIf_c() {}
40 virtual sStateIf_c *build(sStateIDIf_c const &id) = 0; ///< Returns a new state with a given state ID.
41 virtual void dispose(sStateIf_c *&id) = 0; ///< Clears out the pointer to a state.
42};
43
44/// @brief The interface for state ID checkers.
45/// @details [This class is not really used, but it seems to be intended for testing if a state is "normal", most likely a debug leftover].
47public:
48 virtual ~sStateIDChkIf_c() {}
49 virtual bool isNormalID(const sStateIDIf_c &id) const = 0; ///< Returns whether a state ID is normal.
50};
51
52/// @brief A default implementation of a state ID checker.
53/// @details ::isNormalID always returns true.
55public:
56 virtual bool isNormalID(const sStateIDIf_c &) const { return true; }
57};
58
59/// @brief The interface for state managers.
60/// @details A state manager handles execution of and transitioning between state IDs.
62public:
63 virtual ~sStateMgrIf_c() {}
64 virtual void initializeState() = 0; ///< Initializes the current state.
65 virtual void executeState() = 0; ///< Executes the current state.
66 virtual void finalizeState() = 0; ///< Prepares the current state for termination.
67 virtual void changeState(const sStateIDIf_c &newStateID) = 0; ///< Transitions to a new state ID.
68 virtual void refreshState() = 0; ///< Marks the current state to be executed again.
69 virtual sStateIf_c *getState() const = 0; ///< Gets the state holder.
70 virtual const sStateIDIf_c *getNewStateID() const = 0; ///< Gets the next state ID.
71 virtual const sStateIDIf_c *getStateID() const = 0; ///< Gets the current state ID.
72 virtual const sStateIDIf_c *getOldStateID() const = 0; ///< Gets the previous state ID.
73};
74
75/// @}
The interface for state factories.
virtual void dispose(sStateIf_c *&id)=0
Clears out the pointer to a state.
virtual sStateIf_c * build(sStateIDIf_c const &id)=0
Returns a new state with a given state ID.
The interface for state ID checkers.
virtual bool isNormalID(const sStateIDIf_c &id) const =0
Returns whether a state ID is normal.
A default implementation of a state ID checker.
virtual bool isNormalID(const sStateIDIf_c &) const
Returns whether a state ID is normal.
The interface for state IDs.
virtual bool isEqual(const sStateIDIf_c &other) const =0
Returns whether both states have the same number.
virtual bool isSameName(const char *name) const =0
Returns whether this state ID is called name.
virtual const char * name() const =0
Returns the name of this state ID.
virtual unsigned int number() const =0
Returns the number of this state ID.
virtual bool isNull() const =0
Returns whether this is a null state.
virtual bool operator==(const sStateIDIf_c &other) const =0
Overloaded equality operator, using isEqual.
virtual bool operator!=(const sStateIDIf_c &other) const =0
Overloaded inequality operator, using isEqual.
The interface for a state holder.
virtual const void execute()=0
Executes the state.
virtual const void initialize()=0
Initializes the state.
virtual const void finalize()=0
Prepares the state for termination.
The interface for state managers.
virtual const sStateIDIf_c * getStateID() const =0
Gets the current state ID.
virtual void executeState()=0
Executes the current state.
virtual sStateIf_c * getState() const =0
Gets the state holder.
virtual const sStateIDIf_c * getOldStateID() const =0
Gets the previous state ID.
virtual const sStateIDIf_c * getNewStateID() const =0
Gets the next state ID.
virtual void initializeState()=0
Initializes the current state.
virtual void refreshState()=0
Marks the current state to be executed again.
virtual void finalizeState()=0
Prepares the current state for termination.
virtual void changeState(const sStateIDIf_c &newStateID)=0
Transitions to a new state ID.