// @(#)root/proof:$Id: TProofQueryResult.cxx 34755 2010-08-10 10:47:41Z rdm $
// Author: G Ganis Sep 2005

/*************************************************************************
 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TProofQueryResult                                                    //
//                                                                      //
// TQueryResult version adapted to PROOF neeeds.                        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TDSet.h"
#include "TError.h"
#include "TList.h"
#include "TProofQueryResult.h"
#include "TSystem.h"


ClassImp(TProofQueryResult)

//______________________________________________________________________________
TProofQueryResult::TProofQueryResult(Int_t sn, const char *opt, TList *inlist,
                                     Long64_t ent, Long64_t fst, TDSet *dset,
                                     const char *sel, TObject *elist)
                  : TQueryResult(sn, opt, inlist, ent, fst, sel)
{
   // Main constructor.

   fNumWrks = -1;
   fStartLog = -1;

   // Add data sets and event lists to the input list
   if (fInputList && dset)
      fInputList->Add(dset);
   if (fInputList && elist)
      fInputList->Add(elist);
}

//______________________________________________________________________________
void TProofQueryResult::SetRunning(Int_t startlog, const char *par, Int_t nwrks)
{
   // Call when running starts.

   Info("SetRunning", "nwrks: %d", nwrks);

   fStatus = kRunning;
   fNumWrks = nwrks;
   fStart.Set();
   fEnd.Set(fStart.Convert()-1);
   fParList = (par && (strlen(par) > 0)) ? par : "-";
   fStartLog = startlog;

   // Add header to log file
   fLogFile->AddLine("+++");
   fLogFile->AddLine(Form("+++ Start processing query # %d (log file offset: %d)",
                     fSeqNum, startlog));
   fLogFile->AddLine("+++");
}
