mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-02 03:48:19 +08:00
46 lines
680 B
C++
46 lines
680 B
C++
/*
|
|
* GlobalInitializer.h
|
|
*
|
|
* Copyright (c) 2019 hikyuu.org
|
|
*
|
|
* Created on: 2019-11-01
|
|
* Author: fasiondog
|
|
*/
|
|
|
|
#pragma once
|
|
#ifndef HKU_GLOBAL_INITIALIZER_H
|
|
#define HKU_GLOBAL_INITIALIZER_H
|
|
|
|
#ifndef HKU_API
|
|
#define HKU_API
|
|
#endif
|
|
|
|
namespace hku {
|
|
|
|
class HKU_API GlobalInitializer {
|
|
public:
|
|
GlobalInitializer() {
|
|
if (m_count++ == 0) {
|
|
init();
|
|
}
|
|
}
|
|
|
|
~GlobalInitializer() {
|
|
if (--m_count == 0) {
|
|
clean();
|
|
}
|
|
}
|
|
|
|
private:
|
|
void init();
|
|
void clean();
|
|
|
|
private:
|
|
static int m_count;
|
|
};
|
|
|
|
static GlobalInitializer s_global_initializer;
|
|
|
|
} /* namespace hku */
|
|
|
|
#endif /* HKU_GLOBAL_INITIALIZER_H */ |