This machine mirrors various open-source projects.
20 Gbit/s uplink.
If there are any issues or you want another project mirrored, please contact
mirror-service -=AT=- netcologne DOT de !
00001 /*===========================================================================*/ 00002 /* 00003 * This file is part of libogg++ - a c++ library for the Ogg transport format 00004 * 00005 * Copyright (C) 2006, 2007, 2008 Elaine Tsiang YueLien 00006 * 00007 * libogg++ is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the 00019 * Free Software Foundation, Inc. 00020 * 51 Franklin Street, Fifth Floor 00021 * Boston, MA 02110-1301, USA 00022 * 00023 *===========================================================================*/ 00028 /*===========================================================================*/ 00029 #ifndef OggDebug 00030 #define OggDebug 00031 00032 #ifdef __GNUG__ 00033 #pragma interface 00034 #endif 00035 00036 #include <iostream> 00037 00038 extern "C" 00039 { 00040 #include <pthread.h> 00041 } 00042 00043 00044 namespace Ogg 00045 { 00046 using std::ostream; 00047 00048 class Debug 00049 { 00050 private: 00051 pthread_mutexattr_t lockType; 00052 pthread_mutex_t lock; 00053 00054 public: 00055 Debug() throw() 00056 { 00057 pthread_mutexattr_init(&lockType); 00058 // using a non-POSIX type 00059 pthread_mutexattr_settype(&lockType, PTHREAD_MUTEX_RECURSIVE); 00060 pthread_mutex_init(&lock, &lockType); 00061 } 00062 00063 virtual 00064 ~Debug() throw () 00065 {} 00066 00067 void 00068 init() 00069 { 00070 pthread_mutexattr_init(&lockType); 00071 pthread_mutexattr_settype(&lockType, PTHREAD_MUTEX_RECURSIVE); 00072 pthread_mutex_init(&lock, &lockType); 00073 } 00074 00075 void 00076 begin() 00077 { 00078 pthread_mutex_lock(&lock); 00079 std::cerr << std::endl << "["; 00080 } 00081 00082 void 00083 end() 00084 { 00085 std::cerr << "]" << std::endl; 00086 pthread_mutex_unlock(&lock); 00087 } 00088 } 00089 ; 00090 00091 extern Debug Dbg; 00092 00093 inline 00094 Debug& operator<<(ostream & os, Debug & dbg) 00095 { 00096 dbg.end(); 00097 return(dbg); 00098 } 00099 00100 inline 00101 ostream& operator<<(Debug & dbg, ostream & os) 00102 { 00103 dbg.begin(); 00104 return(os); 00105 } 00106 00107 inline void debug() 00108 { 00109 Dbg.init(); 00110 } 00111 00112 inline void debug(bool test) 00113 { 00114 if ( _GEN_DEBUG_CODE && test ) 00115 ; 00116 } 00117 00118 template<class X> 00119 inline void debug(bool test 00120 ,const X & x 00121 ) 00122 { 00123 if ( _GEN_DEBUG_CODE && test ) 00124 { 00125 Dbg << std::cerr 00126 << x 00127 << Dbg; 00128 } 00129 } 00130 00131 template<class X1 00132 , class X2 00133 > 00134 inline void debug(bool test 00135 ,const X1 & x1 00136 ,const X2 & x2 00137 ) 00138 { 00139 if ( _GEN_DEBUG_CODE && test ) 00140 { 00141 Dbg << std::cerr 00142 << x1 00143 << x2 00144 << Dbg; 00145 } 00146 } 00147 00148 template<class X1 00149 , class X2 00150 , class X3 00151 > 00152 inline void debug(bool test 00153 ,const X1 & x1 00154 ,const X2 & x2 00155 ,const X3 & x3 00156 ) 00157 { 00158 if ( _GEN_DEBUG_CODE && test ) 00159 { 00160 Dbg << std::cerr 00161 << x1 00162 << x2 00163 << x3 00164 << Dbg; 00165 } 00166 } 00167 00168 template<class X1 00169 , class X2 00170 , class X3 00171 , class X4 00172 > 00173 inline void debug(bool test 00174 ,const X1 & x1 00175 ,const X2 & x2 00176 ,const X3 & x3 00177 ,const X4 & x4 00178 ) 00179 { 00180 if ( _GEN_DEBUG_CODE && test ) 00181 { 00182 Dbg << std::cerr 00183 << x1 00184 << x2 00185 << x3 00186 << x4 00187 << Dbg; 00188 } 00189 } 00190 00191 template<class X1 00192 , class X2 00193 , class X3 00194 , class X4 00195 , class X5 00196 > 00197 inline void debug(bool test 00198 ,const X1 & x1 00199 ,const X2 & x2 00200 ,const X3 & x3 00201 ,const X4 & x4 00202 ,const X5 & x5 00203 ) 00204 { 00205 if ( _GEN_DEBUG_CODE && test ) 00206 { 00207 Dbg << std::cerr 00208 << x1 00209 << x2 00210 << x3 00211 << x4 00212 << x5 00213 << Dbg; 00214 } 00215 } 00216 00217 template<class X1 00218 , class X2 00219 , class X3 00220 , class X4 00221 , class X5 00222 , class X6 00223 > 00224 inline void debug(bool test 00225 ,const X1 & x1 00226 ,const X2 & x2 00227 ,const X3 & x3 00228 ,const X4 & x4 00229 ,const X5 & x5 00230 ,const X6 & x6 00231 ) 00232 { 00233 if ( _GEN_DEBUG_CODE && test ) 00234 { 00235 Dbg << std::cerr 00236 << x1 00237 << x2 00238 << x3 00239 << x4 00240 << x5 00241 << x6 00242 << Dbg; 00243 } 00244 } 00245 00246 template<class X1 00247 , class X2 00248 , class X3 00249 , class X4 00250 , class X5 00251 , class X6 00252 , class X7 00253 > 00254 inline void debug(bool test 00255 ,const X1 & x1 00256 ,const X2 & x2 00257 ,const X3 & x3 00258 ,const X4 & x4 00259 ,const X5 & x5 00260 ,const X6 & x6 00261 ,const X7 & x7 00262 ) 00263 { 00264 if ( _GEN_DEBUG_CODE && test ) 00265 { 00266 Dbg 00267 <<std::cerr 00268 << x1 00269 << x2 00270 << x3 00271 << x4 00272 << x5 00273 << x6 00274 << x7 00275 << Dbg; 00276 } 00277 } 00278 00279 template<class X1 00280 , class X2 00281 , class X3 00282 , class X4 00283 , class X5 00284 , class X6 00285 , class X7 00286 , class X8 00287 > 00288 inline void debug(bool test 00289 ,const X1 & x1 00290 ,const X2 & x2 00291 ,const X3 & x3 00292 ,const X4 & x4 00293 ,const X5 & x5 00294 ,const X6 & x6 00295 ,const X7 & x7 00296 ,const X8 & x8 00297 ) 00298 { 00299 if ( _GEN_DEBUG_CODE && test ) 00300 { 00301 Dbg 00302 <<std::cerr 00303 << x1 00304 << x2 00305 << x3 00306 << x4 00307 << x5 00308 << x6 00309 << x7 00310 << x8 00311 << Dbg; 00312 } 00313 } 00314 00315 template<class X1 00316 , class X2 00317 , class X3 00318 , class X4 00319 , class X5 00320 , class X6 00321 , class X7 00322 , class X8 00323 , class X9 00324 > 00325 inline void debug(bool test 00326 ,const X1 & x1 00327 ,const X2 & x2 00328 ,const X3 & x3 00329 ,const X4 & x4 00330 ,const X5 & x5 00331 ,const X6 & x6 00332 ,const X7 & x7 00333 ,const X8 & x8 00334 ,const X9 & x9 00335 ) 00336 { 00337 if ( _GEN_DEBUG_CODE && test ) 00338 { 00339 Dbg 00340 <<std::cerr 00341 << x1 00342 << x2 00343 << x3 00344 << x4 00345 << x5 00346 << x6 00347 << x7 00348 << x8 00349 << x9 00350 << Dbg; 00351 } 00352 } 00353 00354 template<class X1 00355 , class X2 00356 , class X3 00357 , class X4 00358 , class X5 00359 , class X6 00360 , class X7 00361 , class X8 00362 , class X9 00363 , class X10 00364 > 00365 inline void debug(bool test 00366 ,const X1 & x1 00367 ,const X2 & x2 00368 ,const X3 & x3 00369 ,const X4 & x4 00370 ,const X5 & x5 00371 ,const X6 & x6 00372 ,const X7 & x7 00373 ,const X8 & x8 00374 ,const X9 & x9 00375 ,const X10 & x10 00376 ) 00377 { 00378 if ( _GEN_DEBUG_CODE && test ) 00379 { 00380 Dbg 00381 <<std::cerr 00382 << x1 00383 << x2 00384 << x3 00385 << x4 00386 << x5 00387 << x6 00388 << x7 00389 << x8 00390 << x9 00391 << x10 00392 << Dbg; 00393 } 00394 } 00395 00396 template<class X1 00397 , class X2 00398 , class X3 00399 , class X4 00400 , class X5 00401 , class X6 00402 , class X7 00403 , class X8 00404 , class X9 00405 , class X10 00406 , class X11 00407 > 00408 inline void debug(bool test 00409 ,const X1 & x1 00410 ,const X2 & x2 00411 ,const X3 & x3 00412 ,const X4 & x4 00413 ,const X5 & x5 00414 ,const X6 & x6 00415 ,const X7 & x7 00416 ,const X8 & x8 00417 ,const X9 & x9 00418 ,const X10 & x10 00419 ,const X11 & x11 00420 ) 00421 { 00422 if ( _GEN_DEBUG_CODE && test ) 00423 { 00424 Dbg 00425 <<std::cerr 00426 << x1 00427 << x2 00428 << x3 00429 << x4 00430 << x5 00431 << x6 00432 << x7 00433 << x8 00434 << x9 00435 << x10 00436 << x11 00437 << Dbg; 00438 } 00439 } 00440 00441 } 00442 00443 #endif