/* ======================================================================== *\
!
! *
! * This file is part of MARS, the MAGIC Analysis and Reconstruction
! * Software. It is distributed to you in the hope that it can be a useful
! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
! * It is distributed WITHOUT ANY WARRANTY.
! *
! * Permission to use, copy, modify and distribute this software and its
! * documentation for any purpose is hereby granted without fee,
! * provided that the above copyright notice appear in all copies and
! * that both that copyright notice and this permission notice appear
! * in supporting documentation. It is provided "as is" without express
! * or implied warranty.
! *
!
!
!   Author(s): Thomas Bretz, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
!
!   Copyright: MAGIC Software Development, 2000-2003
!
!
\* ======================================================================== */

//////////////////////////////////////////////////////////////////////////////
//
//  MReportRun
//
// This is the class interpreting and storing the RUN-REPORT information.
//
// PRELIMINARY!
//
//////////////////////////////////////////////////////////////////////////////
#include "MReportRun.h"

#include "MLogManip.h"

#include "MAstro.h"

ClassImp(MReportRun);

using namespace std;

// --------------------------------------------------------------------------
//
// Default construtor. Initialize identifier to "RUN-REPORT" No subsystem
// is expected.
//
MReportRun::MReportRun() : MReport("RUN-REPORT", kFALSE), fRunNumber(0)
{
    fName  = "MReportRun";
    fTitle = "Class for RUN-REPORT information";
}

// --------------------------------------------------------------------------
//
// Interprete the body of the RUN-REPORT string
//
Int_t MReportRun::InterpreteBody(TString &str)
{
    Int_t len;
    const Int_t n=sscanf(str.Data(), "%d %n", &fRunNumber, &len);
    if (n!=1)
    {
        *fLog << warn << "WARNING - Wrong number of arguments." << endl;
        return kCONTINUE;
    }
    str.Remove(0, len);

    if (str.BeginsWith("END"))
        fRunNumber = -1;

    str.Remove(0, 6);
    str = str.Strip(TString::kBoth);
    Ssiz_t pos = str.First(' ');
    if (pos<0)
        pos = str.Length();
    fSourceName = str(0, pos+1);

    return kTRUE;
}
