Fix typo in license headers
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / UAS / Base / UAS_Sender.C
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.cc /main/4 1996/07/10 09:41:53 rcs $
24 #ifndef _UAS_Sender_CC_
25 #define _UAS_Sender_CC_
26
27 #include "UAS_Receiver.hh"
28
29 // /////////////////////////////////////////////////////////////////
30 // class destructor - remove this sender from all receiver's lists
31 // /////////////////////////////////////////////////////////////////
32
33 template <class T>
34 UAS_Sender<T>::~UAS_Sender()
35 {
36     for (int i = f_receiver_list.numItems() -1; i >= 0; i --) {
37         f_receiver_list[i]->remove(this);
38         f_receiver_list.remove(f_receiver_list[i]);
39     }
40 }
41
42
43 // /////////////////////////////////////////////////////////////////
44 // request/unrequest 
45 // /////////////////////////////////////////////////////////////////
46
47 template <class T> void
48 UAS_Sender<T>::request (UAS_Receiver<T> *receiver)
49 {
50   f_receiver_list.append (receiver);
51   receiver->append (this);
52 }      
53
54 template <class T> void
55 UAS_Sender<T>::unrequest (UAS_Receiver<T> *receiver)
56 {
57   f_receiver_list.remove (receiver);
58 }
59
60
61 // /////////////////////////////////////////////////////////////////
62 // send - send a message to all receivers
63 // /////////////////////////////////////////////////////////////////
64
65 template <class T> void
66 UAS_Sender<T>::send_message (const T &message, void *client_data)
67 {
68     for (int i = f_receiver_list.numItems()-1; i >= 0; i --) {
69         f_receiver_list[i]->receive ((T &) message, client_data);
70     }
71 }
72
73 #endif