source: branches/removing_cpp11_features/mfileio/MWriteFile.cc@ 19861

Last change on this file since 19861 was 17534, checked in by tbretz, 11 years ago
Removed CheckAndWrite from PreProcess, because it is done anyway in ReInit. This can lead to double write.
File size: 3.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, 6/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
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#include "MWriteFile.h"
37
38#include <fstream>
39
40#include "MLog.h"
41#include "MLogManip.h"
42
43#include "MParList.h"
44
45ClassImp(MWriteFile);
46
47using namespace std;
48
49// --------------------------------------------------------------------------
50//
51// Tries to open the given output file.
52// The derived class should retrieve needed containers from the parameter
53// list.
54// instance of the container which should be written.
55// If the container has already the HasChanged flag it is immediatly written
56// to the output file.
57//
58Int_t MWriteFile::PreProcess(MParList *pList)
59{
60 //
61 // test whether file is now open or not
62 //
63 if (!IsFileOpen())
64 {
65 *fLog << err << dbginf << "Cannot open file '" << GetFileName() << "'" << endl;
66 return kFALSE;
67 }
68
69 *fLog << inf << "File '" << GetFileName() << "' open for writing." << endl;
70
71 //
72 // Get the containers (pointers) from the parameter list you want to write
73 //
74 return GetContainer(pList);
75 /*
76 if (!GetContainer(pList))
77 return kFALSE;
78
79 //
80 // write the container if it is already in changed state
81 //
82 return CheckAndWrite();
83 */
84}
85
86// --------------------------------------------------------------------------
87//
88// Checks if the SetReadyToSave flag of the output container is set. If it
89// is set the container should be written to the output.
90//
91Bool_t MWriteFile::ReInit(MParList *pList)
92{
93 return CheckAndWrite();
94}
95
96// --------------------------------------------------------------------------
97//
98// Checks if the SetReadyToSave flag of the output container is set. If it is
99// set the container should be written to the output.
100//
101Int_t MWriteFile::Process()
102{
103 return CheckAndWrite();
104}
105
106// --------------------------------------------------------------------------
107//
108// Checks if the SetReadyToSave flag of the output container is set. If it is
109// set the container should be written to the output.
110//
111Int_t MWriteFile::PostProcess()
112{
113 //
114 // check if the container changed state is set
115 //
116 return CheckAndWrite();
117}
Note: See TracBrowser for help on using the repository browser.