HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 <SYS/SYS_Types.h>
6 #include "OP_DataTypes.h" // For OP_DATA_TYPE
7 #include "OP_Version.h" // For OP_VERSION
8 
9 #include <stdio.h>
10 
11 #define OP_TIME_TOL (0.00001)
12 
13 class OP_CookTask;
14 
16 {
17 public:
19  virtual ~OP_ContextData() {}
20 };
21 
23 {
24 public:
25  struct CurrentEvalTimeTag {};
27 
28  OP_Context();
29  explicit OP_Context(fpreal t);
30  OP_Context(fpreal t, int thread);
32  OP_Context(const OP_Context &from);
33 
34  fpreal getTime() const { return myTime; }
35  void setTime(fpreal t) { myTime = t; }
36 
37  int xres() const { return myXres; }
38  int yres() const { return myYres; }
39  void setXres(int xres) { myXres = xres; }
40  void setYres(int yres) { myYres = yres; }
41  void setRes(int x, int y) { myXres = x; myYres = y; }
42 
43  exint getFrame() const;
44  fpreal getFloatFrame() const;
45  void setFrame(fpreal frame);
46 
47  // The "thread" member is the sequential thread returned by SYSgetSTID()
48  // (UT_Thread.h) for the current thread.
49  void setThread(int thr) { myThread = thr; }
50  int getThread() const { return myThread; }
51 
52  // A cook task will be available when the node is asked to be cooked in
53  // parallel.
54  void setCookTask(OP_CookTask *cook_task)
55  { myCookTask = cook_task; }
57  { return myCookTask; }
58  const OP_CookTask *cookTask() const
59  { return myCookTask; }
60 
61  OP_ContextData *getData() const { return myData; }
62  void setData(OP_ContextData *data) { myData = data; }
63 
64  OP_VERSION getVersion() const { return myVersion; }
65  void setVersion(OP_VERSION version) { myVersion = version; }
66 
67  bool isCookOverride() const
68  { return myFlags.myCookOverride; }
69  void setCookOverride(bool override)
70  { myFlags.myCookOverride = override; }
71  bool isTimeDep() const
72  { return myFlags.myTimeDep; }
73  void setTimeDep(bool timedep)
74  { myFlags.myTimeDep = timedep; }
75 
76  void copyPointer(const OP_Context &from);
77 
78  int operator==( const OP_Context &to ) const;
79  OP_Context &operator= ( const OP_Context &to );
80 
81  void print(FILE *);
82 
83 
84 
85 private:
86  // Match criteria.
87  // These fields define the parameters
88  // for getCookedData(), or
89  // needToCook() or cook().
90  fpreal myTime; // 0 based time
91  int myXres; // Pixel resolution
92  int myYres; // Pixel resolution
93 
94  void initDefaults(fpreal t, int thread);
95 
96  // These fields are used to define the
97  // kind of COOK or GET that is to take
98  // place
99  OP_VERSION myVersion; // When fetching data, this is the
100  // version number of the fetched data.
101  OP_ContextData *myData; // User-specific cook data
102 
103  int myThread; // SYSgetSTID() when this context was
104  // created.
105 
106  OP_CookTask *myCookTask; // Current cook task
107 
108  // Flags (default value is in square brackets)
109  struct Flags
110  {
111  uint64 myCookOverride:1, // [false] Cook only if it is quick
112  myTimeDep:1; // [true] Am I time dependent?
113  } myFlags;
114 };
115 
116 #endif
OP_VERSION getVersion() const
Definition: OP_Context.h:64
uint64 OP_VERSION
Definition: OP_Version.h:6
fpreal getTime() const
Definition: OP_Context.h:34
void setData(OP_ContextData *data)
Definition: OP_Context.h:62
void setRes(int x, int y)
Definition: OP_Context.h:41
OP_ContextData * getData() const
Definition: OP_Context.h:61
int yres() const
Definition: OP_Context.h:38
GLint y
Definition: glcorearb.h:102
void setCookOverride(bool override)
Definition: OP_Context.h:69
void setCookTask(OP_CookTask *cook_task)
Definition: OP_Context.h:54
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
void setVersion(OP_VERSION version)
Definition: OP_Context.h:65
unsigned long long uint64
Definition: SYS_Types.h:107
OP_CookTask * cookTask()
Definition: OP_Context.h:56
int64 exint
Definition: SYS_Types.h:115
void setYres(int yres)
Definition: OP_Context.h:40
bool isCookOverride() const
Definition: OP_Context.h:67
GLboolean * data
Definition: glcorearb.h:130
int xres() const
Definition: OP_Context.h:37
void setTimeDep(bool timedep)
Definition: OP_Context.h:73
void setTime(fpreal t)
Definition: OP_Context.h:35
double fpreal
Definition: SYS_Types.h:269
virtual ~OP_ContextData()
Definition: OP_Context.h:19
void setXres(int xres)
Definition: OP_Context.h:39
#define OP_API
Definition: OP_API.h:10
GLint GLenum GLint x
Definition: glcorearb.h:408
bool isTimeDep() const
Definition: OP_Context.h:71
const OP_CookTask * cookTask() const
Definition: OP_Context.h:58
static CurrentEvalTimeTag CurrentEvalTime
Definition: OP_Context.h:26
int getThread() const
Definition: OP_Context.h:50
void setThread(int thr)
Definition: OP_Context.h:49