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 #include <UT/UT_NonCopyable.h>
24 
25 class FS_EventGenerator;
26 typedef int (*FS_EventInstaller)(FS_EventGenerator *gen, int install);
27 typedef void (*FS_PollCallback)(bool /*drain_queue*/);
28 
30 {
31 public:
33  virtual ~FS_EventGenerator();
34 
36 
37  // Method to get the class name for the event generator
38  virtual const char *getClassName() const = 0;
39 
40  // For efficiency in the UI event loop, it's advantageous to be able to
41  // tell if there are actually events waiting to be processed. There are
42  // two mechanisms for doing this.
43  //
44  // If a file descriptor is available, the UI event loop will check to see
45  // if there's any data waiting to be read. If there is, the event
46  // processor will be called. If a negative number is returned, then we
47  // cannot use this mechanism. By default, this method assumes no file
48  // descriptor exists.
49  virtual int getFileDescriptor();
50 
51  // If file descriptor is not available, then we have to poll for events.
52  // The poll time is expressed in milliseconds, so a poll time of 10 will
53  // poll every 10 ms.
54  //
55  // Note that event generators with valid file descriptors will also poll
56  // if they specify a positive poll time. The default poll time is -1,
57  // meaning that polling will not occur when the file descriptor is valid.
58  virtual int getPollTime();
59 
60  // Return whether or not events are waiting.
61  virtual bool areEventsWaiting() { return false; }
62 
63  // When there is either data on the file descriptor, or the poll time has
64  // elapsed, the processEvent() method is called. The processEvents method
65  // should return 1 if there are futher possible events, 0 if there aren't.
66  // For example, if you delete the event generator, this should return 0.
67  virtual int processEvents() = 0;
68 
69  // These methods install the generator into the event loop or uninstall it
70  // from the event loop. Note that UI applications and hbatch both have
71  // event loops. The installGenerator() command will return 0 if the
72  // application does not have an event loop.
73  int installGenerator();
74  void uninstallGenerator();
75 
76  // This method is called by the event loop to set an installer callback
77  // that is used to install FS_EventGenerators into the real event loop.
78  // It should not be called by users.
79  static void setInstaller(FS_EventInstaller installer);
80 
81  // This method is called by the event loop to set a callback. The callback
82  // is used by the event generator when it needs to explicitly drain
83  // events on the queue. It's used by the tcl and java commands while it
84  // waits for the hwish and java processes to exit.
85  static void setEventLoopPollCallback(FS_PollCallback callback);
86 
87  // Has the event loop callback been set?
88  static bool isEventLoopPollCallbackSet();
89 
90  // This method uses the event loop poll callback to poll event generators
91  // for any events that are waiting. If the event loop callback wasn't set,
92  // it won't do anything. If drain_queue is false, events will be processed
93  // and possibly added to the event queue, but the queue will not be drained.
94  void pollEventLoop(bool drain_queue=true);
95 
96 private:
97 };
98 
99 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
void
Definition: png.h:1083
virtual bool areEventsWaiting()
int(* FS_EventInstaller)(FS_EventGenerator *gen, int install)
GA_API const UT_StringHolder gen
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
void(* FS_PollCallback)(bool)
#define FS_API
Definition: FS_API.h:10