Exceptions and Message handling in/with ROOT

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Thu Jan 27 2000 - 17:30:20 MET


Hi ROOT'ers, 

Thomas Hadig raised the question on a `Message handling' class in
ROOT, which I think is a good idea! 

This proposal got me thinking, and inspired me to propose something my
self: ABC `TException'. I know exception handling isn't all that good
in Cint, but it should work fine in compiled code. You can get a
suggestion for such a class, and some children, at:

   http://www.nbi.dk/~cholm/Downloads 

Look for heading "Other Downloads" and "TException class for ROOT". 

Feed-back is more then welcome. I'm afriad the i've only created a
Makefile for Linux - sorry. 

And some comments on Thomas Hadigs proposal:
From: Thomas Hadig <hadig@toots.physik.rwth-aachen.de>
> Dear Rooters,
> 
> I learned from Rene, that several users/collaborations are thinking
> about a "global" ROOT messaging system. I have come up with a simple
> idea and would like know your opinion.
>
> ...
> 
> Examples:
> 
> ofstream *errout = new ofstream("outputfile");
> TMessageHandler *h = new TMessageHandler (errout);
> int e1 = h->Register("Negative cluster energy", kMessageWarning);
> int e2 = h->Register("Cell number out of range : ", kMessageError);
> h->Suppress(kMessageDebug);
> TROOT->SetMessageHandler(h);
> 
> ...
> TROOT->SendMessage("Entering cluster routine",kMessageDebug);
>     { will print nothing, because kMessageDebug messages are suppressed }
> ...
> TROOT->SendMessage(e1);
>     { will print : Error: Negative cluster energy }
> ...
> char buffer[200]; sprintf (buffer,"%d",num);
> TROOT->SendMessage(e2,buffer);
>     { will print : Error: Cell number out of range : 100 }
> ...
> h->PrintStatistics();
>     { will print : #of occurences Error
>                    10   Negative cluster energy
>                    2    Cell number out of range : }

Couldn't `TMessageHandler' inherit from `strstream' or something, so
that you can put-to the object like 

     h << "Foo is an error of Bar, see Baz" ;

and on the other end, do
    
    Char_t *gnat
    h >> gnat;

or something similar? 

In the same line of thoughts, my TException sould also have an
"operator<<", but that would be wrong (look at how the excpetion is
thrown!). 

Cheers, 

Christian Holm Christensen 
______________________________________________________________________
Address:                                     Phone:  (+45) 35 35 96 91 
  Sankt Hansgade 23, 1. th.                  Office: (+45) 353  25 307 
  DK-2200 Copenhagen N                       Web:    www.nbi.dk/~cholm    
  Denmark                                    Email:       cholm@nbi.dk



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET