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