1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/* -*- c++ -*-
*
* Copyright (c) 2001-2003 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 1998-2001 University of Notre Dame.
* All rights reserved.
* Copyright (c) 1994-1998 The Ohio State University.
* All rights reserved.
*
* This file is part of the LAM/MPI software package. For license
* information, see the LICENSE file in the top level directory of the
* LAM/MPI source distribution.
*
* $HEADER$
*
* $Id: lamdebug-cc.h,v 6.3 2003/02/04 17:53:09 jsquyres Exp $
*
* Function: - IMPI client daemon header file for C++ functions
*/
#ifndef _LAM_DEBUG_CC_H_
#define _LAM_DEBUG_CC_H_
#ifndef __cplusplus
Error: This should only be included by C++ source files
#endif
#include <iostream>
//
// Brings printf debugging to a new low
//
class Debug {
public:
inline Debug(bool initial = false) : on(initial) {}
inline void On() { on = true; }
inline void Off() { on = false; }
inline bool isOn() { return on; };
protected:
bool on;
};
//
// A sick and wrong templated debug function
//
template <class T>
inline Debug&
operator<<(Debug& d, const T& x) {
if (d.isOn())
std::cerr << x;
return d;
}
//
// These need to be here for the endl on some compilers
//
inline Debug&
operator<< (Debug& d, std::ostream& (*_f)(std::ostream&))
{
if (d.isOn())
std::cerr << std::endl;
return d;
}
inline Debug&
operator<< (Debug& d, std::ios& (*_f)(std::ios&))
{
if (d.isOn())
std::cerr << std::endl;
return d;
}
#endif
|