Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

polled.H

Go to the documentation of this file.
00001 #ifndef _polled_H_
00002 #define _polled_H_
00003 
00004 #include "dev/dev.H"
00005 
00006 // 
00007 //  DEVpoll_obs - callback just before devices are polled
00008 //    Register to be notified just before the devices are polled
00009 //  each frame by using the global instance DEV_POLLobs().
00010 //
00011 class DEVpoll_obs {
00012    public: 
00013      class data {
00014      };
00015      virtual void  notify(const data &) = 0;
00016 };
00017 
00018 extern OBSlist<DEVpoll_obs> &DEV_POLLobs();
00019 
00020 //
00021 // This is a mixin class used for all devices that need to poll their inputs. 
00022 // It exists (rather than having each polled device add itself to the 
00023 // appropriate FD_MANAGER) so that all polled input devices can be polled at 
00024 // a controlled time, right before drawing, to reduce lag. 
00025 //
00026 class DllImpExp DEVpolled {
00027  protected:
00028    static ARRAY<DEVpolled*> *_pollable;
00029    static ARRAY<DEVpolled *> &pollable() { if (!_pollable)
00030                                              _pollable = new ARRAY<DEVpolled*>;
00031                                           return *_pollable; }
00032 
00033    /* ---------- abstract polling interface -------------- */
00034    virtual void do_poll() = 0;   // Override with device-specific poll operation
00035    
00036  public:
00037    void        add_poll()        { pollable() += this; }
00038    void        rem_poll()        { pollable() -= this; }
00039    
00040    static void run_polls();
00041 };
00042 
00043 
00044 #endif

Generated on Mon Sep 15 16:25:57 2003 for gluebase by doxygen1.2.18