OpenVDB 13.0.0

Loading...
Searching...
No Matches
OpFactory Class Reference

Helper class to simplify operator registration. More...

`#include <openvdb_houdini/ParmFactory.h>`

Inheritance diagram for OpFactory:

## Public Types
enum | OpFlavor { SOP , POP , ROP , VOP , HDA }
using | CacheAllocFunc = std::function<SOP_NodeCache* (void)>
| Functor that returns newly-allocated node caches for instances of this operator.

## Public Member Functions
template<typename OpPolicyType>
| OpFactory (const OpPolicyType &, const std::string &english, OP_Constructor ctor, ParmList &parms, OP_OperatorTable &table, OpFlavor flavor=SOP)
| Construct a factory that on destruction registers a new operator type.
| OpFactory (const std::string &english, OP_Constructor ctor, ParmList &parms, OP_OperatorTable &table, OpFlavor flavor=SOP)
virtual | ~OpFactory ()
| Register the operator.
| OpFactory (const OpFactory &)=delete
OpFactory & | operator= (const OpFactory &)=delete
OpFlavor | flavor () const
| Return the new operator's flavor (SOP, POP, etc.).
std::string | flavorString () const
| Return the new operator's flavor as a string ("SOP", "POP", etc.).
const std::string & | name () const
| Return the new operator's type name.
const std::string & | english () const
| Return the new operator's UI name.
const std::string & | iconName () const
| Return the new operator's icon name.
const std::string & | helpURL () const
| Return the new operator's help URL.
const std::string & | documentation () const
| Return the new operator's documentation.
const OP_OperatorTable & | table () const
| Return the operator table with which this factory is associated.
OpFactory & | addAlias (const std::string &english)
| Construct a type name for this operator from the given English name and add it as an alias.
OpFactory & | addAliasVerbatim (const std::string &name)
| Add an alias for this operator.
OpFactory & | setDocumentation (const std::string &)
| Add documentation for this operator.
OpFactory & | addInput (const std::string &name)
| Add a required input with the given name.
OpFactory & | addOptionalInput (const std::string &name)
| Add an optional input with the given name.
OpFactory & | setMaxInputs (unsigned=9999)
| Set the maximum number of inputs allowed by this operator.
OpFactory & | setObsoleteParms (const ParmList &)
| Specify obsolete parameters to this operator.
OpFactory & | setLocalVariables (CH_LocalVariable *)
| Add one or more local variables to this operator.
OpFactory & | setFlags (unsigned)
OpFactory & | setInternalName (const std::string &name)
OpFactory & | setOperatorTable (const std::string &name)
OpFactory & | setVerb (SOP_NodeVerb::CookMode cookMode, const CacheAllocFunc &allocator)
| Register this operator as a compilable SOP.
OpFactory & | setInvisible ()
| Mark this node as hidden from the UI tab menu.
OpFactory & | addSpareData (const SpareDataMap &)
| Specify (key, value) pairs of spare data for this operator.

## Static Public Member Functions
static std::string | flavorToString (OpFlavor)
| Return "SOP" for the SOP flavor, "POP" for the POP flavor, etc.

## Protected Member Functions
OP_OperatorTable & | table ()
| Return the operator table with which this factory is associated.

## Detailed Description

Helper class to simplify operator registration.

Example
  void
  newPopOperator(OP_OperatorTable* table)
  {
  houdini_utils::ParmList parms;
  parms.add(houdini_utils::ParmFactory(PRM_STRING, "group", "Group")
  .setHelpText("Specify a subset of the input VDB grids to be processed.")
  .setChoiceList(&houdini_utils::PrimGroupMenu));
  parms.add(...);
  ...
  houdini_utils::OpFactory(MyOpPolicy(), My Node",
  POP_DW_MyNode::factory, parms, *table, houdini_utils::OpFactory::POP)
  .addInput("Input geometry") // input 0 (required)
  .addOptionalInput("Reference geometry"); // input 1 (optional)
  }
  houdini_utils::OpFactory
  Helper class to simplify operator registration.
  Definition ParmFactory.h:376
  houdini_utils::OpFactory::table
  const OP_OperatorTable & table() const
  Return the operator table with which this factory is associated.
  houdini_utils::ParmFactory
  Helper class to simplify construction of PRM_Templates and dynamic user interfaces.
  Definition ParmFactory.h:148
  houdini_utils::ParmList
  Parameter template list that is always terminated.
  Definition ParmFactory.h:74
  houdini_utils::ParmList::add
  ParmList & add(const PRM_Template &)
  Add a parameter to this list.
  houdini_utils::PrimGroupMenu
  OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenu

## Member Typedef Documentation

## ◆ CacheAllocFunc

using CacheAllocFunc = std::function<SOP_NodeCache* (void)>

Functor that returns newly-allocated node caches for instances of this operator.

A node cache encapsulates a SOP's cooking logic for thread safety. Input geometry and parameter values are baked into the cache.

## Member Enumeration Documentation

## ◆ OpFlavor

enum OpFlavor

Enumerator
SOP |
POP |
ROP |
VOP |
HDA |

## Constructor & Destructor Documentation

## ◆ OpFactory() [1/3]

template<typename OpPolicyType>

OpFactory | ( | const OpPolicyType & | ,
|  | const std::string & | english,
|  | OP_Constructor | ctor,
|  | ParmList & | parms,
|  | OP_OperatorTable & | table,
|  | OpFlavor | flavor = SOP )
| inline

Construct a factory that on destruction registers a new operator type.

Parameters

  english | the operator's UI name, as it should appear in menus
  ctor | a factory function that creates operators of this type
  parms | the parameter template list for operators of this type
  table | the registry to which to add this operator type
  flavor | the operator's class (SOP, POP, etc.)

