Bug fixed in the Makefile.
[Faustine.git] / interpretor / faust-0.9.47mr3 / architecture / osclib / faust / src / lib / OSCFError.h
1 /*
2 Copyright (c) Grame 2010
3
4 This library is free software; you can redistribute it and modify it under
5 the terms of the GNU Library General Public License as published by the
6 Free Software Foundation version 2 of the License, or any later version.
7
8 This library is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
11 for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
17 Grame Research Laboratory, 9, rue du Garet 69001 Lyon - France
18 research@grame.fr
19
20 */
21
22 #ifndef __OSCFError__
23 #define __OSCFError__
24
25 #include <iostream>
26 #include "OSCStream.h"
27
28 namespace oscfaust
29 {
30
31 //--------------------------------------------------------------------------
32 /*!
33 \brief OSC error stream
34
35 Combines the \c cerr and \c oscerr streams
36 */
37 typedef struct OSCFError {
38 bool oscpending;
39 OSCFError() { oscpending = false; }
40 } OSCFError;
41
42 typedef struct OSCFErrorEnd {
43 } OSCFErrEnd;
44
45
46 inline OSCFError& operator << (OSCFError& err, OSCFErrEnd end)
47 {
48 std::cerr << std::endl;
49 #ifndef NO_OSC
50 oscerr << OSCEnd();
51 err.oscpending = false;
52 #endif
53 return err;
54 }
55
56 template <typename T> OSCFError& operator << (OSCFError& err, const T& arg)
57 {
58 std::cerr << arg;
59 #ifndef NO_OSC
60 if (!err.oscpending) {
61 oscerr << OSCErr();
62 err.oscpending = true;
63 }
64 oscerr << arg;
65 #endif
66 return err;
67 }
68
69 class Message;
70 OSCFError& operator << (OSCFError& err, const Message* arg);
71
72 extern OSCFError OSCFErr; // static OSC error output stream
73 extern OSCFErrEnd OSCFEndl; // static OSC error output stream end
74
75 } // end namespace
76
77 #endif