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

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