Take two. The ModelRegistry's are already derived from osg::Referenced. So also introduce the osg dependent version in simgear/scene/util.
29 lines
552 B
C++
29 lines
552 B
C++
#ifndef SIMGEAR_SINGLETON_HXX
|
|
#define SIMGEAR_SINGLETON_HXX 1
|
|
|
|
#include "singleton.hpp"
|
|
|
|
namespace simgear
|
|
{
|
|
/**
|
|
* Class that supplies the address of a singleton instance. This class
|
|
* can be inherited by its Class argument in order to support the
|
|
* instance() method in that class.
|
|
*/
|
|
template <typename Class>
|
|
class Singleton
|
|
{
|
|
protected:
|
|
Singleton() {}
|
|
public:
|
|
static Class* instance()
|
|
{
|
|
Class& singleton
|
|
= boost::details::pool::singleton_default<Class>::instance();
|
|
return &singleton;
|
|
}
|
|
};
|
|
|
|
}
|
|
#endif
|