source: trunk/MagicSoft/Mars/mbase/MPrint.cc@ 2386

Last change on this file since 2386 was 2220, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.9 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 10/2001 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26// //
27// MPrint //
28// //
29// This task calls the Print() function of a parameter container, to //
30// print some information event by event. //
31// Overload TObject::Print() //
32// //
33// Input Containers: //
34// MParContainer //
35// //
36// Output Containers: //
37// -/- //
38// //
39//////////////////////////////////////////////////////////////////////////////
40#include "MPrint.h"
41
42#include "MLog.h"
43#include "MLogManip.h"
44
45#include "MParList.h"
46
47ClassImp(MPrint);
48
49using namespace std;
50
51// --------------------------------------------------------------------------
52//
53// Initializes name and title of the object. It is called by all
54// constructors.
55//
56void MPrint::Init(const char *name, const char *title)
57{
58 fName = name ? name : "MPrint";
59 fTitle = title ? title : "Task to print a parameter container";
60
61 fObject = NULL;
62}
63
64// --------------------------------------------------------------------------
65//
66// Constructor. Remembers the name to search for in the parameter list
67// of the object to be printed. The object must be derived from TObject and
68// TObject::Print(Option_t *) const
69// must be overloaded. You can also set an option string to use
70// when calling TObject::Print
71// If you want that the MPrint instance is removed from the tasklist
72// if the container to be printed is not found in the PreProcess, call:
73// MPrint::EnableSkip();
74//
75MPrint::MPrint(const char *obj, const char *option,
76 const char *name, const char *title)
77{
78 Init(name, title);
79 SetOption(option);
80
81 fObjName = obj;
82}
83
84// --------------------------------------------------------------------------
85//
86// Constructor. Remember the pointer of the object which has to be
87// printed. The object must be derived from TObject and
88// TObject::Print(Option_t *) const
89// must be overloaded. You can also set an option string to use
90// when calling TObject::Print
91// if the container to be printed is not found in the PreProcess, call:
92// MPrint::EnableSkip();
93//
94MPrint::MPrint(const TObject *obj, const char *option,
95 const char* name, const char *title)
96{
97 Init(name, title);
98 SetOption(option);
99
100 fObject = obj;
101 fObjName = obj->GetName();
102}
103
104// --------------------------------------------------------------------------
105//
106// Checks the parameter list for the existance of the parameter container. If
107// the name of it was given in the constructor.
108//
109Int_t MPrint::PreProcess(MParList *pList)
110{
111 //
112 // The pointer is already given by the user.
113 //
114 if (fObject)
115 return kTRUE;
116
117 //
118 // Try to find the parameter container with the given name in the list
119 //
120 fObject = pList->FindObject(fObjName);
121 if (fObject)
122 return kTRUE;
123
124 //
125 // If it couldn't get found stop Eventloop
126 //
127 *fLog << err << dbginf << fObjName << " not found... ";
128 if (TestBit(kSkip))
129 {
130 *fLog << "removing task from list." << endl;
131 return kSKIP;
132 }
133 else
134 {
135 *fLog << "aborting." << endl;
136 return kFALSE;
137 }
138}
139
140// --------------------------------------------------------------------------
141//
142// Calls overloaded TObject::Print
143//
144Int_t MPrint::Process()
145{
146 fObject->Print(fOption);
147 return kTRUE;
148}
149
Note: See TracBrowser for help on using the repository browser.