CICEPortState is used for accessing the state of a custom ICENode input port from the cb_ICENode_BeginEvaluate BeginEvaluate callback.
dirty states:checking for port changes The state information is normally used by custom nodes for managing internal cache in order to optimize the computation and improve performance. The following port states are supported:
siDataDirtyState
is set to true. Disconnecting a port will set siDataDirtyState
to true. XSIPLUGINCALLBACK CStatus Port_State_Observer_BeginEvaluate( ICENodeContext& in_ctxt ) { CICEPortState portGeomGroup( in_ctxt, ID_IN_GeometryGroup ); CICEPortState portGeomCurve( in_ctxt, ID_IN_NurbsCurve ); CICEPortState portGeomMesh( in_ctxt, ID_IN_MeshSurf ); CICEPortState portGeomNurbsSurf( in_ctxt, ID_IN_NurbsSurf ); CICEPortState portGeomCloud( in_ctxt, ID_IN_PointCloud ); CICEPortState data( in_ctxt, ID_IN_Data ); double dCurrentFrame = in_ctxt.GetTime(); LogPortStates( portGeomGroup, L"GeometryGroup", dCurrentFrame ); LogPortStates( portGeomCurve, L"NurbsCurve", dCurrentFrame ); LogPortStates( portGeomMesh, L"MeshSurf", dCurrentFrame ); LogPortStates( portGeomNurbsSurf, L"NurbsSurf", dCurrentFrame ); LogPortStates( portGeomCloud, L"PointCloud", dCurrentFrame ); LogPortStates( data, L"Data", dCurrentFrame ); return CStatus::OK; } static void LogPortStates( CICEPortState& in_port, const CString& in_portName, double in_dCurrentFrame ) { if ( in_port.IsDirty( CICEPortState::siAnyDirtyState ) ) { bool bTypeDirtyState = in_port.IsDirty( CICEPortState::siTypeDirtyState ); bool bDataDirtyState = in_port.IsDirty( CICEPortState::siDataDirtyState ); bool bTimeDirtyState = in_port.IsDirty( CICEPortState::siTimeDirtyState ); in_port.ClearState(); Application app; // Don't log redundant information: // bTypeDirtyState always implies bDataDirtyState + bTimeDirtyState // bDataDirtyState always implies bTimeDirtyState if ( bTypeDirtyState) { app.LogMessage( ">>> Port " + in_portName + " siTypeDirtyState at frame " + CString(in_dCurrentFrame) + " is dirty" ); } else { if ( bDataDirtyState) { app.LogMessage( ">>> Port " + in_portName + " siDataDirtyState at frame " + CString(in_dCurrentFrame) + " is dirty" ); } else if ( bTimeDirtyState) { app.LogMessage( ">>> Port " + in_portName + " siTimeDirtyState at frame " + CString(in_dCurrentFrame) + " is dirty" ); } } } }
#include <xsi_iceportstate.h>
Public Types | |
enum | DirtyState { siTypeDirtyState = 1<<0, siDataDirtyState = 1<<1, siTimeDirtyState = 1<<2, siAnyDirtyState = siTypeDirtyState|siDataDirtyState|siTimeDirtyState } |
Public Member Functions | |
CICEPortState (ICENodeContext &in_ctxt, ULONG in_nInputPortID, ULONG in_nInstanceIndex=0) | |
CICEPortState () | |
~CICEPortState () | |
CICEPortState (const CICEPortState &in_obj) | |
bool | operator== (const CICEPortState &in_obj) const |
bool | operator!= (const CICEPortState &in_obj) const |
CICEPortState & | operator= (const CICEPortState &in_obj) |
bool | IsValid () const |
bool | IsDirty (unsigned short in_flag=siAnyDirtyState) const |
void | ClearState () |
enum DirtyState |
Defines the supported dirty port state types.
CICEPortState | ( | ICENodeContext & | in_ctxt, |
ULONG | in_nInputPortID, | ||
ULONG | in_nInstanceIndex = 0 |
||
) |
Constructor for creating and initializing an instance of CICEPortState.
in_ctxt | ICENode evaluation context. |
in_nInputPortID | Input port identifier. |
in_nInstanceIndex | The group instance of the port. Defaults to 0 . |
CICEPortState | ( | ) |
Default constructor.
~CICEPortState | ( | ) |
Default destructor.
CICEPortState | ( | const CICEPortState & | in_obj | ) |
Copy constructor.
in_obj | constant class object. |
bool operator== | ( | const CICEPortState & | in_obj | ) | const |
Equality operator. Tests whether the states on two ports are the same.
in_obj | CICEPortState instance to compare. |
bool operator!= | ( | const CICEPortState & | in_obj | ) | const |
Inequality operator. Tests whether the states on two ports are different.
in_obj | CICEPortState instance to compare. |
CICEPortState& operator= | ( | const CICEPortState & | in_obj | ) |
Assignment operator. Assign this CICEPortState to another CICEPortState.
in_obj | CICEPortState object to assign. |
bool IsValid | ( | ) | const |
Returns true if the object is valid. Unless not created properly, the object is always valid.
bool IsDirty | ( | unsigned short | in_flag = siAnyDirtyState | ) | const |
Returns the dirty state of a port for a given state type defined in the CICEPortState::DirtyState enumerator. By default, IsDirty returns true if at least one of the port states is dirty or returns false otherwise.
void ClearState | ( | ) |
Clears the port states.