InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IIdleTaskMgr.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Shawn Sheridan
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __IIdleTaskMgr__
25 #define __IIdleTaskMgr__
26 
27 #include "IPMUnknown.h"
28 #include "ShuksanID.h"
29 
30 class IIdleTask;
31 
32 /*
33  The IdleTaskMgr maintains a queue of active tasks and a queue of suspended tasks
34  to run when its RunOverdueTasks method is called from the main event loop. The active
35  tasks are prioritized on the time they want to run.
36 
37  Idle tasks are a cheap version of threads. They have no stack space of their own,
38  so the memory footprint is very small.
39 
40  The only way to check if a task is installed using the IdleTaskMgr directly
41  is to remove and re-add it like this:
42 
43  <pre>
44  uint32 when = RemoveTask(task);
45  if( when != IIdleTask::kEndOfTime){
46  //was installed so put it back
47  AddTask( task, when);
48  }else{
49  //wasn't currently installed
50  }
51  </pre>
52 */
53 class IIdleTaskMgr : public IPMUnknown
54 {
55  public:
56  enum { kDefaultIID = IID_IIDLETASKMGR };
57  enum IdleTaskEvents {SleepEvent, WakeEvent, MouseClickEvent, KeyEvent, AppOutOfFocus, AppInFocus};
58 
60  typedef enum ApplicationStateFlags { //these will likely move to the app
62  kInBackground = 1,
64  kModalDialogUp = 2,
66  kMenuUp = 4,
68  kMouseTracking = 8,
72  kApplicationMinimized = 32,
77  virtual void SetApplicationState(uint32 flags) = 0;
79  virtual uint32 GetApplicationState() = 0;
80 
87  virtual void AddTask(IIdleTask *newTask, uint32 initialMillisecondDelay = 0) = 0;
88 
99  virtual uint32 RemoveTask(IIdleTask *taskToRemove) = 0;
100 
107  virtual uint32 RunOverdueTasks( const char* (*EventsPendingFunction)()) = 0;
114  uint32 RunAllTasks( const char* (*EventsPendingFunction)()){ return RunOverdueTasks(EventsPendingFunction);} //name change until clients updated
115 
119  virtual void Shutdown() = 0;
120 
125  virtual IPMUnknown* QueryRunningTask( PMIID iid ) = 0;
126 
131  virtual bool16 GetSleepFlag() = 0;
132 
138  virtual void SetSleepFlag(bool16 sleepFlag) = 0;
139 
145  virtual void SetSleepFlagOnEvents(IdleTaskEvents idleTaskEvent) = 0;
146 };
147 
148 #endif // __IIdleTaskMgr__