File: instance.h

package info (click to toggle)
xgalaga%2B%2B 0.9-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 376 kB
  • sloc: cpp: 2,785; makefile: 242
file content (25 lines) | stat: -rw-r--r-- 597 bytes parent folder | download | duplicates (5)
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