Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

messenger.cc

Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2000 Alan McIvor <alan@mcivor.gen.nz>
00003 ** Copyright (C) 2003 Guilhem Bonnefille <guilhem.bonnefille@free.fr>
00004 **  
00005 ** This program is free software; you can redistribute it and/or modify
00006 ** it under the terms of the GNU General Public License as published by
00007 ** the Free Software Foundation; either version 2 of the License, or
00008 ** (at your option) any later version.
00009 ** 
00010 ** This program is distributed in the hope that it will be useful,
00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ** GNU General Public License for more details.
00014 ** 
00015 ** You should have received a copy of the GNU General Public License
00016 ** along with this program; if not, write to the Free Software 
00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #include <iostream>
00021 #include <cstdio>
00022 #include <cstring>
00023 #include <cstdarg>
00024 
00025 using namespace std;
00026 
00027 #include "messenger.h"
00028 
00030 bool MESSENGER::_globalDebug = false;
00031 
00034 void MESSENGER::Format(char *buf, const char *fmt, va_list args)
00035 {
00036   vsprintf(buf, fmt, args);
00037 }
00038 
00041 void MESSENGER::Format(char *buf, const char *fmt, ...)
00042 {
00043   va_list args;
00044  
00045   va_start(args, fmt);
00046   Format(buf, fmt, args);
00047   va_end(args);
00048 }
00049 
00051 void MESSENGER::Error(const char *fmt, va_list args)
00052 {
00053   char buf[1024];
00054  
00055   Format(buf, fmt, args);
00056   
00057   cerr << buf << endl;
00058 }
00059 
00061 void MESSENGER::Error(const char *fmt, ...) 
00062 {
00063   va_list args;
00064  
00065   va_start(args, fmt);
00066   Error(fmt, args);
00067   va_end(args);
00068 }
00069 
00071 void MESSENGER::Warning(const char *fmt, va_list args)
00072 {
00073   char buf[1024];
00074 
00075   sprintf(buf,"WARNING: ");
00076   Format(buf+strlen(buf), fmt, args);
00077   
00078   cerr << buf << endl;
00079 }
00080 
00082 void MESSENGER::Warning(const char *fmt, ...) 
00083 {
00084   char buf[1024];
00085   va_list args;
00086  
00087   va_start(args, fmt);
00088   Warning(buf, fmt, args);
00089   va_end(args);
00090 }
00091 
00093 void MESSENGER::Debug(ENTITY entity, const char *fmt, va_list args)
00094 {
00095   char buf[1024];
00096 
00097   if (_globalDebug == true)
00098     {
00099       Format(buf,fmt,args);
00100       cerr << buf << endl;
00101     }
00102 }
00103 
00105 void MESSENGER::Debug(ENTITY entity, const char *fmt, ...) 
00106 {
00107   va_list args;
00108 
00109   va_start(args,fmt);
00110   Debug(entity, fmt, args);
00111   va_end(args);
00112 }

Generated on Wed Feb 18 22:23:54 2004 for Opensched by doxygen1.2.15