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 |
|
---|
47 | ClassImp(MReportHelp);
|
---|
48 |
|
---|
49 | using 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 | //
|
---|
58 | MReportHelp::MReportHelp(const char *name, MLog *fLog) : fReport(NULL), fNumReports(0), fNumSkipped(0)
|
---|
59 | {
|
---|
60 | TClass *cls = gROOT->GetClass(name);
|
---|
61 | Int_t rc = 0;
|
---|
62 | if (!cls)
|
---|
63 | rc =1;
|
---|
64 | else
|
---|
65 | {
|
---|
66 | if (!cls->Property())
|
---|
67 | rc = 5;
|
---|
68 | if (!cls->Size())
|
---|
69 | rc = 4;
|
---|
70 | if (!cls->IsLoaded())
|
---|
71 | rc = 3;
|
---|
72 | if (!cls->HasDefaultConstructor())
|
---|
73 | rc = 2;
|
---|
74 | }
|
---|
75 |
|
---|
76 | if (rc)
|
---|
77 | {
|
---|
78 | *fLog << err << dbginf << "Cannot create new instance of class '" << name << "': ";
|
---|
79 | switch (rc)
|
---|
80 | {
|
---|
81 | case 1:
|
---|
82 | *fLog << "gROOT->GetClass() returned NULL." << endl;
|
---|
83 | return;
|
---|
84 | case 2:
|
---|
85 | *fLog << "no default constructor." << endl;
|
---|
86 | return;
|
---|
87 | case 3:
|
---|
88 | *fLog << "not loaded." << endl;
|
---|
89 | return;
|
---|
90 | case 4:
|
---|
91 | *fLog << "zero size." << endl;
|
---|
92 | return;
|
---|
93 | case 5:
|
---|
94 | *fLog << "no property." << endl;
|
---|
95 | return;
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | //
|
---|
100 | // create the parameter container of the the given class type
|
---|
101 | //
|
---|
102 | fReport = (MReport*)cls->New();
|
---|
103 | }
|
---|
104 |
|
---|
105 | // --------------------------------------------------------------------------
|
---|
106 | //
|
---|
107 | // The instance of the MReport-class is deleted
|
---|
108 | //
|
---|
109 | MReportHelp::~MReportHelp()
|
---|
110 | {
|
---|
111 | if (fReport)
|
---|
112 | delete fReport;
|
---|
113 | }
|
---|
114 |
|
---|
115 | // --------------------------------------------------------------------------
|
---|
116 | //
|
---|
117 | // Return the Identifier ("DRIVE-REPORT") as name. This allows
|
---|
118 | // calling FindObject("[identifier]") in lists.
|
---|
119 | //
|
---|
120 | const char *MReportHelp::GetName() const
|
---|
121 | {
|
---|
122 | return fReport->GetIdentifier();
|
---|
123 | }
|
---|
124 |
|
---|
125 | // --------------------------------------------------------------------------
|
---|
126 | //
|
---|
127 | // Return the Identifier ("DRIVE-REPORT") hash value as hash value. This
|
---|
128 | // allows faster access b usage of a THashTable
|
---|
129 | //
|
---|
130 | ULong_t MReportHelp::Hash() const
|
---|
131 | {
|
---|
132 | return fReport->GetIdentifier().Hash();
|
---|
133 | }
|
---|
134 |
|
---|
135 | // --------------------------------------------------------------------------
|
---|
136 | //
|
---|
137 | // Calls the Interprete function of the report and counts the number of
|
---|
138 | // successfull interpretations.
|
---|
139 | //
|
---|
140 | Int_t MReportHelp::Interprete(TString &str, const MTime &start, const MTime &stop)
|
---|
141 | {
|
---|
142 | const Int_t rc = fReport->Interprete(str, start, stop);
|
---|
143 |
|
---|
144 | switch (rc)
|
---|
145 | {
|
---|
146 | case kTRUE: fNumReports++; break;
|
---|
147 | case kCONTINUE: fNumSkipped++; break;
|
---|
148 | }
|
---|
149 | return rc;
|
---|
150 | }
|
---|
151 |
|
---|
152 | // --------------------------------------------------------------------------
|
---|
153 | //
|
---|
154 | // Calls the Setip function for reading of the report
|
---|
155 | //
|
---|
156 | Bool_t MReportHelp::SetupReading(MParList &plist)
|
---|
157 | {
|
---|
158 | return fReport->SetupReading(plist);
|
---|
159 | }
|
---|
160 |
|
---|
161 | // --------------------------------------------------------------------------
|
---|
162 | //
|
---|
163 | // Add the report to the given parameter list.
|
---|
164 | //
|
---|
165 | void MReportHelp::AddToList(MParList &plist)
|
---|
166 | {
|
---|
167 | plist.AddToList(fReport);
|
---|
168 | }
|
---|