Loading...
Searching...
No Matches
UsdValidationFixer Class Reference

A UsdValidationFixer represents a fix that can be applied to fix a specific validation error. More...

#include <fixer.h>

Public Member Functions

 UsdValidationFixer (const UsdValidationFixer &)=default
 
UsdValidationFixeroperator= (const UsdValidationFixer &)=default
 
 UsdValidationFixer (UsdValidationFixer &&) noexcept=default
 
UsdValidationFixeroperator= (UsdValidationFixer &&) noexcept=default
 
USDVALIDATION_API UsdValidationFixer (const TfToken &name, const std::string &description, const FixerImplFn &fixerImplFn, const FixerCanApplyFn &canApplyFn, const TfTokenVector &keywords=TfTokenVector(), const TfToken &errorName=TfToken())
 Construct a UsdValidationFixer with the given name and description.
 
const TfTokenGetName () const &
 Returns the name of this fixer.
 
TfToken GetName () &&
 Return the name of this fixer by-value.
 
const std::string & GetDescription () const &
 Returns the description of this fixer.
 
std::string GetDescription () &&
 Return the description of this fixer by-value.
 
const TfTokenGetErrorName () const &
 Returns the error name that this fixer can fix, if any.
 
TfToken GetErrorName () &&
 Returns the error name that this fixer can fix, if any, by-value.
 
USDVALIDATION_API bool IsAssociatedWithErrorName (const TfToken &errorName) const
 Returns true if this fixer is associated with the given error name.
 
const TfTokenVectorGetKeywords () const &
 Returns the keywords associated with this fixer.
 
TfTokenVector GetKeywords () &&
 Return the keywords associated with this fixer by-value.
 
USDVALIDATION_API bool HasKeyword (const TfToken &keyword) const
 Returns true if this fixer has the given keyword.
 
USDVALIDATION_API bool CanApplyFix (const UsdValidationError &error, const UsdEditTarget &editTarget, const UsdTimeCode &timeCode=UsdTimeCode::Default()) const
 Returns true if this fixer can be applied to the given error and edit target; false otherwise.
 
USDVALIDATION_API bool ApplyFix (const UsdValidationError &error, const UsdEditTarget &editTarget, const UsdTimeCode &timeCode=UsdTimeCode::Default()) const
 Applies the fix for the given error at the given time code and edit target.
 

Detailed Description

A UsdValidationFixer represents a fix that can be applied to fix a specific validation error.

A fixer is associated with a specific validator, and can be associated with a specific error name, or can be generic to any error associated with the corresponding validator.

A fixer has a name, description, and a set of keywords associated with it. The name must be unique among all fixers associated with a specific validator. The keywords can be used to group fixers by department, show, etc.

A fixer has two functions associated with it:

  • The FixerImplFn is the function that will be called to apply the fix for a given error.
  • The FixerCanApplyFn is the function that will be called to determine if the fixer can be applied to a given error.

Note that the Validation framework will not apply any fixers automatically. It's the responsibility of the client to pick and apply a fix for a given error, by specifically calling the ApplyFix() method on an appropriate UsdEditTarget.

Appropriate fixers can be retrieved from UsdValidationValidator or UsdValidationError itself via the GetFixers(), GetFixersWithKeyword(), GetFixerByName(), GetFixersByErrorName(), etc.

Definition at line 62 of file fixer.h.

Constructor & Destructor Documentation

◆ UsdValidationFixer()

USDVALIDATION_API UsdValidationFixer ( const TfToken name,
const std::string &  description,
const FixerImplFn &  fixerImplFn,
const FixerCanApplyFn &  canApplyFn,
const TfTokenVector keywords = TfTokenVector(),
const TfToken errorName = TfToken() 
)

Construct a UsdValidationFixer with the given name and description.

The fixerImplFn is the function that will be called to apply the fix for a given error. The canApplyFn is the function that will be called to determine if the fixer can be applied to a given error. The errorName, if provided, is the error name that this fixer can fix. If not provided, the fixer can be applied to any error associated with the corresponding validator. The keywords are the keywords associated with this fixer. Clients when instantiating a fixer for a validator, can provide keywords such as studio, department, or show. Clients can later see which keywords are associated with the fixer or use the GetFixersByKeywords method to return fixers by the keywords they are associated with.

Member Function Documentation

◆ ApplyFix()

USDVALIDATION_API bool ApplyFix ( const UsdValidationError error,
const UsdEditTarget editTarget,
const UsdTimeCode timeCode = UsdTimeCode::Default() 
) const

Applies the fix for the given error at the given time code and edit target.

Returns true if the fix was applied successfully.

See also
CanApplyFix

◆ CanApplyFix()

USDVALIDATION_API bool CanApplyFix ( const UsdValidationError error,
const UsdEditTarget editTarget,
const UsdTimeCode timeCode = UsdTimeCode::Default() 
) const

Returns true if this fixer can be applied to the given error and edit target; false otherwise.

A fixer can be associated with a specific error name, if so, it can only be applied to errors with the same name, otherwise, it can be applied to any error generated by the corresponding validator.

Additionally, the editTarget can be inspected to determine if the fix can be applied to the given target, etc.

See also
ApplyFix

◆ GetDescription() [1/2]

std::string GetDescription ( ) &&
inline

Return the description of this fixer by-value.

Definition at line 112 of file fixer.h.

◆ GetDescription() [2/2]

const std::string & GetDescription ( ) const &
inline

Returns the description of this fixer.

Definition at line 106 of file fixer.h.

◆ GetErrorName() [1/2]

TfToken GetErrorName ( ) &&
inline

Returns the error name that this fixer can fix, if any, by-value.

Definition at line 124 of file fixer.h.

◆ GetErrorName() [2/2]

const TfToken & GetErrorName ( ) const &
inline

Returns the error name that this fixer can fix, if any.

Definition at line 118 of file fixer.h.

◆ GetKeywords() [1/2]

TfTokenVector GetKeywords ( ) &&
inline

Return the keywords associated with this fixer by-value.

Definition at line 140 of file fixer.h.

◆ GetKeywords() [2/2]

const TfTokenVector & GetKeywords ( ) const &
inline

Returns the keywords associated with this fixer.

Definition at line 134 of file fixer.h.

◆ GetName() [1/2]

TfToken GetName ( ) &&
inline

Return the name of this fixer by-value.

Definition at line 100 of file fixer.h.

◆ GetName() [2/2]

const TfToken & GetName ( ) const &
inline

Returns the name of this fixer.

Definition at line 94 of file fixer.h.

◆ HasKeyword()

USDVALIDATION_API bool HasKeyword ( const TfToken keyword) const

Returns true if this fixer has the given keyword.

◆ IsAssociatedWithErrorName()

USDVALIDATION_API bool IsAssociatedWithErrorName ( const TfToken errorName) const

Returns true if this fixer is associated with the given error name.


The documentation for this class was generated from the following file: