From 1473eabc7c1db324bc95b50be676881643421d78 Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Sun, 4 Mar 2012 07:16:59 +0100 Subject: [PATCH] Provide SGReaderWriterOptions::copyOrCreate(const osgDB::Options*). This functions tries to preserve the database options as much as possible and guarantees to return a non zero options pointer. --- simgear/scene/util/SGReaderWriterOptions.hxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/simgear/scene/util/SGReaderWriterOptions.hxx b/simgear/scene/util/SGReaderWriterOptions.hxx index 082cfb82..ef7a5864 100644 --- a/simgear/scene/util/SGReaderWriterOptions.hxx +++ b/simgear/scene/util/SGReaderWriterOptions.hxx @@ -21,6 +21,7 @@ #define SGREADERWRITEROPTIONS_HXX 1 #include +#include #include #include @@ -92,6 +93,17 @@ public: void setInstantiateEffects(bool instantiateEffects) { _instantiateEffects = instantiateEffects; } + static SGReaderWriterOptions* copyOrCreate(const osgDB::Options* options) + { + if (!options) + options = osgDB::Registry::instance()->getOptions(); + if (!options) + return new SGReaderWriterOptions; + if (!dynamic_cast(options)) + return new SGReaderWriterOptions(*options); + return new SGReaderWriterOptions(*static_cast(options)); + } + protected: virtual ~SGReaderWriterOptions() {} -- 2.39.5