Operation#

Fully qualified name: usd_optimize::Operation

class Operation#

Base Operation Class.

This class provides the base class for implementing Usd Optimize Operations as plugins.

It has minimal requirements. Inside your implementation, you can use the following convenience macro to have your plugin registered:

USD_OPTIMIZE_PLUGIN_INIT(usd_optimize::MyOperationClass);

You must implement getAuthor() to provide a useful contact in the case users have questions or issues with your plugin, and also getVersion() to return the version of your plugin. You then implement executeImpl() to perform your actual business logic.

Optionally you can declare arguments inside your constructor. These will be propagated to the user interface.

Subclassed by usd_optimize::OmniOperation, usd_optimize::PythonOperation

Public Functions

Operation(
const std::string &name,
const std::string &displayName,
const std::string &description,
)#

Standard Constructor.

Parameters:
  • name – The internal name of the operation

  • displayName – The display name of the operation

  • description – A description of what the operation does

Operation(const Operation&) = delete#

Disable copying.

void operator=(const Operation&) = delete#
virtual OperationResult execute(
ExecutionContext *context,
const PXR_NS::JsObject &args,
)#

Public entry point to tell an operation to do its thing.

std::string getName() const#

Get the name of this operation.

std::string getDisplayName() const#

Get the display name of this operation.

virtual std::string getDisplayGroup() const#

An optional UI grouping for the operation.

std::string getDescription() const#

Get the description of this plugin.

virtual std::string getDocumentation() const#

Returns the full documentation for this operation. If this is not overridden by the plugin, it will return the same string as getDescription().

virtual std::string getAuthor() const = 0#

Get the author of this operation.

virtual UsdOptimizePluginVersion getVersion() const = 0#
virtual std::string getCategory() const = 0#
virtual bool getVisible() const#

Returns whether this operation is visible.

This function has no effect internally, it is intended for a user interface to be able to hide an operation. Plugins can override this function to return false if necessary.

Returns:

Whether the operation is visible to the user interface

virtual bool getSupportsAnalysis() const#

Returns whether this operation supports analysis mode.

ExecutionContext *getContext() const#

Get the execution context.

PXR_NS::UsdStageWeakPtr getUsdStage() const#

Get the USD Stage that has been set on this operation.

std::shared_ptr<Report> getReport() const#

Get the Report object.

const Argument *getArgument(const std::string &name) const#

Get a specific argument.

std::vector<const Argument*> getArgs() const#

Get the arguments for this operation.

template<typename T>
inline Argument &addArgument(
const std::string &name,
const std::string &displayName,
const std::string &displayType,
const std::string &description,
T &target,
)#

Add an argument to this operation.

Adds an argument to the operation. A reference to the argument is returned so that any of the less common settings can be configured afterwards.

template<class ...Args>
inline Group &addGroup(
const std::string &name,
Args&&... args,
)#

Create a group of arguments.

Creates a series of arguments that should be grouped together e.g. in a UI. The group itself can have its own conditional expression to save having to specify it per argument.

Example usage:

addGroup("myGroup",
         addArgument(...),
         addArgument(...)
).setVisibleIf(...);

Groups will be returned from Operation::getArgs, and will be ordered prior to their children. You can use Argument::getIsGroup to check if an argument is a group.

virtual void setUserData(void *userData)#

Set custom user data for this operation.

This function can be used to let operations communicate with each other in a basic way. The data is operation specific.

Parameters:

userData – Plugin-specific user data

Public Static Functions

static void log(int32_t level, const char *fmt, ...)#

Entry point for the USD_OPTIMIZE_LOG_X macros. Generally you don’t need to call this function directly.

Parameters:
  • level – The level. See carb::logging::kLevelVerbose etc.

  • fmt – The format string

Protected Functions

virtual OperationResult executeImpl() = 0#

Internal entry point for derived operations to begin their logic.

virtual OperationResult executeAnalysisImpl()#

Internal entry point for derived operations to perform analysis logic.

virtual ~Operation()#

Destructor.

Argument &addArgument(Argument *arg)#

Adds the given Argument to this Operation.

Note

The Operation will take ownership of the Argument after this function has been called

Returns:

A reference to the added Argument

template<class ...Args>
inline Group &addJoin(
const std::string &name,
const std::string &description,
Args&&... args,
)#

Create a group of joined arguments.

Convenience function to use the Join Next functionality to show UI widgets on the same row.

May be used within addGroup also.

void positionArgument(
const Argument *argument,
const Argument *after,
)#

Reposition an argument.

Parameters:
  • argument – The argument to move

  • after – The argument to position it after