Files
ss/include/s/s_FStateFct.hpp
T
2024-06-01 23:57:46 +02:00

34 lines
828 B
C++

#ifndef S_FSTATEFCT_H
#define S_FSTATEFCT_H
#include <s/s_StateInterfaces.hpp>
#include <s/s_FState.hpp>
#include <s/s_StateID.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 A state factory for a given class.
/// @tparam T The class that this state belongs to.
/// @ingroup state
template <class T>
class sFStateFct_c : public sStateFctIf_c {
public:
sFStateFct_c(T &owner) : mState(owner) {}
virtual sStateIf_c* build(const sStateIDIf_c &id) {
if (!id.isNull()) {
mState.setID((const sFStateID_c<T> *) &id);
return &mState;
}
return nullptr;
}
virtual void dispose(sStateIf_c *&id) { id = nullptr; }
private:
sFState_c<T> mState;
};
#endif