Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 843)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 844)
@@ -1,3 +1,47 @@
                                                                   -*-*- END -*-*-
+
+ 2001/06/12: Thomas Bretz
+ 
+   * mbase/MWriteAsciiFile.[h,cc]: 
+     - added
+
+   * manalysis/MCT1ReadAscii.h: 
+     - removed fFileName from class definition
+ 
+   * manalysis/MCerPhotCalc.cc: 
+     - use of SetHasChanged added
+ 
+   * manalysis/MHillas.[h,cc]: 
+     - Reset added
+     - AsciiRead added
+     - AsciiWrite added
+     - use of SetHasChanged added
+
+   * mbase/BaseLinkDef.h
+     - MWriteAsciiFile added
+   
+   * mbase/MEvtLoop.cc:
+     - some small changes to the logging output
+   
+   * mbase/MParContainer.cc:
+     - fHasChanged added 
+   
+   * mbase/MParContainer.h:
+     - Reset prototype added
+     - HasChanged added
+     - SetHasChanged added
+   
+   * mbase/MParList.[cc,h]:
+     - SetHasChanged added
+     - Reset added
+   
+   * mbase/MTaskList.cc:
+     - Process: call SetHasChanged before looping
+     - Process: call Reset before looping
+   
+   * mbase/MTaskList.h:
+     - fParList added to class definition
+
+
 
  2001/04/27: Thomas Bretz
Index: /trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc	(revision 844)
+++ /trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc	(revision 844)
@@ -0,0 +1,143 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  06/2001 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MWriteAsciiFile                                                         //
+//                                                                         //
+// If you want to store a single container into an Ascii file you have     //
+// to use this class. You must know the name of the file you wanne write   //
+// (you should know it) and the name of the container you want to write.   //
+// This can be the name of the class or a given name, which identifies     //
+// the container in a parameter container list (MParList).                 //
+// The container is writte to the ascii file if its HasChanged flag is     //
+// set (MParContainer)                                                     //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MWriteAsciiFile.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MWriteAsciiFile)
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+// Specify the name of the ascii output file 'filename' and the name
+// of the container you want to write. (Normally this is the name
+// of the class (eg. MHillas) but it can also be a different name which
+// identifies the container in the parameter list.
+//
+MWriteAsciiFile::MWriteAsciiFile(const char *filename, const char *contname,
+                                 const char *name, const char *title) : fOut(NULL)
+{
+    *fName  = name  ? name  : "MWriteAsciiFile";
+    *fTitle = title ? title : "Task to write one container to an ascii file";
+
+    fNameFile      = filename;
+    fNameContainer = contname;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete the output file if necessary (it is closed
+// automatically by its destructor.
+//
+MWriteAsciiFile::~MWriteAsciiFile()
+{
+    if (fOut)
+        delete fOut;
+}
+
+// --------------------------------------------------------------------------
+//
+// Tries to open the given output file. And tries to get a pointer to the
+// instance of the container which should be written.
+// If the container has already the HasChanged flag it is immediatly written
+// to the output file.
+//
+Bool_t MWriteAsciiFile::PreProcess (MParList *pList)
+{
+    fOut = new ofstream(fNameFile);
+
+    if (!(*fOut))
+    {
+        *fLog << dbginf << "Cannot open Ascii file '" << fNameFile << "' for writing." << endl;
+        return kFALSE;
+    }
+
+    *fLog << "Ascii file '" << fNameFile << "' opened for writing." << endl;
+
+    fContainer = (MParContainer*)pList->FindObject(fNameContainer);
+    if (!fContainer)
+    {
+        *fLog << dbginf << "Cannot find parameter container '" << fContainer << "'." << endl;
+        return kFALSE;
+    }
+
+    if (fContainer->HasChanged())
+        fContainer->AsciiWrite(*fOut);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks if the HasChanged flag of the output container is set. If it is set
+// the container is instructed to write itself to the ascii file.
+// (By calling its memberfunction AsciiWrite. You find the Prototype in
+// MParContainer)
+//
+Bool_t MWriteAsciiFile::Process()
+{
+    if (fContainer->HasChanged())
+        fContainer->AsciiWrite(*fOut);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// If the output container has the HasChanged flag set, it is written to the
+// output file (eg. this could be some calculated result)
+// If the output file object exists, delete it. (The file is closed
+// automatically in the corresponding destructor)
+//
+Bool_t MWriteAsciiFile::PostProcess()
+{
+    if (fContainer->HasChanged())
+        fContainer->AsciiWrite(*fOut);
+
+    delete fOut;
+    fOut = NULL;
+
+    return kTRUE;
+}
+
Index: /trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.h	(revision 844)
+++ /trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.h	(revision 844)
@@ -0,0 +1,28 @@
+#ifndef MWRITEASCIIFILE_H
+#define MWRITEASCIIFILE_H
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MWriteAsciiFile : public MTask
+{
+private:
+    ofstream *fOut;
+    TString  fNameFile;
+    TString  fNameContainer;
+
+    MParContainer *fContainer;
+
+public:
+    MWriteAsciiFile(const char *filename, const char *contname, const char *name=NULL, const char *title=NULL);
+    ~MWriteAsciiFile();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MWriteAsciiFile, 0)	// Class to write one container to an ascii file
+};
+
+#endif
