MStatus TransformationMatrixParameterHandler<T>::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const
{
	typename IECore::TypedParameter<IECore::TransformationMatrix<T> >::ConstPtr p = IECore::runTimeCast<const IECore::TypedParameter<IECore::TransformationMatrix<T> > >( parameter );
	if( !p )
	{
		return MS::kFailure;
	}

	MObject attribute = plug.attribute();
	MFnCompoundAttribute fnCAttr( attribute );
	if( !fnCAttr.hasObj( attribute ) )
	{
		return MS::kFailure;
	}

	if( plug.numChildren() != 8 )
	{
		return MS::kFailure;
	}

	MStatus stat;
	MPlug tmpPlug;

	for( unsigned int i=0; i<8; i++ )
	{
		tmpPlug = plug.child( i, &stat );

		// Verify the naming of the child plugs.

		const MString name = tmpPlug.partialName();
		const unsigned int len = name.length() - 1;
		const unsigned int nlen = g_attributeNames[i].length() - 1;
		const MString nameEnd = name.substringW( len - nlen, len );

		if( !stat || nameEnd != g_attributeNames[i] )
		{
			return MS::kFailure;
		}

		MObject attr = tmpPlug.attribute();
		fnCAttr.setObject( attr );
		if( !fnCAttr.hasObj( attr ) )
		{
			return MS::kFailure;
		}
	}

	IECore::TransformationMatrix<T> tMatrix = p->typedDefaultValue();

	if( !setUnitVecDefaultValues( plug.child( TRANSLATE_INDEX ), tMatrix.translate ) )
		return MS::kFailure;

	if( !setUnitVecDefaultValues( plug.child( ROTATE_INDEX ), tMatrix.rotate ) )
		return MS::kFailure;

	if( !setVecDefaultValues( plug.child( SCALE_INDEX ), tMatrix.scale ) )
		return MS::kFailure;

	if( !setVecDefaultValues( plug.child( SHEAR_INDEX ), tMatrix.shear ) )
		return MS::kFailure;

	if( !setVecDefaultValues( plug.child( SCALEPIVOT_INDEX ), tMatrix.scalePivot ) )
		return MS::kFailure;

	if( !setVecDefaultValues( plug.child( SCALEPIVOTTRANS_INDEX ), tMatrix.scalePivotTranslation ) )
		 return MS::kFailure;

	if( !setVecDefaultValues( plug.child( ROTATEPIVOT_INDEX ), tMatrix.rotatePivot ) )
		return MS::kFailure;

	if( !setVecDefaultValues( plug.child( ROTATEPIVOTTRANS_INDEX ), tMatrix.rotatePivotTranslation ) )
		return MS::kFailure;

	return finishUpdating( parameter, plug );
}