728x90
반응형
define.h
#define NO_COPY(CLASSNAME) \
private: \
CLASSNAME(const CLASSNAME&); \
CLASSNAME& operator = (const CLASSNAME&); \
#define DECLARE_SINGLETON(CLASSNAME) \
NO_COPY(CLASSNAME) \
private: \
static CLASSNAME* pInstance; \
public: \
static CLASSNAME* GetInstance(void); \
static void DestroyInstance(void); \
#define IMPLEMENT_SINGLETON(CLASSNAME) \
CLASSNAME* CLASSNAME::pInstance = NULL; \
CLASSNAME* CLASSNAME::GetInstance(void){ \
if(pInstance == NULL) \
pInstance = new CLASSNAME; \
return pInstance; \
} \
void CLASSNAME::DestroyInstance(void){ \
if(pInstance != NULL) { \
delete pInstance; \
pInstance = NULL; \
} \
}
#define ERR_MSG(Message) MessageBox(g_hWnd, Message, L"System Error", NULL)
h 파일에 DECLARE_SINGLETON(구조체명)
cpp 파일에 IMPLEMENT_SINGLETON(구조체명)
728x90
반응형
'back-end > C & API' 카테고리의 다른 글
디자인패턴의 정의와 역사, 종류 / 상태 패턴 정의 (0) | 2023.07.20 |
---|---|
디자인 패턴의 종류 (0) | 2023.07.20 |
직선의방정식 (0) | 2023.07.20 |
API 삼각 함수 (0) | 2023.07.20 |
동치 연산자 (0) | 2023.06.22 |