Untangle osg singleton dependencies.

Take two. The ModelRegistry's are already derived from osg::Referenced.
So also introduce the osg dependent version in simgear/scene/util.
This commit is contained in:
Mathias Froehlich 2012-03-03 18:57:48 +01:00
parent c74e212494
commit 8c78588ee1
9 changed files with 45 additions and 43 deletions

View File

@ -115,7 +115,6 @@ find_package(Threads REQUIRED)
if(SIMGEAR_HEADLESS)
message(STATUS "headless mode")
set(NO_OPENSCENEGRAPH_INTERFACE 1)
else()
find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED)

View File

@ -46,7 +46,6 @@ if(SIMGEAR_SHARED)
get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS)
add_library(SimGearCore SHARED ${coreSources})
set_property(TARGET SimGearCore PROPERTY COMPILE_FLAGS "-DNO_OPENSCENEGRAPH_INTERFACE=1")
# set_property(TARGET SimGearCore PROPERTY FRAMEWORK 1)
# message(STATUS "public header: ${publicHeaders}")

View File

@ -27,7 +27,7 @@
#include <osgDB/Registry>
#include <simgear/compiler.h>
#include <simgear/structure/Singleton.hxx>
#include <simgear/scene/util/OsgSingleton.hxx>
#include <string>
#include <map>

View File

@ -24,7 +24,7 @@
#include <osg/StateSet>
#include <simgear/structure/Singleton.hxx>
#include <simgear/scene/util/OsgSingleton.hxx>
#include <simgear/scene/util/SGUpdateVisitor.hxx>
namespace simgear

View File

@ -4,6 +4,7 @@ set(HEADERS
CopyOp.hxx
NodeAndDrawableVisitor.hxx
OsgMath.hxx
OsgSingleton.hxx
PrimitiveUtils.hxx
QuadTreeBuilder.hxx
RenderConstants.hxx

View File

@ -0,0 +1,41 @@
#ifndef SIMGEAR_OSGSINGLETON_HXX
#define SIMGEAR_OSGSINGLETON_HXX 1
#include <simgear/structure/Singleton.hxx>
#include <osg/Referenced>
#include <osg/ref_ptr>
namespace simgear {
template <typename RefClass>
class SingletonRefPtr
{
public:
SingletonRefPtr()
{
ptr = new RefClass;
}
static RefClass* instance()
{
SingletonRefPtr& singleton
= boost::details::pool::singleton_default<SingletonRefPtr>::instance();
return singleton.ptr.get();
}
private:
osg::ref_ptr<RefClass> ptr;
};
template <typename RefClass>
class ReferencedSingleton : public virtual osg::Referenced
{
public:
static RefClass* instance()
{
return SingletonRefPtr<RefClass>::instance();
}
};
}
#endif

View File

@ -37,7 +37,7 @@ class Texture2D;
class TexEnv;
}
#include <simgear/structure/Singleton.hxx>
#include <simgear/scene/util/OsgSingleton.hxx>
// Return read-only instances of common OSG state attributes.
namespace simgear

View File

@ -17,6 +17,3 @@
#cmakedefine HAVE_LIBSVN_CLIENT_1
#cmakedefine GCC_ATOMIC_BUILTINS_FOUND
// set if building headless (no OSG or OpenGL libs)
#cmakedefine NO_OPENSCENEGRAPH_INTERFACE

View File

@ -3,11 +3,6 @@
#include "singleton.hpp"
#ifndef NO_OPENSCENEGRAPH_INTERFACE
#include <osg/Referenced>
#include <osg/ref_ptr>
#endif
namespace simgear
{
/**
@ -29,35 +24,5 @@ public:
}
};
#ifndef NO_OPENSCENEGRAPH_INTERFACE
template <typename RefClass>
class SingletonRefPtr
{
public:
SingletonRefPtr()
{
ptr = new RefClass;
}
static RefClass* instance()
{
SingletonRefPtr& singleton
= boost::details::pool::singleton_default<SingletonRefPtr>::instance();
return singleton.ptr.get();
}
private:
osg::ref_ptr<RefClass> ptr;
};
template <typename RefClass>
class ReferencedSingleton : public virtual osg::Referenced
{
public:
static RefClass* instance()
{
return SingletonRefPtr<RefClass>::instance();
}
};
#endif // of NO_OPENSCENEGRAPH_INTERFACE
}
#endif