diff --git a/include/vsg/core/Object.h b/include/vsg/core/Object.h index 43a4302559..fce17f532b 100644 --- a/include/vsg/core/Object.h +++ b/include/vsg/core/Object.h @@ -259,4 +259,20 @@ namespace vsg return dest; } + template + ref_ptr clone(vsg::ref_ptr object) + { + if (!object) return {}; + auto new_object = object->clone(); + return new_object.template cast(); + } + + template + ref_ptr clone(vsg::ref_ptr object) + { + if (!object) return {}; + auto new_object = object->clone(); + return new_object.template cast(); + } + } // namespace vsg diff --git a/include/vsg/io/Options.h b/include/vsg/io/Options.h index ffca00a2ad..be5d94b6c3 100644 --- a/include/vsg/io/Options.h +++ b/include/vsg/io/Options.h @@ -37,7 +37,7 @@ namespace vsg { public: Options(); - explicit Options(const Options& options); + Options(const Options& rhs, const CopyOp& copyop = {}); template explicit Options(Args... args) @@ -47,14 +47,10 @@ namespace vsg Options& operator=(const Options& rhs) = delete; - int compare(const Object& rhs) const override; /// read command line options, assign values to this options object to later use with reading/writing files virtual bool readOptions(CommandLine& arguments); - void read(Input& input) override; - void write(Output& output) const override; - void add(ref_ptr rw = {}); void add(const ReaderWriters& rws); @@ -108,6 +104,14 @@ namespace vsg /// mechanism for propogating dynamic objects classification up parental chain so that cloning is done on all dynamic objects to avoid sharing of dyanmic parts. ref_ptr propagateDynamicObjects; + public: + + ref_ptr clone(const CopyOp& copyop = {}) const override { return Options::create(*this, copyop); } + int compare(const Object& rhs) const override; + + void read(Input& input) override; + void write(Output& output) const override; + protected: virtual ~Options(); }; diff --git a/include/vsg/io/stream.h b/include/vsg/io/stream.h index c306e71e06..59a516445b 100644 --- a/include/vsg/io/stream.h +++ b/include/vsg/io/stream.h @@ -25,6 +25,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include #include #include @@ -284,4 +285,27 @@ namespace vsg return output; } + + inline std::istream& operator>>(std::istream& input, CoordinateSpace& coordinateSpace) + { + std::string value; + input >> value; + + if (value == "LINEAR") coordinateSpace = CoordinateSpace::LINEAR; + else if (value == "sRGB") coordinateSpace = CoordinateSpace::sRGB; + else coordinateSpace = CoordinateSpace::NO_PREFERENCE; + + return input; + } + + inline std::ostream& operator<<(std::ostream& output, const CoordinateSpace& coordinateSpace) + { + if (coordinateSpace==CoordinateSpace::LINEAR) output<<"LINEAR"; + else if (coordinateSpace==CoordinateSpace::sRGB) output<<"sRGB"; + else output<<"NO_PREFERENCE"; + + return output; + } + + } // namespace vsg diff --git a/include/vsg/utils/CoordinateSpace.h b/include/vsg/utils/CoordinateSpace.h index 956ffedc84..0eae64d622 100644 --- a/include/vsg/utils/CoordinateSpace.h +++ b/include/vsg/utils/CoordinateSpace.h @@ -12,8 +12,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ -#include -#include #include namespace vsg @@ -25,6 +23,7 @@ namespace vsg LINEAR = (1 << 0), sRGB = (1 << 1) }; + VSG_type_name(vsg::CoordinateSpace); template constexpr T linear_to_sRGB_component(T c) diff --git a/src/vsg/io/Options.cpp b/src/vsg/io/Options.cpp index 4c2bc654b2..9ee9a858e0 100644 --- a/src/vsg/io/Options.cpp +++ b/src/vsg/io/Options.cpp @@ -36,8 +36,8 @@ Options::Options() propagateDynamicObjects = PropagateDynamicObjects::create(); } -Options::Options(const Options& options) : - Inherit(), +Options::Options(const Options& options, const CopyOp& copyop) : + Inherit(options, copyop), sharedObjects(options.sharedObjects), readerWriters(options.readerWriters), operationThreads(options.operationThreads), diff --git a/src/vsg/nodes/TileDatabase.cpp b/src/vsg/nodes/TileDatabase.cpp index 1fe7f31024..68f51ab53e 100644 --- a/src/vsg/nodes/TileDatabase.cpp +++ b/src/vsg/nodes/TileDatabase.cpp @@ -187,7 +187,7 @@ bool TileDatabase::readDatabase(vsg::ref_ptr options) auto tileReader = tile::create(settings, options); - auto local_options = options ? vsg::Options::create(*options) : vsg::Options::create(); + auto local_options = options ? vsg::clone(options) : vsg::Options::create(); local_options->readerWriters.insert(local_options->readerWriters.begin(), tileReader); auto result = vsg::read("root.tile", local_options); @@ -255,7 +255,7 @@ ref_ptr vsg::createBingMapsSettings(const std::string& ima vsg::info("metadata_url = ", metadata_url); - auto txt_options = vsg::Options::create(*options); + auto txt_options = vsg::clone(options); txt_options->extensionHint = ".txt"; if (auto metadata = vsg::read_cast(metadata_url, txt_options))