HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CH_EvalContextFwd.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: CH_EvalContextFwd.h (CH Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __CH_EVALCONTEXTFWD_H_INLUDED__
12 #define __CH_EVALCONTEXTFWD_H_INLUDED__
13 
14 #include "CH_API.h"
16 #include <UT/UT_COW.h>
17 #include <UT/UT_NonCopyable.h>
18 #include <SYS/SYS_Inline.h>
19 #include <SYS/SYS_Types.h>
20 
23 class CH_Channel;
24 class CH_Collection;
25 class CH_Manager;
26 class CH_ScriptAccessManager;
27 class CH_Segment;
28 
29 /// @file CH_EvalContextFwd.h
30 ///
31 /// Define CH_EvalContext enough to be used as data members.
32 /// Include CH_EvalContext.h which has additional includes to be able to call
33 /// all methods on it.
34 
35 /// Information regarding the current evaluation.
36 ///
37 /// NOTES:
38 /// - All of the pointers may be NULL in general.
39 /// - If channel() is non-NULL, it must belong to the non-NULL collection()
40 /// - If channel() is non-NULL, then channelName() and segment() is non-NULL
41 /// - If segment() is non-NULL <==> collection()/channel() are non-NULL
42 /// - If segment() is non-NULL it must belong to the non-NULL channel()
43 ///
45 {
46 public:
47  class Scope;
48 
49  inline fpreal time() const
50  { return myTime; }
51  inline const CH_Collection* collection() const
52  { return myCollection; }
54  { return myCollection; }
56  { return myContextOptionsStack; }
58  { return myContextOptions; }
59  inline const CH_Channel* channel() const
60  { return myChannel; }
61  inline CH_Channel* channel()
62  { return myChannel; }
63  inline const CH_Segment* segment() const
64  { return mySegment; }
65  inline CH_Segment* segment()
66  { return mySegment; }
67  inline const char* channelName() const
68  { return myChannelName; }
70  { return myParentContext; }
71 
72 private:
73  fpreal myTime;
74  CH_Collection *myCollection;
75  const DEP_ContextOptionsStack *myContextOptionsStack;
76  DEP_ContextOptionsReadHandle myContextOptions;
77  CH_Channel *myChannel;
78  CH_Segment *mySegment;
79 
80  // Note that because hscript expression string parms can add
81  // dependencies even though they don't have a channel, we have to store
82  // both the evaluating channel and the evaluating channel name.
83  const char *myChannelName;
84  CH_EvalContext *myParentContext;
85 
86  friend class CH_Manager;
87  friend class CH_EvalContext::Scope;
88  friend class CH_AutoEvaluateTime;
89  friend class CH_AutoEvalCollection;
90 };
91 
92 // Make CH_EvalContext a POD type for UT_ThreadSpecificValue for zero init.
93 template <> constexpr SYS_STATIC_INLINE bool
94 SYSisPOD<CH_EvalContext>() { return true; }
95 
96 /// Object to save the current CH_EvalContext and then restore it when it goes
97 /// out of scope.
99 {
100 public:
101  Scope(int thread);
102  Scope(int thread, bool push_access_manager);
103  ~Scope();
104 
105  inline fpreal time() const
106  { return myContext.myTime; }
107  inline const CH_Collection* collection() const
108  { return myContext.myCollection; }
109  inline const CH_Channel* channel() const
110  { return myContext.myChannel; }
111  inline const CH_Segment* segment() const
112  { return myContext.mySegment; }
113  inline const char* channelName() const
114  { return myContext.myChannelName; }
115 
116  inline void
118  {
119  myContext.myTime = t;
120  }
121 
122  inline void
124  {
125  myContext.myCollection = collection;
126  }
127 
128  // Sets myChannel to channel, myChannelName to myChannel->getName(), and
129  // mySegment to seg. (not inline to avoid #including CH_Channel.h)
130  void setChannel(CH_Channel* channel, CH_Segment* seg);
131 
132  // Sets myChannel/mySegment to NULL and myChannelName to channel_name.
133  void setChannelName(const char* channel_name)
134  {
135  myContext.myChannel = NULL;
136  myContext.mySegment = NULL;
137  myContext.myChannelName = channel_name;
138  }
139 
140 
141  inline void
143  {
144  myContext.mySegment = segment;
145  }
146 
147  inline void
149  const DEP_ContextOptionsReadHandle &options,
150  const DEP_ContextOptionsStack *options_stack)
151  {
152  myContext.myContextOptions = options;
153  myContext.myContextOptionsStack = options_stack;
154  }
155 
156  // Common combinations
157  inline void
158  set(fpreal t, CH_Collection* collection, CH_Channel* chp, CH_Segment* seg)
159  {
160  myContext.myTime = t;
161  myContext.myCollection = collection;
162  setChannel(chp, seg);
163  }
164  inline void
165  set(fpreal t, CH_Collection* collection)
166  {
167  myContext.myTime = t;
168  myContext.myCollection = collection;
169  setChannel(NULL, NULL);
170  }
171  inline void
172  set(CH_Collection* collection, CH_Channel* channel)
173  {
174  myContext.myCollection = collection;
175  setChannel(channel, NULL);
176  }
177  inline void
178  set(CH_Collection* collection, const char* channel_name)
179  {
180  myContext.myCollection = collection;
181  setChannelName(channel_name);
182  }
183 
184 private:
185  CH_EvalContext& myContext;
186  CH_ScriptAccessManager* myAccessMgr;
187  CH_EvalContext myPrevContext;
188 };
189 
190 #endif // __CH_EVALCONTEXTFWD_H_INLUDED__
CH_Collection * collection()
void setChannelName(const char *channel_name)
CH_Segment * segment()
const CH_Segment * segment() const
constexpr SYS_STATIC_INLINE bool SYSisPOD< CH_EvalContext >()
void setSegment(CH_Segment *segment)
CH_EvalContext * parentContext()
void set(fpreal t, CH_Collection *collection, CH_Channel *chp, CH_Segment *seg)
const CH_Collection * collection() const
*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 set(fpreal t, CH_Collection *collection)
void setTime(fpreal t)
void setContextOptions(const DEP_ContextOptionsReadHandle &options, const DEP_ContextOptionsStack *options_stack)
double fpreal
Definition: SYS_Types.h:276
Push & restore the evaluation time (and optionally a channel collection)
Definition: CH_Manager.h:1599
CH_Channel * channel()
#define CH_API
Definition: CH_API.h:10
void set(CH_Collection *collection, CH_Channel *channel)
const char * channelName() const
const DEP_ContextOptionsStack * contextOptionsStack() const
Scope(int thread)
DEP_ContextOptionsReadHandle contextOptions() const
void setCollection(CH_Collection *collection)
void set(CH_Collection *collection, const char *channel_name)
GLdouble GLdouble t
Definition: glew.h:1398
fpreal time() const
const CH_Channel * channel() const