HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CH_EvalContext.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_EvalContext.h (CH Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __CH_EVALCONTEXT_H_INCLUDED__
12 #define __CH_EVALCONTEXT_H_INCLUDED__
13 
14 /// @file CH_EvalContext.h
15 /// This file is used to split off inline implementations which require more
16 /// headers.
17 
18 #include "CH_EvalContextFwd.h" // See this for actual definition
19 
20 #include "CH_Channel.h"
21 #include "CH_Manager.h"
22 #include "CH_ScriptAccessManager.h"
23 
24 
25 inline
26 CH_EvalContext::Scope::Scope(int thread)
27  : myContext(CHgetManager()->evalContext(thread))
28  , myAccessMgr(CHgetManager()->getAccessManager(thread))
29 {
30  myPrevContext = myContext;
31  myContext.myParentContext = &myPrevContext;
32  if (myAccessMgr)
33  myAccessMgr->pushChEvalContext();
34 }
35 
36 inline
37 CH_EvalContext::Scope::Scope(int thread, bool push_access_manager)
38  : myContext(CHgetManager()->evalContext(thread))
39  , myAccessMgr(push_access_manager
40  ? CHgetManager()->getAccessManager(thread) : NULL)
41 {
42  myPrevContext = myContext;
43  myContext.myParentContext = &myPrevContext;
44  if (myAccessMgr)
45  myAccessMgr->pushChEvalContext();
46 }
47 
48 inline
49 CH_EvalContext::Scope::~Scope()
50 {
51  myContext = myPrevContext;
52  if (myAccessMgr)
53  myAccessMgr->popChEvalContext();
54 }
55 
56 inline
57 void
58 CH_EvalContext::Scope::setChannel(CH_Channel* channel, CH_Segment* seg)
59 {
60  // Note that because hscript expression string parms can add
61  // dependencies even though they don't have a channel, we have to store
62  // both the evaluating channel and the evaluating channel name.
63  myContext.myChannel = channel;
64  myContext.mySegment = seg;
65  myContext.myChannelName = channel ? channel->getName().buffer() : NULL;
66 }
67 
68 #endif // __CH_EVALCONTEXT_H_INCLUDED__
const CH_EvalContext & evalContext(int thread) const
Definition: CH_Manager.h:1203
CH_Manager * CHgetManager()
Definition: CH_Manager.h:1718
SYS_FORCE_INLINE const char * buffer() const
const UT_StringHolder & getName(void) const
Definition: CH_Channel.h:243
*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
virtual CH_ScriptAccessManager * getAccessManager(int)
Definition: CH_Manager.h:1199