OpenVDB  9.0.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
OpFactory Class Reference

Helper class to simplify operator registration. More...

#include <openvdb_houdini/ParmFactory.h>

Inherited by OpenVDBOpFactory.

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. More...
 

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. More...
 
 OpFactory (const std::string &english, OP_Constructor ctor, ParmList &parms, OP_OperatorTable &table, OpFlavor flavor=SOP)
 
virtual ~OpFactory ()
 Register the operator. More...
 
 OpFactory (const OpFactory &)=delete
 
OpFactoryoperator= (const OpFactory &)=delete
 
OpFlavor flavor () const
 Return the new operator's flavor (SOP, POP, etc.). More...
 
std::string flavorString () const
 Return the new operator's flavor as a string ("SOP", "POP", etc.). More...
 
const std::string & name () const
 Return the new operator's type name. More...
 
const std::string & english () const
 Return the new operator's UI name. More...
 
const std::string & iconName () const
 Return the new operator's icon name. More...
 
const std::string & helpURL () const
 Return the new operator's help URL. More...
 
const std::string & documentation () const
 Return the new operator's documentation. More...
 
const OP_OperatorTable & table () const
 Return the operator table with which this factory is associated. More...
 
OpFactoryaddAlias (const std::string &english)
 Construct a type name for this operator from the given English name and add it as an alias. More...
 
OpFactoryaddAliasVerbatim (const std::string &name)
 Add an alias for this operator. More...
 
OpFactorysetDocumentation (const std::string &)
 Add documentation for this operator. More...
 
OpFactoryaddInput (const std::string &name)
 Add a required input with the given name. More...
 
OpFactoryaddOptionalInput (const std::string &name)
 Add an optional input with the given name. More...
 
OpFactorysetMaxInputs (unsigned=9999)
 Set the maximum number of inputs allowed by this operator. More...
 
OpFactorysetObsoleteParms (const ParmList &)
 Specify obsolete parameters to this operator. More...
 
OpFactorysetLocalVariables (CH_LocalVariable *)
 Add one or more local variables to this operator. More...
 
OpFactorysetFlags (unsigned)
 
OpFactorysetInternalName (const std::string &name)
 
OpFactorysetOperatorTable (const std::string &name)
 
OpFactorysetVerb (SOP_NodeVerb::CookMode cookMode, const CacheAllocFunc &allocator)
 Register this operator as a compilable SOP. More...
 
OpFactorysetInvisible ()
 Mark this node as hidden from the UI tab menu. More...
 
OpFactoryaddSpareData (const SpareDataMap &)
 Specify (key, value) pairs of spare data for this operator. More...
 

Static Public Member Functions

static std::string flavorToString (OpFlavor)
 Return "SOP" for the SOP flavor, "POP" for the POP flavor, etc. More...
 

Protected Member Functions

OP_OperatorTable & table ()
 Return the operator table with which this factory is associated. More...
 

Detailed Description

Helper class to simplify operator registration.

Example
void
newPopOperator(OP_OperatorTable* table)
{
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)
}

Member Typedef Documentation

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

enum OpFlavor
Enumerator
SOP 
POP 
ROP 
VOP 
HDA 

Constructor & Destructor Documentation

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
englishthe operator's UI name, as it should appear in menus
ctora factory function that creates operators of this type
parmsthe parameter template list for operators of this type
tablethe registry to which to add this operator type
flavorthe 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 ( const std::string &  english,
OP_Constructor  ctor,
ParmList parms,
OP_OperatorTable &  table,
OpFlavor  flavor = SOP 
)
Note
Factories initialized with this constructor use the DWAOpPolicy.
virtual ~OpFactory ( )
virtual

Register the operator.

OpFactory ( const OpFactory )
delete

Member Function Documentation

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.

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.
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& 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
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()
const std::string& english ( ) const

Return the new operator's UI name.

This accessor is mainly for use by OpPolicy objects.

OpFlavor flavor ( ) const

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

This accessor is mainly for use by OpPolicy objects.

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.

static 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.

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()
const std::string& iconName ( ) const

Return the new operator's icon name.

This accessor is mainly for use by OpPolicy objects.

const std::string& name ( ) const

Return the new operator's type name.

This accessor is mainly for use by OpPolicy objects.

OpFactory& operator= ( const OpFactory )
delete
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.
OpFactory& setFlags ( unsigned  )
OpFactory& setInternalName ( const std::string &  name)
OpFactory& setInvisible ( )

Mark this node as hidden from the UI tab menu.

This is equivalent to using the hscript ophide method.

OpFactory& setLocalVariables ( CH_LocalVariable *  )

Add one or more local variables to this operator.

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().
OpFactory& setObsoleteParms ( const ParmList )

Specify obsolete parameters to this operator.

OpFactory& setOperatorTable ( const std::string &  name)
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
cookModehow to initialize the output detail
allocatora node cache allocator for instances of this operator
Exceptions
std::runtime_errorif this operator is not a SOP
std::invalid_argumentif allocator is empty
const OP_OperatorTable& table ( ) const

Return the operator table with which this factory is associated.

This accessor is mainly for use by OpPolicy objects.

OP_OperatorTable& table ( )
protected

Return the operator table with which this factory is associated.

This accessor is mainly for use by derived OpFactory classes.