HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_AutoLockInputs.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: OP_AutoLockInputs.h ( OP Library, C++)
7  *
8  * COMMENTS: Lock and automatically unlock inputs when cooking an operator.
9  */
10 
11 #ifndef __OP_AutoLockInputs__
12 #define __OP_AutoLockInputs__
13 
14 #include "OP_API.h"
15 #include "OP_Error.h"
16 #include <UT/UT_BitArray.h>
17 #include <SYS/SYS_Types.h>
18 
19 class OP_Context;
20 class OP_Node;
21 
23 {
24 public:
25  /// Constructor accepting a node.
26  /// NOTE: This does *NOT* lock the inputs! Call lock().
27  /// Must call setNode() before locking if NULL.
28  OP_AutoLockInputs(OP_Node *node = NULL)
29  {
30  myNode = node;
31  }
32 
33  /// Destructor unlocks any locked inputs.
35  {
36  unlock();
37  }
38 
39  /// Unlocks any locked inputs and sets the node.
40  void setNode(OP_Node *node)
41  {
42  unlock();
43  myNode = node;
44  if (myLockedInputs.size() > 0)
45  myLockedInputs.setSize(0);
46  }
47 
48  /// Locks all inputs
49  OP_ERROR lock(OP_Context &context);
50 
51  /// Locks a single input
52  OP_ERROR lockInput(exint input, OP_Context &context);
53 
54  /// Returns the node associated with this auto-unlocker.
56  { return myNode; }
57 
58  /// Returns a bit array of successfully locked inputs.
60  { return myLockedInputs; }
61 
62  /// Explicitly unlock all locked inputs.
63  /// NOTE: Only call this directly if you need to unlock early!
64  void unlock();
65 
66  /// Explicitly unlock the specified locked input.
67  /// NOTE: Only call this directly if you need to unlock early!
68  void unlockInput(exint input);
69 
70  /// Explicilty marks the given input as unlocked. This is used
71  /// if another function outside of the auto-lock has explicilty
72  /// unlocked that input.
73  void markInputUnlocked(exint input);
74 
75 private:
76  OP_Node *myNode;
77  UT_BitArray myLockedInputs;
78 };
79 
80 #endif
const UT_BitArray & getLockedInputs() const
Returns a bit array of successfully locked inputs.
OP_Node * getLockedNode() const
Returns the node associated with this auto-unlocker.
UT_ErrorSeverity
Definition: UT_Error.h:25
OP_AutoLockInputs(OP_Node *node=NULL)
int64 exint
Definition: SYS_Types.h:116
~OP_AutoLockInputs()
Destructor unlocks any locked inputs.
#define OP_API
Definition: OP_API.h:10
void setNode(OP_Node *node)
Unlocks any locked inputs and sets the node.