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

Last change on this file since 1003 was 1003, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.4 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 (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}
95
96// --------------------------------------------------------------------------
97//
98// Checks the parameter list for the existance of the parameter container. If
99// the name of it was given in the constructor.
100//
101Bool_t MPrint::PreProcess(MParList *pList)
102{
103 //
104 // The pointer is already given by the user.
105 //
106 if (fObject)
107 return kTRUE;
108
109 //
110 // Try to find the parameter container with the given name in the list
111 //
112 fObject = pList->FindObject(fObjName);
113 if (fObject)
114 return kTRUE;
115
116 //
117 // If it couldn't get found stop Eventloop
118 //
119 *fLog << dbginf << fObjName << " not found... aborting." << endl;
120 return kFALSE;
121}
122
123// --------------------------------------------------------------------------
124//
125// Calls overloaded TObject::Print
126//
127Bool_t MPrint::Process()
128{
129 fObject->Print(fOption);
130 return kTRUE;
131}
132
Note: See TracBrowser for help on using the repository browser.