Skip to content

Commit

Permalink
OpenColorIOContext : Don't duplicate OptionalValuePlug API
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Sep 20, 2023
1 parent b04ec0b commit 49565af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 70 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
=======
Expand Down
23 changes: 5 additions & 18 deletions include/GafferImage/OpenColorIOContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include "Gaffer/CompoundDataPlug.h"
#include "Gaffer/ContextProcessor.h"
#include "Gaffer/OptionalValuePlug.h"
#include "Gaffer/TypedObjectPlug.h"

namespace GafferImage
Expand All @@ -56,25 +57,11 @@ class GAFFERIMAGE_API OpenColorIOContext : public Gaffer::ContextProcessor
explicit OpenColorIOContext( const std::string &name=GraphComponent::defaultName<OpenColorIOContext>() );
~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;
Expand Down
64 changes: 12 additions & 52 deletions src/GafferImage/OpenColorIOContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,64 +67,24 @@ OpenColorIOContext::~OpenColorIOContext()
{
}

Gaffer::ValuePlug *OpenColorIOContext::configPlug()
Gaffer::OptionalValuePlug *OpenColorIOContext::configPlug()
{
return getChild<ValuePlug>( g_firstPlugIndex );
return getChild<OptionalValuePlug>( g_firstPlugIndex );
}

const Gaffer::ValuePlug *OpenColorIOContext::configPlug() const
const Gaffer::OptionalValuePlug *OpenColorIOContext::configPlug() const
{
return getChild<ValuePlug>( g_firstPlugIndex );
return getChild<OptionalValuePlug>( g_firstPlugIndex );
}

Gaffer::BoolPlug *OpenColorIOContext::configEnabledPlug()
Gaffer::OptionalValuePlug *OpenColorIOContext::workingSpacePlug()
{
return configPlug()->getChild<BoolPlug>( 0 );
return getChild<OptionalValuePlug>( g_firstPlugIndex + 1 );
}

const Gaffer::BoolPlug *OpenColorIOContext::configEnabledPlug() const
const Gaffer::OptionalValuePlug *OpenColorIOContext::workingSpacePlug() const
{
return configPlug()->getChild<BoolPlug>( 0 );
}

Gaffer::StringPlug *OpenColorIOContext::configValuePlug()
{
return configPlug()->getChild<StringPlug>( 1 );
}

const Gaffer::StringPlug *OpenColorIOContext::configValuePlug() const
{
return configPlug()->getChild<StringPlug>( 1 );
}

Gaffer::ValuePlug *OpenColorIOContext::workingSpacePlug()
{
return getChild<ValuePlug>( g_firstPlugIndex + 1 );
}

const Gaffer::ValuePlug *OpenColorIOContext::workingSpacePlug() const
{
return getChild<ValuePlug>( g_firstPlugIndex + 1 );
}

Gaffer::BoolPlug *OpenColorIOContext::workingSpaceEnabledPlug()
{
return workingSpacePlug()->getChild<BoolPlug>( 0 );
}

const Gaffer::BoolPlug *OpenColorIOContext::workingSpaceEnabledPlug() const
{
return workingSpacePlug()->getChild<BoolPlug>( 0 );
}

Gaffer::StringPlug *OpenColorIOContext::workingSpaceValuePlug()
{
return workingSpacePlug()->getChild<StringPlug>( 1 );
}

const Gaffer::StringPlug *OpenColorIOContext::workingSpaceValuePlug() const
{
return workingSpacePlug()->getChild<StringPlug>( 1 );
return getChild<OptionalValuePlug>( g_firstPlugIndex + 1 );
}

Gaffer::ValuePlug *OpenColorIOContext::variablesPlug()
Expand Down Expand Up @@ -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<StringPlug>()->getValue() );
}

if( workingSpaceEnabledPlug()->getValue() )
if( workingSpacePlug()->enabledPlug()->getValue() )
{
result["ocio:workingSpace"] = new StringData( workingSpaceValuePlug()->getValue() );
result["ocio:workingSpace"] = new StringData( workingSpacePlug()->valuePlug<StringPlug>()->getValue() );
}

ConstCompoundDataPtr extraVariables = extraVariablesPlug()->getValue();
Expand Down

0 comments on commit 49565af

Please sign in to comment.