Evdev joystick plugin
[lsnes.git] / generic / globalwrap.hpp
blobc1c0b7602b0900860006bac0db6cf6c0fcad5cdd
1 #ifndef _globalwrap__hpp__included__
2 #define _globalwrap__hpp__included__
4 /**
5 * Wrapper for glboal/module-local objects accessable in global ctor context.
6 */
7 template<class T>
8 class globalwrap
10 public:
11 /**
12 * Get the wrapped object.
14 * returns: The wrapped object.
15 * throws std::bad_alloc: Not enough memory.
17 T& operator()() throw(std::bad_alloc)
19 if(!storage)
20 storage = new T();
21 return *storage;
23 private:
24 T* storage;
27 #endif