source: trunk/MagicSoft/Mars/mfileio/MWriteFile.cc@ 2620

Last change on this file since 2620 was 2206, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.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, 6/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MWriteFile //
28// //
29// This is a base class for writing tasks. If you want to implement //
30// writing out parameter containers in a new file format, this is a good //
31// starting point. //
32// The class defines a generalized interface between writing out data in //
33// an eventloop and your file format. //
34// //
35/////////////////////////////////////////////////////////////////////////////
36
37#include "MWriteFile.h"
38
39#include <fstream>
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44#include "MParList.h"
45
46ClassImp(MWriteFile);
47
48using namespace std;
49
50// --------------------------------------------------------------------------
51//
52// Tries to open the given output file.
53// The derived class should retrieve needed containers from the parameter
54// list.
55// instance of the container which should be written.
56// If the container has already the HasChanged flag it is immediatly written
57// to the output file.
58//
59Int_t MWriteFile::PreProcess(MParList *pList)
60{
61 //
62 // test whether file is now open or not
63 //
64 if (!IsFileOpen())
65 {
66 *fLog << err << dbginf << "Cannot open file '" << GetFileName() << "'" << endl;
67 return kFALSE;
68 }
69
70 *fLog << inf << "File '" << GetFileName() << "' open for writing." << endl;
71
72 //
73 // Get the containers (pointers) from the parameter list you want to write
74 //
75 if (!GetContainer(pList))
76 return kFALSE;
77
78 //
79 // write the container if it is already in changed state
80 //
81 CheckAndWrite();
82
83 return kTRUE;
84}
85
86// --------------------------------------------------------------------------
87//
88// Checks if the HasChanged flag of the output container is set. If it is set
89// the container should be written to the output.
90//
91Int_t MWriteFile::Process()
92{
93 CheckAndWrite();
94 return kTRUE;
95}
96
97// --------------------------------------------------------------------------
98//
99// Checks if the HasChanged flag of the output container is set. If it is set
100// the container should be written to the output.
101//
102Int_t MWriteFile::PostProcess()
103{
104 //
105 // check if the container changed state is set
106 //
107 CheckAndWrite();
108 return kTRUE;
109}
110
Note: See TracBrowser for help on using the repository browser.