#ifndef MARS_MLogManip
#define MARS_MLogManip

#include <iomanip.h>

// ----------------------------------------------------------------
//                 Definitions of the manipulators
// ----------------------------------------------------------------

//
// define a general simple macro for manipulator definitions (int)
//
#ifndef OMANIP

#define MANIPULATOR(name) \
    extern ostream& __omanip_##name(ostream& lout, int i); \
    inline omanip<int> ##name(int i)                \
    {                                               \
        return omanip<int>(__omanip_##name, i);    \
    }

#else

#define MANIPULATOR(name) \
    extern ostream& __omanip_##name(ostream& lout, int i); \
    inline OMANIP(int) ##name(int i)                \
    {                                               \
        return OMANIP(int)(__omanip_##name, i);    \
    }

#endif
//
// definitions
//
MANIPULATOR(debug);    // set debug level
MANIPULATOR(device);   // set ouput devices
MANIPULATOR(edev);     // enable additional output devices
MANIPULATOR(ddev);     // disable given output
//#ifndef __CINT__
//__DEFINE_IOMANIP_FN1(smanip, int, debug);    // set debug level
//__DEFINE_IOMANIP_FN1(smanip, int, device);   // set ouput devices
//__DEFINE_IOMANIP_FN1(smanip, int, edev);     // enable additional output devices
//__DEFINE_IOMANIP_FN1(smanip, int, ddev);     // disable given output
//#endif

// ----------------------------------------------------------------
//                         Debug helper macros
// ----------------------------------------------------------------

//
// Output debug information into the stream
//  - this can only be done by a macro
//
#ifndef __CINT__
#define dbginf      __FILE__ << " l." << dec << __LINE__ << ": "
#define all    debug(0)
#define err    debug(1)
#define warn   debug(2)
#define inf    debug(3)
#endif
//
// flush the old buffer, set a new debug level
// and output the debug information code
//
// Be careful: Only use them with a MLogging stream facility.
// Remark:     All this is compiled into the code.
//
/*
#ifndef __CINT__
#define DEBUG(lvl)  flush << debug(lvl) << dbginf
#endif
*/
/*
class SMANIP(T) {
    ios& (*fct)(ios&,T) ;
    T arg ;
public:
    SMANIP(T)(ios& (*f)(ios&, T), T a) :
        fct(f), arg(a) { }
        friend istream& operator>>(istream& i, const SMANIP(T)& m)
        {
            ios* s = &i ;
            (*m.fct)(*s,m.arg) ; return i ;
        }
        friend ostream& operator<<(ostream& o, const SMANIP(T)& m)
        {
            ios* s = &o ;
            (*m.fct)(*s,m.arg) ; return o ;
        }
} ;
*/

#endif
