HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COP_MicroNode.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  */
7 
8 #pragma once
9 
10 #include "COP_API.h"
11 
12 #include <OP/OP_Context.h>
13 
14 /// If this is defined, COPs will track and check context option dependencies.
15 #define USE_CONTEXT_OPTIONS_MICRONODE
16 
17 #ifdef USE_CONTEXT_OPTIONS_MICRONODE
18 
19 #include <CH/CH_EvalContextFwd.h>
20 #include <CH/CH_Manager.h>
22 
23 /// Base type of a micronode in COPs.
25 
26 /// Returns whether the micronode requires updating given the context.
29  const OP_Context& context)
30 {
31  return dep.requiresUpdateTimeOrOptions(context);
32 }
33 /// Returns whether the micronode requires updating in the current evaluation
34 /// context.
37 {
38  CH_Manager* chman = CHgetManager();
39  const CH_EvalContext& context = chman->evalContext(SYSgetSTID());
40  DEP_ContextOptionsReadHandle options = context.contextOptions();
41  if (options.isNull())
42  options = chman->getDefaultContextOptions();
43  return dep.requiresUpdate(context.time()) ||
44  dep.requiresUpdateOptions(options, context.contextOptionsStack());
45 }
46 
47 /// Marks the micronode clean with respect to the given context.
50 {
53  dep.updateOptions(context);
54  dep.update(context.getTime());
55 }
56 /// Marks the micronode clean with respect to the current evaluation context.
59 {
60  CH_Manager* chman = CHgetManager();
61  const CH_EvalContext& context = chman->evalContext(SYSgetSTID());
62  DEP_ContextOptionsReadHandle options = context.contextOptions();
63  if (options.isNull())
64  options = chman->getDefaultContextOptions();
67  dep.updateOptions(options, context.contextOptionsStack());
68  dep.update(context.time());
69 }
70 
71 #else // USE_CONTEXT_OPTIONS_MICRONODE
72 
73 #include <DEP/DEP_TimedMicroNode.h>
74 
75 /// Base type of a micronode in COPs.
77 
78 /// Returns whether the micronode requires updating given the context.
81  const OP_Context& context)
82 {
83  return dep.requiresUpdate(context.getTime());
84 }
85 /// Returns whether the micronode requires updating in the current evaluation
86 /// context.
89 {
90  const CH_EvalContext& context = CHgetManager()->evalContext(SYSgetSTID());
91  return dep.requiresUpdate(context.time());
92 }
93 
94 /// Marks the micronode clean with respect to the given context.
97 {
99  dep.update(context.getTime());
100 }
101 /// Marks the micronode clean with respect to the current evaluation context.
102 SYS_FORCE_INLINE void
104 {
105  const CH_EvalContext& context = CHgetManager()->evalContext(SYSgetSTID());
107  dep.update(context.time());
108 }
109 
110 #endif // USE_CONTEXT_OPTIONS_MICRONODE
111 
112 /// This micronode can invoke a callback when it becomes dirty. It's used by
113 /// COP_ApexProgram's callback registration, to make sure a function runs when
114 /// the program's results are changed.
116 {
117 public:
119  COP_BaseMicroNode(), myCallback(nullptr), myEnabled(false)
120  {
121  }
122 
123  /// Controls whether or not the callback runs when the micronode is dirtied.
124  void enableCallback(bool enable)
125  {
126  myEnabled = enable;
127  }
128 
129  /// Returns true if the callback is enabled (even if not set).
130  bool callbackEnabled() const
131  {
132  return myEnabled;
133  }
134 
135  /// Set the callback to run when the micronode is dirtied. The callback will
136  /// only be invoked if enableCallback(true) was previously called. The data
137  /// pointer is passed to the callback function when it's executed.
138  void setCallback(void (*callback)(void*), void* data)
139  {
140  myCallback = callback;
141  myData = data;
142  }
143 
144  void becameDirty(DEP_MicroNode& src, const DEP_PropagateData& propdata)
145  override;
146 
147 private:
148  void (*myCallback)(void*);
149  void* myData;
150  bool myEnabled;
151 };
152 
DEP_ContextOptionsHandle getDefaultContextOptions() const
Definition: CH_Manager.h:1676
virtual void becameDirty(DEP_MicroNode &src, const DEP_PropagateData &propdata)
SYS_FORCE_INLINE void COPupdateMicroNode(COP_BaseMicroNode &dep, const OP_Context &context)
Marks the micronode clean with respect to the given context.
Definition: COP_MicroNode.h:49
void
Definition: png.h:1083
void setCallback(void(*callback)(void *), void *data)
GLboolean * data
Definition: glcorearb.h:131
fpreal getTime() const
Definition: OP_Context.h:63
bool requiresUpdateTimeOrOptions(const OP_Context &context) const
bool requiresUpdate(fpreal t) const override
const CH_EvalContext & evalContext(int thread) const
Definition: CH_Manager.h:1452
fpreal64 time() const
bool requiresUpdateOptions(DEP_ContextOptionsReadHandle options, const DEP_ContextOptionsStack *optstack) const
CH_Manager * CHgetManager()
Definition: CH_Manager.h:2151
SYS_FORCE_INLINE bool COPmicroNodeRequiresUpdate(const COP_BaseMicroNode &dep, const OP_Context &context)
Returns whether the micronode requires updating given the context.
Definition: COP_MicroNode.h:28
OP_ContextOptionsMicroNode COP_BaseMicroNode
Base type of a micronode in COPs.
Definition: COP_MicroNode.h:24
void updateOptions(const OP_Context &context)
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
bool callbackEnabled() const
Returns true if the callback is enabled (even if not set).
SYS_API int SYSgetSTID()
void enableCallback(bool enable)
Controls whether or not the callback runs when the micronode is dirtied.
const DEP_ContextOptionsStack * contextOptionsStack() const
#define COP_API
Definition: COP_API.h:8
void update(fpreal t) override
Propagation info for a dep micro node.
Definition: DEP_MicroNode.h:36
DEP_ContextOptionsReadHandle contextOptions() const
bool isNull() const
Test if this is a NULL pointer.
Definition: UT_COW.h:211
bool inheritTimeDependentFromExplicitInputs()
bool inheritContextOptionDepsFromExplicitInputs(const UT_StringArray &ignore_deps)
Definition: format.h:1821
GLenum src
Definition: glcorearb.h:1793