2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 // $XConsortium: UAS_Sender.cc /main/4 1996/07/10 09:41:53 rcs $
24 #ifndef _UAS_Sender_CC_
25 #define _UAS_Sender_CC_
27 #include "UAS_Receiver.hh"
29 // /////////////////////////////////////////////////////////////////
30 // class destructor - remove this sender from all receiver's lists
31 // /////////////////////////////////////////////////////////////////
34 UAS_Sender<T>::~UAS_Sender()
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]);
43 // /////////////////////////////////////////////////////////////////
45 // /////////////////////////////////////////////////////////////////
47 template <class T> void
48 UAS_Sender<T>::request (UAS_Receiver<T> *receiver)
50 f_receiver_list.append (receiver);
51 receiver->append (this);
54 template <class T> void
55 UAS_Sender<T>::unrequest (UAS_Receiver<T> *receiver)
57 f_receiver_list.remove (receiver);
61 // /////////////////////////////////////////////////////////////////
62 // send - send a message to all receivers
63 // /////////////////////////////////////////////////////////////////
65 template <class T> void
66 UAS_Sender<T>::send_message (const T &message, void *client_data)
68 for (int i = f_receiver_list.numItems()-1; i >= 0; i --) {
69 f_receiver_list[i]->receive ((T &) message, client_data);