`OpPolicyType` specifies the type of OpPolicy to be used to control the factory's behavior. The (unused) `OpPolicyType` argument is required to enable the compiler to infer the type of the template argument (there is no other way to invoke a templated constructor).

## ◆ OpFactory() [2/3]

OpFactory | ( | const std::string & | english,
|  | OP_Constructor | ctor,
|  | ParmList & | parms,
|  | OP_OperatorTable & | table,
|  | OpFlavor | flavor = SOP )

Note
  Factories initialized with this constructor use the DWAOpPolicy.

## ◆ ~OpFactory()

virtual ~OpFactory | ( |  | ) |
| virtual

Register the operator.

## ◆ OpFactory() [3/3]

OpFactory | ( | const OpFactory & |  | ) |
| delete

## Member Function Documentation

## ◆ addAlias()

OpFactory & addAlias | ( | const std::string & | english | ) |

Construct a type name for this operator from the given English name and add it as an alias.

For backward compatibility when an operator needs to be renamed, add the old name as an alias.

## ◆ addAliasVerbatim()

OpFactory & addAliasVerbatim | ( | const std::string & | name | ) |

Add an alias for this operator.

For backward compatibility when an operator needs to be renamed, add the old name as an alias.

Note
  This variant takes an operator type name rather than an English name.

## ◆ addInput()

OpFactory & addInput | ( | const std::string & | name | ) |

Add a required input with the given name.

## ◆ addOptionalInput()

OpFactory & addOptionalInput | ( | const std::string & | name | ) |

Add an optional input with the given name.

## ◆ addSpareData()

OpFactory & addSpareData | ( | const SpareDataMap & |  | ) |

Specify (key, value) pairs of spare data for this operator.

If a key already exists, its corresponding value will be overwritten with the new value.

See also
  addOperatorSpareData, getOperatorSpareData

## ◆ documentation()

const std::string & documentation | ( |  | ) | const

Return the new operator's documentation.

Note
  If the help URL is nonempty, the URL takes precedence over any help text.

See also
  helpURL(), setDocumentation()

## ◆ english()

const std::string & english | ( |  | ) | const

Return the new operator's UI name.

This accessor is mainly for use by OpPolicy objects.

## ◆ flavor()

OpFlavor flavor | ( |  | ) | const

Return the new operator's flavor (SOP, POP, etc.).

This accessor is mainly for use by OpPolicy objects.

## ◆ flavorString()

std::string flavorString | ( |  | ) | const

Return the new operator's flavor as a string ("SOP", "POP", etc.).

This accessor is mainly for use by OpPolicy objects.

## ◆ flavorToString()

std::string flavorToString | ( | OpFlavor |  | ) |
| static

Return "SOP" for the SOP flavor, "POP" for the POP flavor, etc.

Useful in OpPolicy classes for constructing type and icon names.

## ◆ helpURL()

const std::string & helpURL | ( |  | ) | const

Return the new operator's help URL.

This accessor is mainly for use by OpPolicy objects.

Note
  A help URL takes precedence over help text.

See also
  helpText(), setHelpText()

## ◆ iconName()

const std::string & iconName | ( |  | ) | const

Return the new operator's icon name.

This accessor is mainly for use by OpPolicy objects.

## ◆ name()

const std::string & name | ( |  | ) | const

Return the new operator's type name.

This accessor is mainly for use by OpPolicy objects.

## ◆ operator=()

OpFactory & operator= | ( | const OpFactory & |  | ) |
| delete

## ◆ setDocumentation()

OpFactory & setDocumentation | ( | const std::string & |  | ) |

Add documentation for this operator.

The text is parsed as wiki markup.

Note
  If this factory's OpPolicy specifies a help URL, that URL takes precedence over documentation supplied with this method.

## ◆ setFlags()

OpFactory & setFlags | ( | unsigned |  | ) |

## ◆ setInternalName()

OpFactory & setInternalName | ( | const std::string & | name | ) |

## ◆ setInvisible()

OpFactory & setInvisible | ( |  | ) |

Mark this node as hidden from the UI tab menu.

This is equivalent to using the hscript ophide method.

## ◆ setLocalVariables()

OpFactory & setLocalVariables | ( | CH_LocalVariable * |  | ) |

Add one or more local variables to this operator.

## ◆ setMaxInputs()

OpFactory & setMaxInputs | ( | unsigned | = 9999 | ) |

Set the maximum number of inputs allowed by this operator.

Note
  It is only necessary to set this limit if there are inputs that have not been named with addInput() or addOptionalInput().

## ◆ setObsoleteParms()

OpFactory & setObsoleteParms | ( | const ParmList & |  | ) |

Specify obsolete parameters to this operator.

## ◆ setOperatorTable()

OpFactory & setOperatorTable | ( | const std::string & | name | ) |

## ◆ setVerb()

OpFactory & setVerb | ( | SOP_NodeVerb::CookMode | cookMode,
|  | const CacheAllocFunc & | allocator )

Register this operator as a compilable SOP.

"Verbifying" a SOP separates its input and parameter management from its cooking logic so that cooking can be safely threaded.

Parameters

  cookMode | how to initialize the output detail
  allocator | a node cache allocator for instances of this operator

Exceptions

  std::runtime_error | if this operator is not a SOP
  std::invalid_argument | if allocator is empty

## ◆ table() [1/2]

OP_OperatorTable & table | ( |  | ) |
| protected

Return the operator table with which this factory is associated.

This accessor is mainly for use by derived OpFactory classes.

## ◆ table() [2/2]

const OP_OperatorTable & table | ( |  | ) | const

Return the operator table with which this factory is associated.

This accessor is mainly for use by OpPolicy objects.