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

Last change on this file since 1689 was 1542, checked in by tbretz, 22 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
49// --------------------------------------------------------------------------
50//
51// Initializes name and title of the object. It is called by all
52// constructors.
53//
54void MPrint::Init(const char *name, const char *title)
55{
56 fName = name ? name : "MPrint";
57 fTitle = title ? title : "Task to print a parameter container";
58
59 fObject = NULL;
60}
61
62// --------------------------------------------------------------------------
63//
64// Constructor. Remembers the name to search for in the parameter list
65// of the object to be printed. The object must be derived from TObject and
66// TObject::Print(Option_t *) const
67// must be overloaded. You can also set an option string to use
68// when calling TObject::Print
69// If you want that the MPrint instance is removed from the tasklist
70// if the container to be printed is not found in the PreProcess, call:
71// MPrint::EnableSkip();
72//
73MPrint::MPrint(const char *obj, const char *option,
74 const char *name, const char *title)
75{
76 Init(name, title);
77 SetOption(option);
78
79 fObjName = obj;
80}
81
82// --------------------------------------------------------------------------
83//
84// Constructor. Remember the pointer of the object which has to be
85// printed. The object must be derived from TObject and
86// TObject::Print(Option_t *) const
87// must be overloaded. You can also set an option string to use
88// when calling TObject::Print
89// if the container to be printed is not found in the PreProcess, call:
90// MPrint::EnableSkip();
91//
92MPrint::MPrint(const TObject *obj, const char *option,
93 const char* name, const char *title)
94{
95 Init(name, title);
96 SetOption(option);
97
98 fObject = obj;
99 fObjName = obj->GetName();
100}
101
102// --------------------------------------------------------------------------
103//
104// Checks the parameter list for the existance of the parameter container. If
105// the name of it was given in the constructor.
106//
107Bool_t MPrint::PreProcess(MParList *pList)
108{
109 //
110 // The pointer is already given by the user.
111 //
112 if (fObject)
113 return kTRUE;
114
115 //
116 // Try to find the parameter container with the given name in the list
117 //
118 fObject = pList->FindObject(fObjName);
119 if (fObject)
120 return kTRUE;
121
122 //
123 // If it couldn't get found stop Eventloop
124 //
125 *fLog << err << dbginf << fObjName << " not found... ";
126 if (TestBit(kSKIP))
127 {
128 *fLog << "removing task from list." << endl;
129 return kSKIP;
130 }
131 else
132 {
133 *fLog << "aborting." << endl;
134 return kFALSE;
135 }
136}
137
138// --------------------------------------------------------------------------
139//
140// Calls overloaded TObject::Print
141//
142Bool_t MPrint::Process()
143{
144 fObject->Print(fOption);
145 return kTRUE;
146}
147
Note: See TracBrowser for help on using the repository browser.