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