HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FS_EventGenerator.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: FS_EventGenerator.h ( FS Library, C++ )
7  *
8  * COMMENTS:
9  * This class is used to define an event generator for the UI,
10  * without actually relying on the UI library. There is a
11  * wrapper around this class that allows it to fit into the UI
12  * event loop and there is a wrapper that lets it fit into
13  * hbatch's event loop. These wrapper classes call setInstaller()
14  * set set a callback to notify them when an event generator should
15  * be installed or uninstalled. Note that event generators can only
16  * be installed after setInstaller() has been called.
17  */
18 
19 #ifndef __FS_EventGenerator__
20 #define __FS_EventGenerator__
21 
22 #include "FS_API.h"
23 class FS_EventGenerator;
24 typedef int (*FS_EventInstaller)(FS_EventGenerator *gen, int install);
25 typedef void (*FS_PollCallback)(bool /*drain_queue*/);
26 
28 public:
30  virtual ~FS_EventGenerator();
31 
32  // Method to get the class name for the event generator
33  virtual const char *getClassName() const = 0;
34 
35  // For efficiency in the UI event loop, it's advantageous to be able to
36  // tell if there are actually events waiting to be processed. There are
37  // two mechanisms for doing this.
38  //
39  // If a file descriptor is available, the UI event loop will check to see
40  // if there's any data waiting to be read. If there is, the event
41  // processor will be called. If a negative number is returned, then we
42  // cannot use this mechanism. By default, this method assumes no file
43  // descriptor exists.
44  virtual int getFileDescriptor();
45 
46  // If file descriptor is not available, then we have to poll for events.
47  // The poll time is expressed in milliseconds, so a poll time of 10 will
48  // poll every 10 ms.
49  //
50  // Note that event generators with valid file descriptors will also poll
51  // if they specify a positive poll time. The default poll time is -1,
52  // meaning that polling will not occur when the file descriptor is valid.
53  virtual int getPollTime();
54 
55  // Return whether or not events are waiting.
56  virtual bool areEventsWaiting() { return false; }
57 
58  // When there is either data on the file descriptor, or the poll time has
59  // elapsed, the processEvent() method is called. The processEvents method
60  // should return 1 if there are futher possible events, 0 if there aren't.
61  // For example, if you delete the event generator, this should return 0.
62  virtual int processEvents() = 0;
63 
64  // These methods install the generator into the event loop or uninstall it
65  // from the event loop. Note that UI applications and hbatch both have
66  // event loops. The installGenerator() command will return 0 if the
67  // application does not have an event loop.
68  int installGenerator();
69  void uninstallGenerator();
70 
71  // This method is called by the event loop to set an installer callback
72  // that is used to install FS_EventGenerators into the real event loop.
73  // It should not be called by users.
74  static void setInstaller(FS_EventInstaller installer);
75 
76  // This method is called by the event loop to set a callback. The callback
77  // is used by the event generator when it needs to explicitly drain
78  // events on the queue. It's used by the tcl and java commands while it
79  // waits for the hwish and java processes to exit.
80  static void setEventLoopPollCallback(FS_PollCallback callback);
81 
82  // Has the event loop callback been set?
83  static bool isEventLoopPollCallbackSet();
84 
85  // This method uses the event loop poll callback to poll event generators
86  // for any events that are waiting. If the event loop callback wasn't set,
87  // it won't do anything. If drain_queue is false, events will be processed
88  // and possibly added to the event queue, but the queue will not be drained.
89  void pollEventLoop(bool drain_queue=true);
90 
91 private:
92 };
93 
94 #endif
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
virtual bool areEventsWaiting()
int(* FS_EventInstaller)(FS_EventGenerator *gen, int install)
GA_API const UT_StringHolder gen
void(* FS_PollCallback)(bool)
typedef int
Definition: png.h:1175
#define FS_API
Definition: FS_API.h:10