2021-08-28 07:25:03 -07:00
|
|
|
#ifndef JASGADGET_H
|
|
|
|
|
#define JASGADGET_H
|
|
|
|
|
|
|
|
|
|
#include "dolphin/types.h"
|
|
|
|
|
|
2023-02-16 13:09:22 -08:00
|
|
|
template<class T>
|
2021-08-28 07:25:03 -07:00
|
|
|
class JASGlobalInstance {
|
|
|
|
|
public:
|
2023-02-16 13:09:22 -08:00
|
|
|
JASGlobalInstance(T* inst) {
|
|
|
|
|
sInstance = inst;
|
|
|
|
|
}
|
2021-08-28 07:25:03 -07:00
|
|
|
|
2023-06-09 11:55:15 +03:00
|
|
|
JASGlobalInstance(bool param_1) {
|
2023-07-12 10:59:33 +03:00
|
|
|
if (param_1) {
|
|
|
|
|
sInstance = (T*)this;
|
|
|
|
|
}
|
2023-06-09 11:55:15 +03:00
|
|
|
}
|
|
|
|
|
|
2023-02-16 13:09:22 -08:00
|
|
|
~JASGlobalInstance() {
|
2023-06-09 11:55:15 +03:00
|
|
|
if (sInstance == (T*)this) {
|
2023-02-16 13:09:22 -08:00
|
|
|
sInstance = NULL;
|
2022-12-30 16:19:57 -07:00
|
|
|
}
|
|
|
|
|
}
|
2023-02-16 13:09:22 -08:00
|
|
|
|
|
|
|
|
static T* getInstance() { return sInstance; }
|
|
|
|
|
|
2022-12-30 16:19:57 -07:00
|
|
|
static T* sInstance;
|
2021-08-28 07:25:03 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* JASGADGET_H */
|