remove OSF1 support
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / UAS / Base / UAS_Sender.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 // $XConsortium: UAS_Sender.hh /main/7 1996/08/21 15:44:45 drk $
24 #ifndef _UAS_Sender_hh
25 #define _UAS_Sender_hh
26
27 # include "UAS_PtrList.hh"
28
29 #ifndef CONCAT
30 #if defined(__STDC__) || defined(hpux)
31 #define CONCAT(A,B) A##B
32 #define CONCAT3(A,B,C) A##B##C
33 #else
34 #define CONCAT(A,B) A/**/B
35 #define CONCAT3(A,B,C) A/**/B/**/C
36 #endif
37 #endif
38
39 template <class T> class UAS_Receiver;
40
41 template <class T>
42 class UAS_Sender {
43 public:
44   UAS_Sender() { }
45   ~UAS_Sender();
46
47   void send_message (const T &message, void *client_data = 0);
48
49   // Request message T.
50   void request (UAS_Receiver<T> *receiver);
51   // Stop receiving message T.
52   void unrequest (UAS_Receiver<T> *receiver);
53
54 private:
55   // Keep track of message receivers so that we can send them messages
56   // and notify them when we have been destroyed.
57   UAS_PtrList<UAS_Receiver<T> > f_receiver_list;
58 };
59
60 #define STATIC_SENDER_HH(T)                             \
61   static void send_message (const T &message, void *client_data = 0)            \
62     { CONCAT(sender,T)().send_message (message, client_data); } \
63   static void request (UAS_Receiver<T> *receiver)               \
64     { CONCAT(sender,T)().request (receiver); }          \
65   static void unrequest (UAS_Receiver<T> *receiver)             \
66     { CONCAT(sender,T)().unrequest (receiver); }        \
67   static UAS_Sender<T> &CONCAT(sender,T)()
68
69 #define STATIC_SENDER_CC(T) \
70   UAS_Sender<T> &CLASS::CONCAT(sender,T)() { \
71     static UAS_Sender<T> CONCAT(f_sender,T); \
72     return (CONCAT(f_sender,T)); }
73
74 #ifdef EXPAND_TEMPLATES
75 #include "UAS_Sender.C"
76 #endif
77
78 #endif