hikyuu2/hikyuu_cpp/hikyuu/GlobalInitializer.h
2020-03-13 02:01:22 +08:00

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 */