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_Context;
15 class OP_DataMicroNode;
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 {};
49  struct StateLessTag {};
51 
52  OP_Context();
53  explicit OP_Context(fpreal t);
55  bool use_eval_context_options = true);
57  OP_Context(const OP_DataMicroNode &micronode);
58  OP_Context(const OP_Context &from);
59  OP_Context(StateLessTag, const OP_Context &from);
60  ~OP_Context();
61 
62  fpreal getTime() const { return myTime; }
63  void setTime(fpreal t) { myTime = t; }
64 #if SYS_SIZEOF_FPREAL > 4
65  // Maintain double precision when setting time - we do this by deprecating
66  // a method to set 32 bit time.
67  SYS_DEPRECATED(17.0) void setTime(fpreal32 t) { myTime = t; }
68 #endif
69 
70  int xres() const { return myXres; }
71  int yres() const { return myYres; }
72  void setXres(int xres) { myXres = xres; }
73  void setYres(int yres) { myYres = yres; }
74  void setRes(int x, int y) { myXres = x; myYres = y; }
75 
76  exint getFrame() const;
77  fpreal getFloatFrame() const;
78  void setFrame(fpreal frame);
79 
80  // The "thread" member is the sequential thread returned by SYSgetSTID()
81  // (UT_Thread.h) for the current thread.
82  void setThread(int thr) { myThread = thr; }
83  int getThread() const { return myThread; }
84 
85  OP_ContextData *getData() const { return myData; }
86  void setData(OP_ContextData *data) { myData = data; }
87 
89  { return myVersion; }
91  { myVersion = version; }
92 
93  bool isCookOverride() const
94  { return myFlags.myCookOverride; }
95  void setCookOverride(bool override)
96  { myFlags.myCookOverride = override; }
97 
99  {
100  myFlags.myTimeDep = true;
101  myFlags.myCompareContextOptions = false;
102  }
103 
104  bool isTimeDep() const
105  { return myFlags.myTimeDep; }
106  void setTimeDep(bool timedep)
107  { myFlags.myTimeDep = timedep; }
108 
110  { myFlags.myCompareContextOptions = compare; }
112  { return myFlags.myCompareContextOptions; }
113 
115  { myContextOptionDeps.reset(); }
118  myContextOptionDeps).
119  insert(deps.begin(), deps.end()); }
121  { return myContextOptionsStack.get(); }
123  { return myContextOptions; }
124  void setContextOptionsFromMicroNode(
125  const OP_DataMicroNode &micronode);
126  DEP_ContextOptionsWriteHandle editContextOptions();
127  DEP_ContextOptionsWriteHandle pushContextOptions();
128  bool popContextOptions();
129 
130  void copyPointer(const OP_Context &from);
131 
132  int operator==( const OP_Context &to ) const;
133  OP_Context &operator= ( const OP_Context &to );
134 
135  void print(FILE *) const;
136 
137 private: // data
138  // 0 based time in seconds
139  fpreal myTime;
140 
141  // SYSgetSTID() when this context was created.
142  int myThread;
143 
144  // These fields are used to define the kind of COOK or GET that is to take
145  // place.
146  //
147  // When fetching data, this is the version number of the fetched data.
148  OP_VERSION myVersion;
149  // User-specific cook data
150  OP_ContextData *myData;
151 
152  // Match criteria. These fields define the parameters for getCookedData(),
153  // or needToCook() or cook().
154  //
155  // Arbitrary extra options
156  DEP_ContextOptionsHandle myContextOptions;
157  // Stack of context options
158  UT_UniquePtr<DEP_ContextOptionsStack> myContextOptionsStack;
159  // Which context options matter
160  DEP_ContextOptionDepsPtr myContextOptionDeps;
161 
162  // Pixel resolution
163  int myXres;
164  int myYres;
165 
166  // Flags (default value is in square brackets)
167  struct Flags
168  {
169  // [false] Cook only if it is quick
170  uint64 myCookOverride:1,
171  // [true] Am I time dependent?
172  myTimeDep:1,
173  // [true] Compare context options when testing for equality?
174  myCompareContextOptions:1;
175  } myFlags;
176 };
177 
178 #endif
UT_UniquePtr< DEP_ContextOptionDeps > DEP_ContextOptionDepsPtr
#define SYS_DEPRECATED(__V__)
uint64 OP_VERSION
Definition: OP_Version.h:6
void
Definition: png.h:1083
DEP_ContextOptionsReadHandle getContextOptions() const
Definition: OP_Context.h:122
GLboolean * data
Definition: glcorearb.h:131
static StateLessTag StateLess
Definition: OP_Context.h:50
fpreal getTime() const
Definition: OP_Context.h:62
void setData(OP_ContextData *data)
Definition: OP_Context.h:86
UT_ConcurrentSet< UT_StringHolder > DEP_ContextOptionDeps
void setVersionParms(OP_VERSION version)
Definition: OP_Context.h:90
void setRes(int x, int y)
Definition: OP_Context.h:74
int64 exint
Definition: SYS_Types.h:125
bool isCompareContextOptions() const
Definition: OP_Context.h:111
OP_ContextData * getData() const
Definition: OP_Context.h:85
int yres() const
Definition: OP_Context.h:71
GLint y
Definition: glcorearb.h:103
unsigned long long uint64
Definition: SYS_Types.h:117
OIIO_FORCEINLINE vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
Definition: simd.h:3436
float fpreal32
Definition: SYS_Types.h:200
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
void setCookOverride(bool override)
Definition: OP_Context.h:95
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
void setCompareOnlyTime()
Definition: OP_Context.h:98
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, ROI roi={}, int nthreads=0)
OP_VERSION getVersionParms() const
Definition: OP_Context.h:88
void setYres(int yres)
Definition: OP_Context.h:73
DEP_ContextOptions * operator->() const
Definition: OP_Context.h:33
bool isCookOverride() const
Definition: OP_Context.h:93
int xres() const
Definition: OP_Context.h:70
void setTimeDep(bool timedep)
Definition: OP_Context.h:106
GLint GLenum GLint x
Definition: glcorearb.h:409
void setTime(fpreal t)
Definition: OP_Context.h:63
GLdouble t
Definition: glad.h:2397
GT_API const UT_StringHolder version
**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
void setCompareContextOptions(bool compare)
Definition: OP_Context.h:109
virtual ~OP_ContextData()
Definition: OP_Context.h:21
void clearContextOptionDeps()
Definition: OP_Context.h:114
fpreal64 fpreal
Definition: SYS_Types.h:277
void setXres(int xres)
Definition: OP_Context.h:72
#define OP_API
Definition: OP_API.h:10
void addContextOptionDeps(const DEP_ContextOptionDeps &deps)
Definition: OP_Context.h:116
const DEP_ContextOptionsStack * getContextOptionsStack() const
Definition: OP_Context.h:120
DEP_API DEP_ContextOptionDeps & DEPcreateContextOptionDepsFromPtr(DEP_ContextOptionDepsPtr &ptr, DEP_ContextOptionDepsLock *lock=nullptr)
bool isTimeDep() const
Definition: OP_Context.h:104
static CurrentEvalTimeTag CurrentEvalTime
Definition: OP_Context.h:48
int getThread() const
Definition: OP_Context.h:83
void setThread(int thr)
Definition: OP_Context.h:82
FMT_INLINE void print(format_string< T...> fmt, T &&...args)
Definition: core.h:2976
DEP_ContextOptions & operator*() const
Definition: OP_Context.h:31
Definition: format.h:895