home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / arts / notification.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-10-08  |  2.2 KB  |  88 lines

  1.     /*
  2.  
  3.     Copyright (C) 2000 Stefan Westerfeld
  4.                        stefan@space.twc.de
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.   
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.    
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.     Boston, MA 02111-1307, USA.
  20.  
  21.     */
  22.  
  23. #ifndef NOTIFICATION_H
  24. #define NOTIFICATION_H
  25.  
  26. #include <queue>
  27. #include "arts_export.h"
  28.  
  29. namespace Arts {
  30.  
  31. /*
  32.  * BC - Status (2002-03-08): Notification, NotificationClient,
  33.  *   NotificationManager
  34.  *
  35.  * All need to be kept BC, NotificationManager with usual d ptr.
  36.  *
  37.  * Notifications have to be FAST. Currently, they use ID, data & receiver.
  38.  * However, there may be future extensions. For this, one more internal
  39.  * field is provided. Set it to ZERO currently when sending notifications.
  40.  */
  41.  
  42. struct Notification;
  43. typedef void (*NotificationDestroyFunction)(const Notification& n);
  44.  
  45. struct Notification {
  46.     class NotificationClient *receiver;
  47.     int ID;
  48.     void *data;
  49.     void *internal;        /* handle with care, equivalent to private d ptr */
  50.  
  51.     void setDestroy(NotificationDestroyFunction destroy);
  52. };
  53.  
  54. class ARTS_EXPORT NotificationClient {
  55. public:
  56.     virtual void notify(const Notification& wm);
  57. };
  58.  
  59. class NotificationManagerPrivate;
  60. class ARTS_EXPORT NotificationManager {
  61. private:
  62.     NotificationManagerPrivate *d;        // unused
  63. protected:
  64.     std::queue<Notification> todo;
  65.     static NotificationManager *instance;
  66.  
  67. public:
  68.     NotificationManager();
  69.     ~NotificationManager();
  70.  
  71.     static inline NotificationManager *the()
  72.     {
  73.         return instance;
  74.     }
  75.     void send(Notification wm);
  76.     inline bool pending()
  77.     {
  78.         return !todo.empty();
  79.     }
  80.     bool run();
  81.     void removeClient(NotificationClient *client);
  82.  
  83. };
  84.  
  85. }
  86.  
  87. #endif /* NOTIFICATION_H */
  88.