TStatus.cxx

Go to the documentation of this file.
00001 // @(#)root/proofplayer:$Id: TStatus.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Maarten Ballintijn   7/06/2004
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TStatus                                                              //
00015 //                                                                      //
00016 // This class holds the status of an ongoing operation and collects     //
00017 // error messages. It provides a Merge() operation allowing it to       //
00018 // be used in PROOF to monitor status in the slaves.                    //
00019 // No messages indicates success.                                       //
00020 //                                                                      //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #include "TStatus.h"
00024 #include "Riostream.h"
00025 #include "TClass.h"
00026 #include "TList.h"
00027 
00028 
00029 ClassImp(TStatus)
00030 
00031 //______________________________________________________________________________
00032 TStatus::TStatus()
00033 {
00034    // Deafult constructor.
00035 
00036    SetName("PROOF_Status");
00037    fIter = fMsgs.begin();
00038 }
00039 
00040 //______________________________________________________________________________
00041 void TStatus::Add(const char *mesg)
00042 {
00043    // Add an error message.
00044 
00045    fMsgs.insert(mesg);
00046    Reset();
00047 }
00048 
00049 //______________________________________________________________________________
00050 Int_t TStatus::Merge(TCollection *li)
00051 {
00052    // PROOF Merge() function.
00053 
00054    TIter stats(li);
00055    while (TObject *obj = stats()) {
00056       TStatus *s = dynamic_cast<TStatus*>(obj);
00057       if (s == 0) continue;
00058 
00059       MsgIter_t i = s->fMsgs.begin();
00060       MsgIter_t end = s->fMsgs.end();
00061       for (; i != end; i++)
00062          Add(i->c_str());
00063    }
00064 
00065    return fMsgs.size();
00066 }
00067 
00068 //______________________________________________________________________________
00069 void TStatus::Print(Option_t * /*option*/) const
00070 {
00071    // Standard print function.
00072 
00073    cout <<"OBJ: " << IsA()->GetName() << "\t" << GetName()
00074         << "\t" << (IsOk() ? "OK" : "ERROR") << endl;
00075 
00076    MsgIter_t i = fMsgs.begin();
00077    for (; i != fMsgs.end(); i++)
00078       cout << "\t" << *i << endl;
00079 }
00080 
00081 //______________________________________________________________________________
00082 void TStatus::Reset()
00083 {
00084    // Reset the iterator on the messages.
00085 
00086    fIter = fMsgs.begin();
00087 }
00088 
00089 //______________________________________________________________________________
00090 const char *TStatus::NextMesg()
00091 {
00092    // Return the next message or 0.
00093 
00094    if (fIter != fMsgs.end()) {
00095       return (*fIter++).c_str();
00096    } else {
00097       return 0;
00098    }
00099 }
00100 
00101 

Generated on Tue Jul 5 14:52:20 2011 for ROOT_528-00b_version by  doxygen 1.5.1