Changeset 2120 for trunk


Ignore:
Timestamp:
05/19/03 09:11:42 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2119 r2120  
    11                                                 -*-*- END OF LINE -*-*-
     2 2003/05/19: Thomas Bretz
     3
     4   * mbase/MEvtLoop.cc, mbase/MParList.cc, mbase/MTaskList.cc,
     5     mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc:
     6     - use new manipulator 'underline'
     7
     8   * mbase/MLog.cc:
     9     - added new underlining
     10     - added blue color for debugging
     11     
     12   * mbase/MLogManip.[h,cc]:
     13     - added underline
     14     - added dbg and increased all other debug(n) levels by one
     15     
     16   * mbase/MParContainer.h:
     17     - made fDisplay persistent (workaround for a obsolete warning in
     18       root 3.02/07)
     19
     20   * mfileio/MWriteRootFile.[h,cc]:
     21     - fixed a bug introduced when implementing UPDATE mode,
     22       kIsNewTree set for TTree
     23
     24
    225
    326 2003/05/16: Abelardo Moralejo
     
    629     - Added SetCoeff
    730
     31
     32
    833 2003/05/16: Thomas Bretz
     34
     35   * mfilter/MFEventSelector2.[h,cc]:
     36     - added
     37
     38   * mfilter/Makefile, mfilter/FilterLinkDef.h:
     39     - added MFEventSelector2
    940
    1041   * mbase/MContinue.cc:
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r2117 r2120  
    108108    fName = name;
    109109
    110     fLog->Underline();
    111     *fLog << inf << "Instantiated MEvtLoop (" << name << "), using ROOT v" << ROOTVER << endl;
     110    *fLog << inf << underline << "Instantiated MEvtLoop (" << name << "), using ROOT v" << ROOTVER << endl;
    112111}
    113112
  • trunk/MagicSoft/Mars/mbase/MLog.cc

    r2106 r2120  
    2525
    2626//////////////////////////////////////////////////////////////////////////////
    27 //                                                                          //
    28 // MLog                                                                     //
    29 //                                                                          //
    30 // This is what we call the logging-system.                                 //
    31 //                                                                          //
    32 // It is derived from the C++ streaming classes and can handle our          //
    33 // logging. The log output can be redirected to stdout, stderr, any other   //
    34 // stream or a root window.                                                 //
    35 //                                                                          //
    36 // There is a global log-instance which you can use like cout, id is gLog.  //
    37 // A log-instance of your choice (gLog by default) is destributed to all    //
    38 // Task which are used in an eventloop, so that you can redirect the output //
    39 // of one eventloop to where you want..                                     //
    40 //                                                                          //
    41 // The MLog stream has the advantage, that it can be used like the common   //
    42 // C++ streams (for example cout). It can redirect the stream to different  //
    43 // outputs (console, file, GUI) if necessary at the same time.              //
    44 //                                                                          //
    45 // It supports different debug levels. The debug level of the current       //
    46 // stream contents is set by SetDebugLevel, the output level of the         //
    47 // current stream can be set by SetOutputLevel.                             //
    48 //                                                                          //
    49 // The header file MLogManip.h contains so called manipulators (like flush  //
    50 // or setw from iomanip.h) which can manipulate these levels from within    //
    51 // stream, for example:                                                     //
    52 //    gLog << debug(3) << "Hallo World " << endl;                           //
    53 // sets the debug level of the following stream to 3                        //
    54 //                                                                          //
    55 // edev(), ddev() can be used to enable/disable an output device from       //
    56 // within the stream. The enumerations are defined in MLog::_flags          //
    57 //                                                                          //
    58 // Commonly used abbreviations are also defined:                            //
    59 //    dbginf  Prints source file name and line number. Used for output      //
    60 //            which people may like to look up in the code                  //
    61 //    all     Is streamed to the output in any case. Used for outputs       //
    62 //            which are requested by the user (eg TObject::Print)           //
    63 //    err     Should be used for fatal errors which stops the current       //
    64 //            processing, eg:                                               //
    65 //              gLog << err << "ERROR: TObject::Copy - Stopped" << endl;    //
    66 //    warn    Warning means an error occured, but it is not clear whether   //
    67 //            this results further procesing or not.                        //
    68 //    inf     Informs the user about what's going on. Mostly usefull for    //
    69 //            debugging, but in general not necessary at all.               //
    70 //                                                                          //
    71 // gLog is a global stream defined like cout or cerr                        //
    72 //                                                                          //
     27//
     28// MLog
     29//
     30// This is what we call the logging-system.
     31//
     32// It is derived from the C++ streaming classes and can handle our
     33// logging. The log output can be redirected to stdout, stderr, any other
     34// stream or a root window.
     35//
     36// There is a global log-instance which you can use like cout, id is gLog.
     37// A log-instance of your choice (gLog by default) is destributed to all
     38// Task which are used in an eventloop, so that you can redirect the output
     39// of one eventloop to where you want..
     40//
     41// The MLog stream has the advantage, that it can be used like the common
     42// C++ streams (for example cout). It can redirect the stream to different
     43// outputs (console, file, GUI) if necessary at the same time.
     44//
     45// It supports different debug levels. The debug level of the current
     46// stream contents is set by SetDebugLevel, the output level of the
     47// current stream can be set by SetOutputLevel.
     48//
     49// The header file MLogManip.h contains so called manipulators (like flush
     50// or setw from iomanip.h) which can manipulate these levels from within
     51// stream, for example:
     52//    gLog << debug(3) << "Hallo World " << endl;
     53// sets the debug level of the following stream to 3
     54//
     55// edev(), ddev() can be used to enable/disable an output device from
     56// within the stream. The enumerations are defined in MLog::_flags
     57//
     58// Commonly used abbreviations are also defined:
     59//    dbginf  Prints source file name and line number. Used for output
     60//            which people may like to look up in the code
     61//    all     Is streamed to the output in any case. Used for outputs
     62//            which are requested by the user (eg TObject::Print)
     63//    err     Should be used for fatal errors which stops the current
     64//            processing, eg:
     65//              gLog << err << "ERROR: TObject::Copy - Stopped" << endl;
     66//    warn    Warning means an error occured, but it is not clear whether
     67//            this results further procesing or not.
     68//    inf     Informs the user about what's going on. Mostly usefull for
     69//            debugging, but in general not necessary at all.
     70//    dbg     Use this for your private purpose to mark something as debug
     71//            output. This is _not_ ment to be persistent!
     72//
     73// If your console is capable of ANSI colors the stream is displayed
     74// in several colors:
     75//    all:    default
     76//    err:    red
     77//    warn:   yellow/brown
     78//    inf:    green
     79//    dbg:    blue (and all other levels)
     80//
     81// If you have a dark background on your console you might want to set
     82// an environment variable, eg:
     83//    export MARSDEFINES=-DHAVE_DARKBACKGROUND
     84// and recompile MLog.
     85//
     86// If your console can display it also 'underline' can be used. This
     87// underlines a text till the next 'endl', eg:
     88//    gLog << underline << "This is important!" << endl;
     89//
     90// To switch off ANSI support call: SetNoColors()
     91//
     92// gLog is a global stream defined like cout or cerr
     93//
    7394//////////////////////////////////////////////////////////////////////////////
    7495
     
    99120const char *const MLog::kYellow    = "\033[33m";
    100121#endif
     122const char *const MLog::kBlue      = "\033[34m";
    101123const char *const MLog::kUnderline = "\033[4m";;
    102124const char *const MLog::kBlink     = "\033[5m";;
     
    197219void MLog::Underline()
    198220{
     221    SetBit(kIsUnderlined);
     222
    199223    if (TestBit(eNoColors))
    200224        return;
     
    212236        switch (fOutputLevel)
    213237        {
    214         case 0:  out << MLog::kReset;   break;  // all // maybe not necessary?
     238            // do not output reset. Otherwise we reset underline in 0-mode
     239            // case 1: out << MLog::kReset; break; // all
     240        case 0:  break; // all = background color
    215241        case 1:  out << MLog::kRed;     break;  // err
    216242        case 2:  out << MLog::kYellow;  break;  // warn
    217243        case 3:  out << MLog::kGreen;   break;  // inf
     244        default: out << MLog::kBlue;    break;  // all others (dbg)
    218245        }
    219246
     
    221248    {
    222249        // Check for EOL
    223         const Bool_t endline = fBase[len-1]=='\n';
     250        const Int_t endline = fBase[len-1]=='\n' ? 1 : 0;
    224251        // output text to screen (without trailing '\n')
    225         out << TString(fBase, endline ? len-1 : len);
     252        out << TString(fBase, len-endline);
    226253        // reset colors if working with colors
    227254        if (!TestBit(eNoColors))
     
    229256        // output EOL of check found EOL
    230257        if (endline)
     258        {
    231259            out << '\n';
     260            // Check whether text was underlined
     261            if (TestBit(kIsUnderlined) && TestBit(eNoColors))
     262            {
     263                out << setw(len-1) << setfill('-') << "" << "\n";
     264                ResetBit(kIsUnderlined);
     265            }
     266        }
    232267    }
    233268    out.flush();
     269}
     270
     271void MLog::AddGuiLine(const TString &line)
     272{
     273    // add a new TString* to the array of gui lines
     274    TString **newstr = new TString*[fNumLines+1];
     275    memcpy(newstr, fGuiLines, fNumLines*sizeof(TString*));
     276    if (fNumLines>0)
     277        delete fGuiLines;
     278    fGuiLines = newstr;
     279
     280    // add Gui line as last line of array
     281    fGuiLines[fNumLines++] = new TString(line);
    234282}
    235283
     
    263311    {
    264312        // check whether the current text was flushed or endl'ed
    265         const Bool_t flushed = fBase[len-1]!='\n';
     313        const Int_t endline = fBase[len-1]=='\n' ? 1 : 0;
    266314
    267315        // for the gui remove trailing characters ('\n' or '\0')
    268         fBase[flushed ? len : len-1]='\0';
     316        fBase[len-endline]='\0';
    269317
    270318        // add new text to line storage
    271319        fGuiLine += fBase;
    272320
    273         if (!flushed)
     321        if (endline)
    274322        {
    275             // add a new TString* to the array of gui lines
    276             TString **newstr = new TString*[fNumLines+1];
    277             memcpy(newstr, fGuiLines, fNumLines*sizeof(TString*));
    278             if (fNumLines>0)
    279                 delete fGuiLines;
    280             fGuiLines = newstr;
    281 
    282             // add Gui line as last line of array
    283             fGuiLines[fNumLines++] = new TString(fGuiLine);
     323            AddGuiLine(fGuiLine);
    284324            fGuiLine = "";
     325
     326            // Check whether text should be underlined
     327            if (endline && TestBit(kIsUnderlined))
     328            {
     329                AddGuiLine("");
     330                fGuiLines[fNumLines-1]->Append('-', fGuiLines[fNumLines-2]->Length());
     331                ResetBit(kIsUnderlined);
     332            }
    285333        }
    286334    }
  • trunk/MagicSoft/Mars/mbase/MLogManip.cc

    r2100 r2120  
    107107}
    108108
     109ostream& underline(ostream& lout)
     110{
     111    //
     112    // get the streambuf of the stream
     113    // get the pointer to the parent class by casting
     114    // Disable an output device of the logging stream, it should
     115    // be possible to disable more than one output device at the
     116    // same time by oring them together
     117    //
     118    // Be careful: This manipulator can only be used in MLogging
     119    // streams - in other streams SetOutputLevel is a call
     120    // of a non existing function
     121    //
     122    MLog *log=(MLog*)lout.rdbuf();
     123    log->Underline();
     124    return lout;
     125}
     126
  • trunk/MagicSoft/Mars/mbase/MLogManip.h

    r1080 r2120  
    1111// define a general simple macro for manipulator definitions (int)
    1212//
     13#define MANIPULATOR0(name) \
     14   extern ostream& ##name(ostream& lout);
     15
    1316#ifndef OMANIP
    14 
    15 #define MANIPULATOR(name) \
    16     extern ostream& __omanip_##name(ostream& lout, int i); \
    17     inline omanip<int> ##name(int i)                \
    18     {                                               \
    19         return omanip<int>(__omanip_##name, i);    \
    20     }
     17   #define MANIPULATOR1(name) \
     18      extern ostream& __omanip_##name(ostream& lout, int i); \
     19      inline omanip<int> ##name(int i)                \
     20      {                                               \
     21         return omanip<int>(__omanip_##name, i);     \
     22      }
    2123
    2224#else
    23 
    24 #define MANIPULATOR(name) \
    25     extern ostream& __omanip_##name(ostream& lout, int i); \
    26     inline OMANIP(int) ##name(int i)                \
    27     {                                               \
    28         return OMANIP(int)(__omanip_##name, i);    \
    29     }
     25   #define MANIPULATOR1(name) \
     26       extern ostream& __omanip_##name(ostream& lout, int i); \
     27       inline OMANIP(int) ##name(int i)                \
     28       {                                               \
     29          return OMANIP(int)(__omanip_##name, i);      \
     30       }
    3031
    3132#endif
     33
    3234//
    3335// definitions
    3436//
    35 MANIPULATOR(debug);    // set debug level
    36 MANIPULATOR(device);   // set ouput devices
    37 MANIPULATOR(edev);     // enable additional output devices
    38 MANIPULATOR(ddev);     // disable given output
     37MANIPULATOR0(underline); // underline output
     38MANIPULATOR1(debug);     // set debug level
     39MANIPULATOR1(device);    // set ouput devices
     40MANIPULATOR1(edev);      // enable additional output devices
     41MANIPULATOR1(ddev);      // disable given output
    3942//#ifndef __CINT__
    4043//__DEFINE_IOMANIP_FN1(smanip, int, debug);    // set debug level
     
    5356//
    5457#ifndef __CINT__
    55 #define dbginf      __FILE__ << " l." << dec << __LINE__ << ": "
    56 #define all    debug(0)
    57 #define err    debug(1)
    58 #define warn   debug(2)
    59 #define inf    debug(3)
     58#define dbginf dbg << __FILE__ << " l." << dec << __LINE__ << ": "
     59#define all    debug(0) // use this for output in any case
     60#define err    debug(1) // use this for fatal errors (red)
     61#define warn   debug(2) // use this for wrnings (yellow)
     62#define inf    debug(3) // use this for informations (green)
     63#define dbg    debug(4) // use this for debug messages (blue)
    6064#endif
    6165//
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1965 r2120  
    3636    MLog   *fLog;         // The general log facility for this object, initialized with the global object
    3737
    38     MStatusDisplay *fDisplay;
     38    // This data member was added later, because for calculating the
     39    // Checksum root (3.02/07) ignores ClassDef=0 all data members
     40    // which are not persistent (//!) are used. To make the two
     41    // class versions CheckSum-compatible (only getting rid of a
     42    // warning) this member is persistent.
     43    MStatusDisplay *fDisplay; //!
    3944
    4045private:
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r2052 r2120  
    503503void MParList::Print(Option_t *t) const
    504504{
    505     *fLog << all << " " << GetDescriptor() << endl;
    506     *fLog << setfill('-') << setw(strlen(GetDescriptor())+2) << "" << endl;
     505    *fLog << all << underline << GetDescriptor() << ":" << endl;
    507506
    508507    MParContainer *obj = NULL;
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r2117 r2120  
    549549    if (lvl==0)
    550550    {
    551         *fLog << all << endl;
    552         *fLog << "Execution Statistics: " << endl;
    553         *fLog << "---------------------" << endl;
     551        *fLog << all << underline << "Execution Statistics:" << endl;
    554552        *fLog << GetDescriptor();
    555553        if (GetFilter())
     
    580578void MTaskList::Print(Option_t *t) const
    581579{
    582     *fLog << all << endl;
    583     *fLog << GetDescriptor() << endl;
    584     *fLog << setfill('-') << setw(strlen(GetDescriptor())) << "" << endl;
     580    *fLog << all << underline << GetDescriptor() << ":" << endl;
    585581
    586582    fTasks->Print();
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r2117 r2120  
    895895void MReadTree::Print(Option_t *o) const
    896896{
    897     *fLog << all << GetDescriptor() << dec << endl;
    898     *fLog << setfill('-') << setw(strlen(GetDescriptor())) << "" << endl;
     897    *fLog << all << underline << GetDescriptor() << ":" << endl << dec;
    899898    *fLog << " Files [Tree]:" << endl;
    900899
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r2002 r2120  
    140140void MWriteRootFile::Print(Option_t *) const
    141141{
    142     *fLog << all << " File: " << GetFileName() << endl;
    143     *fLog << setfill('-') << setw(strlen(GetFileName())+8) << "" << endl;
    144     *fLog << setfill(' '); // FIXME: not resetting setfill results in strange output???
     142    *fLog << all << underline << "File: " << GetFileName() << ":" << endl;
    145143
    146144    TTree *t = NULL;
     
    278276            // tree as a branch created by MWriteRootFile
    279277            //
    280             entry->SetBit(kIsNewTree);
     278            tree->SetBit(kIsNewTree);
    281279
    282280            gDirectory = save;
     
    358356void MWriteRootFile::CheckAndWrite() const
    359357{
    360     const Int_t kFillTree = BIT(14);
    361 
    362358    TObject *obj;
    363359
     
    380376        // the corresponding tree entry.
    381377        //
    382         if (b->TestBit(kIsNewTree))
     378        if (b->GetTree()->TestBit(kIsNewTree))
    383379            b->GetTree()->SetBit(kFillTree);
    384380        else
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h

    r2002 r2120  
    8181
    8282    enum {
     83        kFillTree  = BIT(14),
    8384        kIsNewTree = BIT(15)
    8485    };
Note: See TracChangeset for help on using the changeset viewer.