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:
parent
c74e212494
commit
8c78588ee1
@ -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)
|
||||
|
@ -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}")
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -4,6 +4,7 @@ set(HEADERS
|
||||
CopyOp.hxx
|
||||
NodeAndDrawableVisitor.hxx
|
||||
OsgMath.hxx
|
||||
OsgSingleton.hxx
|
||||
PrimitiveUtils.hxx
|
||||
QuadTreeBuilder.hxx
|
||||
RenderConstants.hxx
|
||||
|
41
simgear/scene/util/OsgSingleton.hxx
Normal file
41
simgear/scene/util/OsgSingleton.hxx
Normal 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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user