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

Last change on this file since 1177 was 1080, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.5 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//
70MPrint::MPrint(const char *obj, const char *option,
71 const char *name, const char *title)
72{
73 Init(name, title);
74 SetOption(option);
75
76 fObjName = obj;
77}
78
79// --------------------------------------------------------------------------
80//
81// Constructor. Remember the pointer of the object which has to be
82// printed. The object must be derived from TObject and
83// TObject::Print(Option_t *) const
84// must be overloaded. You can also set an option string to use
85// when calling TObject::Print
86//
87MPrint::MPrint(const TObject *obj, const char *option,
88 const char* name, const char *title)
89{
90 Init(name, title);
91 SetOption(option);
92
93 fObject = obj;
94 fObjName = obj->GetName();
95}
96
97// --------------------------------------------------------------------------
98//
99// Checks the parameter list for the existance of the parameter container. If
100// the name of it was given in the constructor.
101//
102Bool_t MPrint::PreProcess(MParList *pList)
103{
104 //
105 // The pointer is already given by the user.
106 //
107 if (fObject)
108 return kTRUE;
109
110 //
111 // Try to find the parameter container with the given name in the list
112 //
113 fObject = pList->FindObject(fObjName);
114 if (fObject)
115 return kTRUE;
116
117 //
118 // If it couldn't get found stop Eventloop
119 //
120 *fLog << err << dbginf << fObjName << " not found... aborting." << endl;
121 return kFALSE;
122}
123
124// --------------------------------------------------------------------------
125//
126// Calls overloaded TObject::Print
127//
128Bool_t MPrint::Process()
129{
130 fObject->Print(fOption);
131 return kTRUE;
132}
133
Note: See TracBrowser for help on using the repository browser.