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 __libmisc_transmitter_h__
21 #define __libmisc_transmitter_h__
26 #include <sigc++/sigc++.h>
28 #include "pbd/libpbd_visibility.h"
30 class LIBPBD_API Transmitter : public std::stringstream
42 Transmitter (Channel);
44 sigc::signal<void,Channel, const char *> &sender() {
48 bool does_not_return ();
51 virtual void deliver ();
52 friend std::ostream& endmsg (std::ostream &);
56 sigc::signal<void, Channel, const char *> *send;
58 sigc::signal<void, Channel, const char *> info;
59 sigc::signal<void, Channel, const char *> warning;
60 sigc::signal<void, Channel, const char *> error;
61 sigc::signal<void, Channel, const char *> fatal;
64 /* for EGCS 2.91.66, if this function is not compiled within the same
65 compilation unit as the one where a ThrownError is thrown, then
66 nothing will catch the error. This is a pretty small function, so
67 inlining it here seems like a reasonable workaround.
71 endmsg (std::ostream &ostr)
76 /* There is a serious bug in the Cygnus/GCC libstdc++ library:
77 cout is not actually an ostream, but a trick was played
78 to make the compiler think that it is. This will cause
79 the dynamic_cast<> to fail with SEGV. So, first check to
80 see if ostr == cout, and handle it specially.
83 if (&ostr == &std::cout) {
84 std::cout << std::endl;
86 } else if (&ostr == &std::cerr) {
87 std::cerr << std::endl;
91 if ((t = dynamic_cast<Transmitter *> (&ostr)) != 0) {
94 /* hmm. not a Transmitter, so just put a newline on
95 it and assume that that will be enough.
105 extern "C" { LIBPBD_API void pbd_c_error (const char *); }
107 #endif // __libmisc_transmitter_h__