1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#ifndef INSTANCE_H
#define INSTANCE_H
#include <stack>
// This singleton registers functions and calls them in reverse order of
// registration when it is destroyed. it is used to destroy other singletons.
class InstancesManager {
static InstancesManager * singleton_;
std::stack<void(*)()> destroy_funcs_;
InstancesManager() {}
~InstancesManager();
InstancesManager(const InstancesManager&); // no copy
InstancesManager & operator=(const InstancesManager&); // no copy
public:
static InstancesManager & Instance();
static void DestroyInstance();
void Push(void(*pf)());
};
#endif
|