source: branches/Corsika7405Compatibility/mreport/MReportHelp.cc@ 18227

Last change on this file since 18227 was 9026, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.0 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MReportHelp
28//
29// This is a wrapper class for MReport derived files. It provides root-like
30// access to the identifier of the report, such that this identifiers can
31// be used in hast tables to be able to speed up access to the class
32// corresponding to a report identifier. It also provides access to the
33// class by the name of the identifier.
34//
35//////////////////////////////////////////////////////////////////////////////
36#include "MReportHelp.h"
37
38#include <TROOT.h> // gROOT->GeClass
39#include <TClass.h> // TClass
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44#include "MReport.h"
45#include "MParList.h"
46
47ClassImp(MReportHelp);
48
49using namespace std;
50
51// --------------------------------------------------------------------------
52//
53// Construtor. Takes the name of the MReport-class (eg MReportDrive) and
54// a log-stream as an argument. The log-stream is used for output in the
55// constructor An instance of the MReport-class is created using its
56// default constructor.
57//
58MReportHelp::MReportHelp(const char *name, MLog *fLog) : fReport(NULL), fNumReports(0), fNumSkipped(0)
59{
60 //
61 // create the parameter container of the the given class type
62 //
63 *fLog << err;
64 TClass *cls = MParList::GetClass(name, fLog);
65
66 if (cls && cls->InheritsFrom(MReport::Class()))
67 fReport = static_cast<MReport*>(cls->New());
68}
69
70// --------------------------------------------------------------------------
71//
72// The instance of the MReport-class is deleted
73//
74MReportHelp::~MReportHelp()
75{
76 if (fReport)
77 delete fReport;
78}
79
80// --------------------------------------------------------------------------
81//
82// Return the Identifier ("DRIVE-REPORT") as name. This allows
83// calling FindObject("[identifier]") in lists.
84//
85const char *MReportHelp::GetName() const
86{
87 return fReport->GetIdentifier();
88}
89
90// --------------------------------------------------------------------------
91//
92// Return the Identifier ("DRIVE-REPORT") hash value as hash value. This
93// allows faster access b usage of a THashTable
94//
95ULong_t MReportHelp::Hash() const
96{
97 return fReport->GetIdentifier().Hash();
98}
99
100// --------------------------------------------------------------------------
101//
102// Calls the Interprete function of the report and counts the number of
103// successfull interpretations.
104//
105Int_t MReportHelp::Interprete(TString &str, const MTime &start, const MTime &stop, Int_t ver)
106{
107 const Int_t rc = fReport->Interprete(str, start, stop, ver);
108
109 switch (rc)
110 {
111 case kTRUE: fNumReports++; break;
112 case kCONTINUE: fNumSkipped++; break;
113 }
114 return rc;
115}
116
117// --------------------------------------------------------------------------
118//
119// Calls the Setip function for reading of the report
120//
121Bool_t MReportHelp::SetupReading(MParList &plist)
122{
123 return fReport->SetupReading(plist);
124}
125
126// --------------------------------------------------------------------------
127//
128// Add the report to the given parameter list.
129//
130void MReportHelp::AddToList(MParList &plist)
131{
132 plist.AddToList(fReport);
133}
Note: See TracBrowser for help on using the repository browser.