Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Notifier.h

00001 #ifndef INCLUDE_NOTIFIER_H
00002 #define INCLUDE_NOTIFIER_H
00003 /*
00004  * This is the Loris C++ Class Library, implementing analysis, 
00005  * manipulation, and synthesis of digitized sounds using the Reassigned 
00006  * Bandwidth-Enhanced Additive Sound Model.
00007  *
00008  * Loris is Copyright (c) 1999-2004 by Kelly Fitz and Lippold Haken
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  *
00025  * Notifier.h
00026  *
00027  *  A pair of dedicated streams, notifier and debugger, are used for
00028  *  notification throughout the Loris class library. These streams are used
00029  *  like cout or cerr, but they buffer their contents until a newline is
00030  *  receieved. Then they post their entire contents to a notification
00031  *  handler. The default handler just prints to stderr, but other handlers
00032  *  may be dynamically specified using setNotifierHandler() and
00033  *  setDebuggerHandler().
00034  *  
00035  *  debugger is enabled only when compiled with the preprocessor macro
00036  *  Debug_Loris defined. It cannot be enabled using setDebuggerHandler() if
00037  *  Debug_Loris is undefined.When Debug_Loris is not defined, characters
00038  *  streamed onto debugger are never posted nor are they otherwise
00039  *  accessible.
00040  *  
00041  *  Notifier.h may be included in c files. The stream declarations are
00042  *  omitted, but the notification handler routines are accessible.
00043  *  
00044  *
00045  * Kelly Fitz, 28 Feb 2000
00046  * loris@cerlsoundgroup.org
00047  *
00048  * http://www.cerlsoundgroup.org/Loris/
00049  *
00050  */
00051 
00052 
00053 /*
00054  *  stream declaration, C++ only:
00055  */
00056 #ifdef __cplusplus
00057 
00058 #include <iostream>
00059 
00060 //  begin namespace
00061 namespace Loris {
00062 
00063 std::ostream & getNotifierStream(void);
00064 std::ostream & getDebuggerStream(void);
00065 
00066 //  declare streams:
00067 static std::ostream & notifier = getNotifierStream();
00068 /*  This stream is used throughout Loris (and may be used by clients)
00069     to provide user feedback. Characters streamed onto notifier are
00070     buffered until a newline is received, and then the entire contents
00071     of the stream are flushed to the current notification handler (stderr,
00072     by default).
00073  */
00074 
00075 static std::ostream & debugger = getDebuggerStream();
00076 /*  This stream is used throughout Loris (and may be used by clients)
00077     to provide debugging information. Characters streamed onto debugger are
00078     buffered until a newline is received, and then the entire contents
00079     of the stream are flushed to the current debugger handler (stderr,
00080     by default).
00081     
00082     debugger is enabled only when compiled with the preprocessor macro
00083     Debug_Loris defined. It cannot be enabled using setDebuggerHandler()
00084     if Debug_Loris is undefined. When Debug_Loris is not defined,
00085     characters streamed onto debugger are never posted nor are they
00086     otherwise accessible.
00087  */
00088  
00089 //  for convenience, import endl and ends from std into Loris:
00090 using std::endl;
00091 using std::ends;
00092 
00093 }   //  end of namespace Loris
00094 
00095 #endif  /* def __cplusplus */
00096 
00097 /*
00098  *  handler assignment, c linkable:
00099  */
00100 
00101 #ifdef __cplusplus
00102 //  begin namespace
00103 namespace Loris {
00104 extern "C" {
00105 #endif  //  def __cplusplus
00106 
00107 //  These functions do not throw exceptions.
00108 typedef void(*NotificationHandler)(const char * s);
00109 NotificationHandler setNotifierHandler( NotificationHandler fn );
00110 /*  Specify a new handling procedure for posting user feedback, and return
00111     the current handler. 
00112  */
00113  
00114 NotificationHandler setDebuggerHandler( NotificationHandler fn );
00115 /*  Specify a new handling procedure for posting debugging information, and return
00116     the current handler. This has no effect unless compiled with the Debug_Loris
00117     preprocessor macro defined.
00118  */
00119  
00120 #ifdef __cplusplus
00121 }   //  end extern "C"
00122 }   //  end of namespace Loris
00123 #endif  // def __cplusplus
00124 
00125 
00126 #endif /* ndef INCLUDE_NOTIFIER_H */

Generated on Thu Apr 14 22:01:55 2005 for Loris by doxygen 1.3.4