2 Copyright (C) 1998-99 Paul Barton-Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __pbd_abstract_ui_h__
21 #define __pbd_abstract_ui_h__
27 #include <sigc++/sigc++.h>
29 #include <glibmm/thread.h>
31 #include "pbd/receiver.h"
32 #include "pbd/ringbufferNPT.h"
33 #include "pbd/base_ui.h"
37 template <class RequestObject>
38 class AbstractUI : public BaseUI
41 AbstractUI (std::string name, bool with_signal_pipe);
42 virtual ~AbstractUI() {}
44 virtual bool caller_is_ui_thread() = 0;
46 void call_slot (sigc::slot<void> el_slot) {
47 RequestObject *req = get_request (BaseUI::CallSlot);
57 void register_thread (pthread_t, std::string);
58 void register_thread_with_request_count (pthread_t, std::string, uint32_t num_requests);
61 typedef RingBufferNPT<RequestObject> RequestBuffer;
62 typedef typename RequestBuffer::rw_vector RequestBufferVector;
63 typedef typename std::map<pthread_t,RequestBuffer*>::iterator RequestBufferMapIterator;
65 Glib::Mutex request_buffer_map_lock;
66 typedef std::map<pthread_t,RequestBuffer*> RequestBufferMap;
67 RequestBufferMap request_buffers;
68 pthread_key_t thread_request_buffer_key;
69 RequestObject* get_request (RequestType);
70 void handle_ui_requests ();
71 void send_request (RequestObject *);
73 virtual void do_request (RequestObject *) = 0;
76 #endif /* __pbd_abstract_ui_h__ */