HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COP_SlapcompDispatcher Class Reference

#include <COP_SlapcompDispatcher.h>

+ Inheritance diagram for COP_SlapcompDispatcher:

Public Types

using Callbacks = COP_SlapcompManager::Callbacks
 
using CheckFunction = bool(*)(const OP_Node *)
 Should return true for nodes that are supported by the slapcomp type. More...
 
using AllocationFunction ) = COP_SlapcompManager *(*)(
 

Public Member Functions

 COP_SlapcompDispatcher ()
 
 COP_SlapcompDispatcher (const COP_SlapcompDispatcher &)=delete
 
 COP_SlapcompDispatcher (COP_SlapcompDispatcher &&)
 
COP_SlapcompDispatcheroperator= (const COP_SlapcompDispatcher &)=delete
 
COP_SlapcompDispatcheroperator= (COP_SlapcompDispatcher &&)
 
void copyFrom (const COP_SlapcompDispatcher &other, const OP_Context &context)
 Makes this object a copy of other, including the enable state. More...
 
void enable (int target_node_id, const OP_Context &) override
 Enable slapcomp with the given node. More...
 
void enable (OP_Node *const node, const OP_Context &ctx)
 
void disable () override
 Disable slapcomp. More...
 
bool isEnabled () const override
 Returns the on-off state of slapcomp. More...
 
bool hasErrors () const override
 Returns true if the last run of slapcomp had errors. More...
 
int getTargetNode () const override
 Returns the id of the node slapcomp was built from. More...
 
void setErrorCallback (void(*cb)(void *, const char *), void *data) override
 Sets a callback that gets called when reporting slapcomp errors. More...
 
void setWarningCallback (void(*cb)(void *, const char *), void *data) override
 Sets a callback that gets called when reporting slapcomp warnings. More...
 
void setRunCallback (void(*cb)(void *), void *data) override
 Sets a callback that gets called when slapcomp is run. More...
 
void setUpdateCallback (void(*cb)(void *), void *data) override
 Sets a callback that gets called when slapcomp changes. More...
 
bool isSlapcompAOV (const UT_StringHolder &name) const override
 
bool buildForInputs (const COP_CableStructure &inputs, const OP_Context &context) override
 Prepares for applying slapcomp for inputs of the given types. More...
 
void runSlapcompImpl (COP_SlapcompInputFetcher &input_fetcher, const OP_Context &context) override
 Should run slapcomp with the specified inputs and context. More...
 
COP_CableStructure getOutputStructure () const override
 Should return the outputs that this slapcomp produces. More...
 
IMX_LayerPtr getOutputLayer (const UT_StringHolder &name) const override
 Returns a particular output by name. More...
 
int getVersion () const override
 
bool hasStateChanged () const override
 
void setVersion (int version) override
 
- Public Member Functions inherited from COP_SlapcompManager
 COP_SlapcompManager ()=default
 
 COP_SlapcompManager (const COP_SlapcompManager &)=delete
 
 COP_SlapcompManager (COP_SlapcompManager &&)=default
 
COP_SlapcompManageroperator= (const COP_SlapcompManager &)=delete
 
COP_SlapcompManageroperator= (COP_SlapcompManager &&)=default
 
virtual ~COP_SlapcompManager ()=default
 
void enable (OP_Node *const node, const OP_Context &ctx)
 
virtual bool expectsLayerCameras () const
 
bool runSlapcomp (COP_SlapcompInputFetcher &input_fetcher, const OP_Context &context, bool should_build=true)
 
bool build (const COP_SlapcompInputFetcher &input_fetcher, const OP_Context &context)
 Prepares for applying slapcomp for the provided set of inputs. More...
 
UT_StringMap< OutputgetOutputs () const
 
void setCallbacks (const Callbacks &cbs)
 Set all callbacks using a struct. More...
 

Static Public Member Functions

static void installFactory (CheckFunction checker, AllocationFunction allocator)
 

Protected Member Functions

void reportError (const char *message) override
 Reports an error (through the callback if possible). More...
 
void reportWarning (const char *message) override
 Reports a warning (through the callback if possible). More...
 
- Protected Member Functions inherited from COP_SlapcompManager
void reportAllErrorManagerErrors (const UT_ErrorManager &)
 Relays all warnings and messages from the error manager. More...
 

Protected Attributes

Callbacks myCallbacks
 
UT_UniquePtr< COP_SlapcompManagermyManager
 
int myCurrentType = -1
 
int myVersion = 0
 
bool myStateChanged = false
 

Detailed Description

This class is a polymorphic slapcomp manager that can be used to interface with different types of slapcomps. To this end, a factory must be registered with the static installFactory() method, with a checker and an allocator. When a manager gets enabled with a specific node, the first factory (i.e. one registered earliest) whose check the node passes will be used to run it.

Definition at line 19 of file COP_SlapcompDispatcher.h.

Member Typedef Documentation

using COP_SlapcompDispatcher::AllocationFunction = COP_SlapcompManager* (*)(

Should dynamically allocate a new slapcomp manager for the slapcomp type.

Definition at line 28 of file COP_SlapcompDispatcher.h.

Should return true for nodes that are supported by the slapcomp type.

Definition at line 25 of file COP_SlapcompDispatcher.h.

Constructor & Destructor Documentation

COP_SlapcompDispatcher::COP_SlapcompDispatcher ( )
inline

Definition at line 49 of file COP_SlapcompDispatcher.h.

COP_SlapcompDispatcher::COP_SlapcompDispatcher ( const COP_SlapcompDispatcher )
delete
COP_SlapcompDispatcher::COP_SlapcompDispatcher ( COP_SlapcompDispatcher &&  )

Member Function Documentation

bool COP_SlapcompDispatcher::buildForInputs ( const COP_CableStructure inputs,
const OP_Context context 
)
overridevirtual

Prepares for applying slapcomp for inputs of the given types.

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::copyFrom ( const COP_SlapcompDispatcher other,
const OP_Context context 
)

Makes this object a copy of other, including the enable state.

void COP_SlapcompDispatcher::disable ( )
overridevirtual

Disable slapcomp.

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::enable ( int  target_node_id,
const OP_Context  
)
overridevirtual

Enable slapcomp with the given node.

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::enable ( OP_Node *const  node,
const OP_Context ctx 
)
inline

Definition at line 60 of file COP_SlapcompDispatcher.h.

IMX_LayerPtr COP_SlapcompDispatcher::getOutputLayer ( const UT_StringHolder name) const
overridevirtual

Returns a particular output by name.

Implements COP_SlapcompManager.

COP_CableStructure COP_SlapcompDispatcher::getOutputStructure ( ) const
overridevirtual

Should return the outputs that this slapcomp produces.

Implements COP_SlapcompManager.

int COP_SlapcompDispatcher::getTargetNode ( ) const
overridevirtual

Returns the id of the node slapcomp was built from.

Implements COP_SlapcompManager.

int COP_SlapcompDispatcher::getVersion ( ) const
inlineoverridevirtual

Returns a version number, which is incremented every time the program is rebuilt.

Implements COP_SlapcompManager.

Definition at line 83 of file COP_SlapcompDispatcher.h.

bool COP_SlapcompDispatcher::hasErrors ( ) const
overridevirtual

Returns true if the last run of slapcomp had errors.

Implements COP_SlapcompManager.

bool COP_SlapcompDispatcher::hasStateChanged ( ) const
inlineoverridevirtual

Returns true if the last attempted application of slapcomp may have changed the possible outputs. This flag is is reset before each application of slapcomp.

Implements COP_SlapcompManager.

Definition at line 87 of file COP_SlapcompDispatcher.h.

static void COP_SlapcompDispatcher::installFactory ( CheckFunction  checker,
AllocationFunction  allocator 
)
static

Call this function to register a slapcomp factory. The checker function should return true for a node if that slapcomp manager should be used for it.

bool COP_SlapcompDispatcher::isEnabled ( ) const
overridevirtual

Returns the on-off state of slapcomp.

Implements COP_SlapcompManager.

bool COP_SlapcompDispatcher::isSlapcompAOV ( const UT_StringHolder name) const
overridevirtual

Returns true if the slapcomp program ouputs an AOV with the given name. Should accept "color" as an alias for the "C" AOV.

Implements COP_SlapcompManager.

COP_SlapcompDispatcher& COP_SlapcompDispatcher::operator= ( const COP_SlapcompDispatcher )
delete
COP_SlapcompDispatcher& COP_SlapcompDispatcher::operator= ( COP_SlapcompDispatcher &&  )
void COP_SlapcompDispatcher::reportError ( const char *  message)
overrideprotectedvirtual

Reports an error (through the callback if possible).

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::reportWarning ( const char *  message)
overrideprotectedvirtual

Reports a warning (through the callback if possible).

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::runSlapcompImpl ( COP_SlapcompInputFetcher input_fetcher,
const OP_Context context 
)
overridevirtual

Should run slapcomp with the specified inputs and context.

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::setErrorCallback ( void(*)(void *, const char *)  cb,
void data 
)
overridevirtual

Sets a callback that gets called when reporting slapcomp errors.

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::setRunCallback ( void(*)(void *)  cb,
void data 
)
overridevirtual

Sets a callback that gets called when slapcomp is run.

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::setUpdateCallback ( void(*)(void *)  cb,
void data 
)
overridevirtual

Sets a callback that gets called when slapcomp changes.

Implements COP_SlapcompManager.

void COP_SlapcompDispatcher::setVersion ( int  version)
inlineoverridevirtual

This should really be private, but due to difficult visibility rules, we just settle for this... This should only be called by higher-level managers that interface with other managers.

Implements COP_SlapcompManager.

Definition at line 93 of file COP_SlapcompDispatcher.h.

void COP_SlapcompDispatcher::setWarningCallback ( void(*)(void *, const char *)  cb,
void data 
)
overridevirtual

Sets a callback that gets called when reporting slapcomp warnings.

Implements COP_SlapcompManager.

Member Data Documentation

Callbacks COP_SlapcompDispatcher::myCallbacks
protected

Definition at line 103 of file COP_SlapcompDispatcher.h.

int COP_SlapcompDispatcher::myCurrentType = -1
protected

Definition at line 105 of file COP_SlapcompDispatcher.h.

UT_UniquePtr<COP_SlapcompManager> COP_SlapcompDispatcher::myManager
protected

Definition at line 104 of file COP_SlapcompDispatcher.h.

bool COP_SlapcompDispatcher::myStateChanged = false
protected

Definition at line 108 of file COP_SlapcompDispatcher.h.

int COP_SlapcompDispatcher::myVersion = 0
protected

Definition at line 107 of file COP_SlapcompDispatcher.h.


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