From 49565af175b1f49b9f199bcb98f22890c99e0ab2 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 20 Sep 2023 16:51:19 +0100 Subject: [PATCH] OpenColorIOContext : Don't duplicate OptionalValuePlug API --- Changes.md | 1 + include/GafferImage/OpenColorIOContext.h | 23 ++------- src/GafferImage/OpenColorIOContext.cpp | 64 +++++------------------- 3 files changed, 18 insertions(+), 70 deletions(-) diff --git a/Changes.md b/Changes.md index 2424d73bab2..3c49e2289ad 100644 --- a/Changes.md +++ b/Changes.md @@ -7,6 +7,7 @@ Breaking Changes - Dispatcher : Removed `createMatching()` method. - Process : Removed non-const variant of the `handleException()` method. - StringPlug : Remove deprecated `precomputedHash` argument from `getValue()` method. +- OpenColorIOContext : Removed `configEnabledPlug()`, `configValuePlug()`, `workingSpaceEnabledPlug()` and `workingSpaceValuePlug()` methods. Use the OptionalValuePlug child accessors instead. 1.3.x.x (relative to 1.3.3.0) ======= diff --git a/include/GafferImage/OpenColorIOContext.h b/include/GafferImage/OpenColorIOContext.h index 7788982664a..185511e2733 100644 --- a/include/GafferImage/OpenColorIOContext.h +++ b/include/GafferImage/OpenColorIOContext.h @@ -41,6 +41,7 @@ #include "Gaffer/CompoundDataPlug.h" #include "Gaffer/ContextProcessor.h" +#include "Gaffer/OptionalValuePlug.h" #include "Gaffer/TypedObjectPlug.h" namespace GafferImage @@ -56,25 +57,11 @@ class GAFFERIMAGE_API OpenColorIOContext : public Gaffer::ContextProcessor explicit OpenColorIOContext( const std::string &name=GraphComponent::defaultName() ); ~OpenColorIOContext() override; - /// \todo Return OptionalValuePlug, and remove `configEnabledPlug()` and - /// `configValuePlug()` methods. Do the same for `workingSpace` plugs. - Gaffer::ValuePlug *configPlug(); - const Gaffer::ValuePlug *configPlug() const; + Gaffer::OptionalValuePlug *configPlug(); + const Gaffer::OptionalValuePlug *configPlug() const; - Gaffer::BoolPlug *configEnabledPlug(); - const Gaffer::BoolPlug *configEnabledPlug() const; - - Gaffer::StringPlug *configValuePlug(); - const Gaffer::StringPlug *configValuePlug() const; - - Gaffer::ValuePlug *workingSpacePlug(); - const Gaffer::ValuePlug *workingSpacePlug() const; - - Gaffer::BoolPlug *workingSpaceEnabledPlug(); - const Gaffer::BoolPlug *workingSpaceEnabledPlug() const; - - Gaffer::StringPlug *workingSpaceValuePlug(); - const Gaffer::StringPlug *workingSpaceValuePlug() const; + Gaffer::OptionalValuePlug *workingSpacePlug(); + const Gaffer::OptionalValuePlug *workingSpacePlug() const; Gaffer::ValuePlug *variablesPlug(); const Gaffer::ValuePlug *variablesPlug() const; diff --git a/src/GafferImage/OpenColorIOContext.cpp b/src/GafferImage/OpenColorIOContext.cpp index 5f9c2fafc01..31165b40648 100644 --- a/src/GafferImage/OpenColorIOContext.cpp +++ b/src/GafferImage/OpenColorIOContext.cpp @@ -67,64 +67,24 @@ OpenColorIOContext::~OpenColorIOContext() { } -Gaffer::ValuePlug *OpenColorIOContext::configPlug() +Gaffer::OptionalValuePlug *OpenColorIOContext::configPlug() { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } -const Gaffer::ValuePlug *OpenColorIOContext::configPlug() const +const Gaffer::OptionalValuePlug *OpenColorIOContext::configPlug() const { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } -Gaffer::BoolPlug *OpenColorIOContext::configEnabledPlug() +Gaffer::OptionalValuePlug *OpenColorIOContext::workingSpacePlug() { - return configPlug()->getChild( 0 ); + return getChild( g_firstPlugIndex + 1 ); } -const Gaffer::BoolPlug *OpenColorIOContext::configEnabledPlug() const +const Gaffer::OptionalValuePlug *OpenColorIOContext::workingSpacePlug() const { - return configPlug()->getChild( 0 ); -} - -Gaffer::StringPlug *OpenColorIOContext::configValuePlug() -{ - return configPlug()->getChild( 1 ); -} - -const Gaffer::StringPlug *OpenColorIOContext::configValuePlug() const -{ - return configPlug()->getChild( 1 ); -} - -Gaffer::ValuePlug *OpenColorIOContext::workingSpacePlug() -{ - return getChild( g_firstPlugIndex + 1 ); -} - -const Gaffer::ValuePlug *OpenColorIOContext::workingSpacePlug() const -{ - return getChild( g_firstPlugIndex + 1 ); -} - -Gaffer::BoolPlug *OpenColorIOContext::workingSpaceEnabledPlug() -{ - return workingSpacePlug()->getChild( 0 ); -} - -const Gaffer::BoolPlug *OpenColorIOContext::workingSpaceEnabledPlug() const -{ - return workingSpacePlug()->getChild( 0 ); -} - -Gaffer::StringPlug *OpenColorIOContext::workingSpaceValuePlug() -{ - return workingSpacePlug()->getChild( 1 ); -} - -const Gaffer::StringPlug *OpenColorIOContext::workingSpaceValuePlug() const -{ - return workingSpacePlug()->getChild( 1 ); + return getChild( g_firstPlugIndex + 1 ); } Gaffer::ValuePlug *OpenColorIOContext::variablesPlug() @@ -197,14 +157,14 @@ void OpenColorIOContext::compute( ValuePlug *output, const Context *context ) co IECore::CompoundDataPtr resultData = new IECore::CompoundData; IECore::CompoundDataMap &result = resultData->writable(); - if( configEnabledPlug()->getValue() ) + if( configPlug()->enabledPlug()->getValue() ) { - result["ocio:config"] = new StringData( configValuePlug()->getValue() ); + result["ocio:config"] = new StringData( configPlug()->valuePlug()->getValue() ); } - if( workingSpaceEnabledPlug()->getValue() ) + if( workingSpacePlug()->enabledPlug()->getValue() ) { - result["ocio:workingSpace"] = new StringData( workingSpaceValuePlug()->getValue() ); + result["ocio:workingSpace"] = new StringData( workingSpacePlug()->valuePlug()->getValue() ); } ConstCompoundDataPtr extraVariables = extraVariablesPlug()->getValue();