From 8c78588ee18ab2e3ca308072c5361d38789d9508 Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Sat, 3 Mar 2012 18:57:48 +0100 Subject: [PATCH] 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. --- CMakeLists.txt | 1 - simgear/CMakeLists.txt | 1 - simgear/scene/model/ModelRegistry.hxx | 2 +- simgear/scene/tgdb/GroundLightManager.hxx | 2 +- simgear/scene/util/CMakeLists.txt | 1 + simgear/scene/util/OsgSingleton.hxx | 41 ++++++++++++++++++++ simgear/scene/util/StateAttributeFactory.hxx | 2 +- simgear/simgear_config_cmake.h.in | 3 -- simgear/structure/Singleton.hxx | 35 ----------------- 9 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 simgear/scene/util/OsgSingleton.hxx diff --git a/CMakeLists.txt b/CMakeLists.txt index f1e985ad..281b366f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/simgear/CMakeLists.txt b/simgear/CMakeLists.txt index 954ed6f0..7612bb8d 100644 --- a/simgear/CMakeLists.txt +++ b/simgear/CMakeLists.txt @@ -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}") diff --git a/simgear/scene/model/ModelRegistry.hxx b/simgear/scene/model/ModelRegistry.hxx index 5e303905..e048f187 100644 --- a/simgear/scene/model/ModelRegistry.hxx +++ b/simgear/scene/model/ModelRegistry.hxx @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include diff --git a/simgear/scene/tgdb/GroundLightManager.hxx b/simgear/scene/tgdb/GroundLightManager.hxx index 92130db0..2da72bc4 100644 --- a/simgear/scene/tgdb/GroundLightManager.hxx +++ b/simgear/scene/tgdb/GroundLightManager.hxx @@ -24,7 +24,7 @@ #include -#include +#include #include namespace simgear diff --git a/simgear/scene/util/CMakeLists.txt b/simgear/scene/util/CMakeLists.txt index 1b833484..8d5e84a2 100644 --- a/simgear/scene/util/CMakeLists.txt +++ b/simgear/scene/util/CMakeLists.txt @@ -4,6 +4,7 @@ set(HEADERS CopyOp.hxx NodeAndDrawableVisitor.hxx OsgMath.hxx + OsgSingleton.hxx PrimitiveUtils.hxx QuadTreeBuilder.hxx RenderConstants.hxx diff --git a/simgear/scene/util/OsgSingleton.hxx b/simgear/scene/util/OsgSingleton.hxx new file mode 100644 index 00000000..c9c40e16 --- /dev/null +++ b/simgear/scene/util/OsgSingleton.hxx @@ -0,0 +1,41 @@ +#ifndef SIMGEAR_OSGSINGLETON_HXX +#define SIMGEAR_OSGSINGLETON_HXX 1 + +#include + +#include +#include + +namespace simgear { + +template +class SingletonRefPtr +{ +public: + SingletonRefPtr() + { + ptr = new RefClass; + } + static RefClass* instance() + { + SingletonRefPtr& singleton + = boost::details::pool::singleton_default::instance(); + return singleton.ptr.get(); + } +private: + osg::ref_ptr ptr; +}; + +template +class ReferencedSingleton : public virtual osg::Referenced +{ +public: + static RefClass* instance() + { + return SingletonRefPtr::instance(); + } +}; + +} + +#endif diff --git a/simgear/scene/util/StateAttributeFactory.hxx b/simgear/scene/util/StateAttributeFactory.hxx index 47603e7b..12b6840b 100644 --- a/simgear/scene/util/StateAttributeFactory.hxx +++ b/simgear/scene/util/StateAttributeFactory.hxx @@ -37,7 +37,7 @@ class Texture2D; class TexEnv; } -#include +#include // Return read-only instances of common OSG state attributes. namespace simgear diff --git a/simgear/simgear_config_cmake.h.in b/simgear/simgear_config_cmake.h.in index a1192283..563f9f73 100644 --- a/simgear/simgear_config_cmake.h.in +++ b/simgear/simgear_config_cmake.h.in @@ -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 diff --git a/simgear/structure/Singleton.hxx b/simgear/structure/Singleton.hxx index 35c712a2..0db235fe 100644 --- a/simgear/structure/Singleton.hxx +++ b/simgear/structure/Singleton.hxx @@ -3,11 +3,6 @@ #include "singleton.hpp" -#ifndef NO_OPENSCENEGRAPH_INTERFACE -#include -#include -#endif - namespace simgear { /** @@ -29,35 +24,5 @@ public: } }; -#ifndef NO_OPENSCENEGRAPH_INTERFACE -template -class SingletonRefPtr -{ -public: - SingletonRefPtr() - { - ptr = new RefClass; - } - static RefClass* instance() - { - SingletonRefPtr& singleton - = boost::details::pool::singleton_default::instance(); - return singleton.ptr.get(); - } -private: - osg::ref_ptr ptr; -}; - -template -class ReferencedSingleton : public virtual osg::Referenced -{ -public: - static RefClass* instance() - { - return SingletonRefPtr::instance(); - } -}; -#endif // of NO_OPENSCENEGRAPH_INTERFACE - } #endif -- 2.39.5