00001 /* 00002 $Id: dedebug.h,v 1.3 2004/12/12 23:44:44 pecos Exp $ 00003 */ 00004 00005 /* ********* 00006 * 00007 * This file is part of: 00008 * NePSing, Network Protocol Simulator next generation 00009 * 00010 * Copyright (C) 2004 Tommaso Pecorella <tpecorella@mac.com> 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 2.1 of the License, or (at your option) any later version. 00016 * 00017 * This library is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Lesser General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 ********* */ 00027 00034 #ifndef ___DEDEBUG_H___ 00035 #define ___DEDEBUG_H___ 00036 00037 using namespace std ; 00038 00039 00040 #include "detime.h" 00041 00042 00043 #define DBG_PRINT_TIMES 1 00044 #define DBG_PRINT_EVENTS 2 00045 #define DBG_PRINT_EVENT_QUEUE 4 00046 #define DBG_PRINT_MESSAGES 8 00047 00048 class DEScheduler; 00049 00051 00102 class DEDebug 00103 { 00104 protected: 00105 // The currnt level of debugging 00106 int DbgLevel; 00107 00108 // When to start printing debugging informations of level 2 and above 00109 DETime StartTime; 00110 00111 // First 'run' when to start printing debugging informations of level 2 and above 00112 int StartRun; 00113 00114 // Current time 00115 DETime T; 00116 00117 // Current Run 00118 int Run; 00119 00120 // Time between printig of level 1 debugging informations 00121 DETime PrintInterval; 00122 00123 // Time of the last print of information 00124 DETime LastPrint; 00125 00126 public: 00128 ostream& os; 00129 00131 00155 DEDebug(ostream& _os = cout, 00156 int _DbgLevel = 0, 00157 DETime _StartTime = 0.0, 00158 int _StartRun = 0, 00159 DETime _PrintInterval = DETime()); 00160 00162 void Initialize(); 00163 00165 void SchedulerExecEvent(DEScheduler* Sched); 00166 00168 void CurrentTime(DETime& Time, int _Run); 00169 00171 bool isDebugging(); 00172 00174 DEDebug& operator<< (const char* x ); 00175 00177 void ErrorMessage(const char * x); 00178 }; 00179 00186 template<class T> DEDebug& operator<< ( DEDebug& dbg, const T& x ) 00187 { 00188 if (dbg.isDebugging()) 00189 dbg.os << x; 00190 00191 return dbg; 00192 }; 00193 00194 00195 #endif 00196 00197 /* 00198 00199 $Log: dedebug.h,v $ 00200 Revision 1.3 2004/12/12 23:44:44 pecos 00201 Added Copyright message - LGPL 00202 00203 Revision 1.2 2004/12/11 23:53:24 pecos 00204 Added DoxyGen comments 00205 00206 Revision 1.1.1.1 2004/07/08 16:59:33 pecos 00207 NePSing framework 00208 00209 Revision 1.2 1999/05/25 10:27:08 pecos 00210 *** empty log message *** 00211 00212 Revision 1.1.1.1 1999/05/24 15:59:57 inesis 00213 INeSiS Project 00214 00215 Revision 1.1.1.1 1999/05/24 15:17:20 inesis 00216 INeSiS Project 00217 00218 Revision 1.2 1999/01/26 11:24:23 pecos 00219 *** empty log message *** 00220 00221 Revision 1.1 1999/01/02 09:09:22 nanni 00222 *** empty log message *** 00223 00224 00225 */