HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_Context.h
Go to the documentation of this file.
1 #ifndef __OP_Context__
2 #define __OP_Context__
3 
4 #include "OP_API.h"
5 #include "OP_DataTypes.h" // For OP_DATA_TYPE
6 #include "OP_Version.h" // For OP_VERSION
8 #include <UT/UT_NonCopyable.h>
9 #include <SYS/SYS_Types.h>
10 #include <stdio.h>
11 
12 #define OP_TIME_TOL (0.00001)
13 
14 class OP_CookTask;
15 class OP_Context;
16 
18 {
19 public:
21  virtual ~OP_ContextData() {}
22 };
23 
25 {
26 public:
28  bool push_options);
30 
32  { return *myHandle; }
34  { return myHandle.operator->(); }
35  DEP_ContextOptions *get() const
36  { return myHandle.get(); }
37 
38 private:
40  OP_Context &myContext;
41  bool myOptionsPushed;
42 };
43 
45 {
46 public:
47  struct CurrentEvalTimeTag {};
51 
52  OP_Context();
53  explicit OP_Context(fpreal t);
54  OP_Context(fpreal t, int thread);
57  OP_Context(const OP_Context &from);
58  ~OP_Context();
59 
60  fpreal getTime() const { return myTime; }
61  void setTime(fpreal t) { myTime = t; }
62 #if SYS_SIZEOF_FPREAL > 4
63  // Maintain double precision when setting time - we do this by deprecating
64  // a method to set 32 bit time.
65  SYS_DEPRECATED(17.0) void setTime(fpreal32 t) { myTime = t; }
66 #endif
67 
68  int xres() const { return myXres; }
69  int yres() const { return myYres; }
70  void setXres(int xres) { myXres = xres; }
71  void setYres(int yres) { myYres = yres; }
72  void setRes(int x, int y) { myXres = x; myYres = y; }
73 
74  exint getFrame() const;
75  fpreal getFloatFrame() const;
76  void setFrame(fpreal frame);
77 
78  // The "thread" member is the sequential thread returned by SYSgetSTID()
79  // (UT_Thread.h) for the current thread.
80  void setThread(int thr) { myThread = thr; }
81  int getThread() const { return myThread; }
82 
83  // A cook task will be available when the node is asked to be cooked in
84  // parallel.
85  void setCookTask(OP_CookTask *cook_task)
86  { myCookTask = cook_task; }
88  { return myCookTask; }
89  const OP_CookTask *cookTask() const
90  { return myCookTask; }
91 
92  OP_ContextData *getData() const { return myData; }
93  void setData(OP_ContextData *data) { myData = data; }
94 
95  OP_VERSION getVersion() const { return myVersion; }
96  void setVersion(OP_VERSION version) { myVersion = version; }
97 
98  bool isCookOverride() const
99  { return myFlags.myCookOverride; }
100  void setCookOverride(bool override)
101  { myFlags.myCookOverride = override; }
102 
104  {
105  myFlags.myTimeDep = true;
106  myFlags.myCompareContextOptions = false;
107  }
108 
109  bool isTimeDep() const
110  { return myFlags.myTimeDep; }
111  void setTimeDep(bool timedep)
112  { myFlags.myTimeDep = timedep; }
113 
115  { myFlags.myCompareContextOptions = compare; }
117  { return myFlags.myCompareContextOptions; }
118 
120  { myContextOptionDeps.reset(); }
123  myContextOptionDeps).
124  insert(deps.begin(), deps.end()); }
126  { return myContextOptionsStack.get(); }
128  { return myContextOptions; }
129  DEP_ContextOptionsWriteHandle editContextOptions();
130  DEP_ContextOptionsWriteHandle pushContextOptions();
131  bool popContextOptions();
132 
133  void copyPointer(const OP_Context &from);
134 
135  int operator==( const OP_Context &to ) const;
136  OP_Context &operator= ( const OP_Context &to );
137 
138  void print(FILE *) const;
139 
140 private: // data
141  // 0 based time in seconds
142  fpreal myTime;
143 
144  // SYSgetSTID() when this context was created.
145  int myThread;
146 
147  // These fields are used to define the kind of COOK or GET that is to take
148  // place.
149  //
150  // When fetching data, this is the version number of the fetched data.
151  OP_VERSION myVersion;
152  // User-specific cook data
153  OP_ContextData *myData;
154 
155  // Match criteria. These fields define the parameters for getCookedData(),
156  // or needToCook() or cook().
157  //
158  // Arbitrary extra options
159  DEP_ContextOptionsHandle myContextOptions;
160  // Stack of context options
161  UT_UniquePtr<DEP_ContextOptionsStack> myContextOptionsStack;
162  // Which context options matter
163  DEP_ContextOptionDepsPtr myContextOptionDeps;
164 
165  // Pixel resolution
166  int myXres;
167  int myYres;
168 
169  // Current cook task
170  OP_CookTask *myCookTask;
171 
172  // Flags (default value is in square brackets)
173  struct Flags
174  {
175  // [false] Cook only if it is quick
176  uint64 myCookOverride:1,
177  // [true] Am I time dependent?
178  myTimeDep:1,
179  // [true] Compare context options when testing for equality?
180  myCompareContextOptions:1;
181  } myFlags;
182 };
183 
184 #endif
vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
Definition: simd.h:3340
OP_VERSION getVersion() const
Definition: OP_Context.h:95
#define SYS_DEPRECATED(__V__)
uint64 OP_VERSION
Definition: OP_Version.h:6
DEP_ContextOptionsReadHandle getContextOptions() const
Definition: OP_Context.h:127
fpreal getTime() const
Definition: OP_Context.h:60
void setData(OP_ContextData *data)
Definition: OP_Context.h:93
UT_ConcurrentSet< UT_StringHolder > DEP_ContextOptionDeps
void setRes(int x, int y)
Definition: OP_Context.h:72
bool isCompareContextOptions() const
Definition: OP_Context.h:116
OP_ContextData * getData() const
Definition: OP_Context.h:92
int yres() const
Definition: OP_Context.h:69
void setCookOverride(bool override)
Definition: OP_Context.h:100
void setCookTask(OP_CookTask *cook_task)
Definition: OP_Context.h:85
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
void setCompareOnlyTime()
Definition: OP_Context.h:103
void setVersion(OP_VERSION version)
Definition: OP_Context.h:96
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, ROI roi={}, int nthreads=0)
unsigned long long uint64
Definition: SYS_Types.h:112
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
OP_CookTask * cookTask()
Definition: OP_Context.h:87
int64 exint
Definition: SYS_Types.h:120
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
void setYres(int yres)
Definition: OP_Context.h:71
DEP_ContextOptions * operator->() const
Definition: OP_Context.h:33
void
Definition: png.h:1083
bool isCookOverride() const
Definition: OP_Context.h:98
*Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
int xres() const
Definition: OP_Context.h:68
void setTimeDep(bool timedep)
Definition: OP_Context.h:111
void setTime(fpreal t)
Definition: OP_Context.h:61
GT_API const UT_StringHolder version
static CurrentEvalContextTag CurrentEvalContext
Definition: OP_Context.h:50
void setCompareContextOptions(bool compare)
Definition: OP_Context.h:114
double fpreal
Definition: SYS_Types.h:276
virtual ~OP_ContextData()
Definition: OP_Context.h:21
void clearContextOptionDeps()
Definition: OP_Context.h:119
void setXres(int xres)
Definition: OP_Context.h:70
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:47
#define OP_API
Definition: OP_API.h:10
void addContextOptionDeps(const DEP_ContextOptionDeps &deps)
Definition: OP_Context.h:121
const DEP_ContextOptionsStack * getContextOptionsStack() const
Definition: OP_Context.h:125
DEP_API DEP_ContextOptionDeps & DEPcreateContextOptionDepsFromPtr(DEP_ContextOptionDepsPtr &ptr, DEP_ContextOptionDepsLock *lock=nullptr)
bool isTimeDep() const
Definition: OP_Context.h:109
const OP_CookTask * cookTask() const
Definition: OP_Context.h:89
static CurrentEvalTimeTag CurrentEvalTime
Definition: OP_Context.h:48
int getThread() const
Definition: OP_Context.h:81
void setThread(int thr)
Definition: OP_Context.h:80
DEP_ContextOptions & operator*() const
Definition: OP_Context.h:31
float fpreal32
Definition: SYS_Types.h:195
GLdouble GLdouble t
Definition: glew.h:1398
std::enable_if< internal::is_string< S >::value >::type print(std::basic_ostream< FMT_CHAR(S)> &os, const S &format_str, const Args &...args)
Definition: ostream.h:146