1 /*
2  * Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef ARDOUR_TEST_RECEIVER_H
20 #define ARDOUR_TEST_RECEIVER_H
21 
22 #include <iostream>
23 
24 #include "pbd/textreceiver.h"
25 
26 class TestReceiver : public Receiver
27 {
28 protected:
receive(Transmitter::Channel chn,const char * str)29 	void receive (Transmitter::Channel chn, const char * str) {
30 		const char *prefix = "";
31 
32 		switch (chn) {
33 		case Transmitter::Error:
34 			prefix = ": [ERROR]: ";
35 			break;
36 		case Transmitter::Debug:
37 			/* ignore */
38 			return;
39 		case Transmitter::Info:
40 			/* ignore */
41 			return;
42 		case Transmitter::Warning:
43 			prefix = ": [WARNING]: ";
44 			break;
45 		case Transmitter::Fatal:
46 			prefix = ": [FATAL]: ";
47 			break;
48 		case Transmitter::Throw:
49 			/* this isn't supposed to happen */
50 			abort ();
51 		}
52 
53 		/* note: iostreams are already thread-safe: no external
54 		   lock required.
55 		*/
56 
57 		std::cout << prefix << str << std::endl;
58 
59 		if (chn == Transmitter::Fatal) {
60 			exit (9);
61 		}
62 	}
63 };
64 
65 #endif // ARDOUR_TEST_RECEIVER_H
66