Moved the OSG_INIT_SINGLETON_PROXY macro into include/osg/Object to make it more generally useful and added it's usage into the RenderBinPrototypeList initialization.

This commit is contained in:
Robert Osfield 2012-09-05 13:48:23 +00:00
parent 3c9a0cdfd7
commit f5a3c40934
3 changed files with 7 additions and 1 deletions

View File

@ -42,6 +42,9 @@ class UserDataContainer;
virtual const char* libraryName() const { return #library; }\
virtual const char* className() const { return #name; }
/** Helper macro that creates a static proxy object to call singleton function on it's construction, ensuring that the singleton gets initialized at startup.*/
#define OSG_INIT_SINGLETON_PROXY(ProxyName, Func) static struct ProxyName{ ProxyName() { Func; } } s_##ProxyName;
/** Base class/standard interface for objects which require IO support,
cloning and reference counting.
Based on GOF Composite, Prototype and Template Method patterns.

View File

@ -54,6 +54,10 @@ static RenderBinPrototypeList* renderBinPrototypeList()
return s_renderBinPrototypeList.get();
}
// Use a proxy to force the initialization of the the SceneSingleton during static initialization
OSG_INIT_SINGLETON_PROXY(RenderBinSingletonProxy, renderBinPrototypeList())
RenderBin* RenderBin::getRenderBinPrototype(const std::string& binName)
{
RenderBinPrototypeList* list = renderBinPrototypeList();

View File

@ -16,7 +16,6 @@
using namespace osgViewer;
#define OSG_INIT_SINGLETON_PROXY(ProxyName, Func) static struct ProxyName{ ProxyName() { Func; } } s_##ProxyName;
namespace osgViewer
{