Ignore:
Timestamp:
09/08/04 18:49:00 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc

    r4694 r4889  
    2424
    2525/////////////////////////////////////////////////////////////////////////////
    26 //                                                                         //
    27 // MWriteAsciiFile                                                         //
    28 //                                                                         //
    29 // If you want to store a single container into an Ascii file you have     //
    30 // to use this class. You must know the name of the file you wanne write   //
    31 // (you should know it) and the name of the container you want to write.   //
    32 // This can be the name of the class or a given name, which identifies     //
    33 // the container in a parameter container list (MParList).                 //
    34 // The container is written to the ascii file if its ReadyToSave flag is   //
    35 // set (MParContainer)                                                     //
    36 //                                                                         //
    37 // You can write more than one container in one line of the file, see      //
    38 // AddContainer.                                                           //
    39 //                                                                         //
    40 // You can also write single data members of a container (like fWidth      //
    41 // of MHillas). For more details see AddContainer. Make sure, that a       //
    42 // getter method for the data member exist. The name of the method         //
    43 // must be the same than the data member itself, but the f must be         //
    44 // replaced by a Get.                                                      //
    45 //                                                                         //
     26//
     27// MWriteAsciiFile
     28//
     29// If you want to store a single container into an Ascii file you have
     30// to use this class. You must know the name of the file you wanne write
     31// (you should know it) and the name of the container you want to write.
     32// This can be the name of the class or a given name, which identifies
     33// the container in a parameter container list (MParList).
     34// The container is written to the ascii file if its ReadyToSave flag is
     35// set (MParContainer)
     36//
     37// You can write more than one container in one line of the file, see
     38// AddContainer.
     39//
     40// You can also write single data members of a container (like fWidth
     41// of MHillas). For more details see AddContainer. Make sure, that a
     42// getter method for the data member exist. The name of the method
     43// must be the same than the data member itself, but the f must be
     44// replaced by a Get.
     45//
    4646/////////////////////////////////////////////////////////////////////////////
    47 
    4847#include "MWriteAsciiFile.h"
    4948
     
    5150
    5251#include <TMethodCall.h> // TMethodCall, AsciiWrite
     52
     53#include "MIter.h"
    5354
    5455#include "MDataList.h"   // MDataList
     
    190191Bool_t MWriteAsciiFile::CheckAndWrite()
    191192{
     193    MParContainer *obj = NULL;
     194
     195    //
     196    // Check for the Write flag
     197    //
     198    Bool_t write = kFALSE;
     199    MIter Next(&fList);
     200    while ((obj=Next()))
     201        if (obj->IsReadyToSave())
     202        {
     203            write = kTRUE;
     204            break;
     205        }
     206
     207    //
     208    // Do not write if not at least one ReadyToSave-flag set
     209    //
     210    if (!write)
     211        return kTRUE;
     212
    192213    Bool_t written = kFALSE;
    193 
    194     MParContainer *obj = NULL;
    195 
    196214    Int_t num = fList.GetEntries();
    197215
    198     TIter Next(&fList);
    199     while ((obj=(MParContainer*)Next()))
     216    Next.Reset();
     217    while ((obj=Next()))
    200218    {
    201         //
    202         // Check for the Write flag
    203         //
    204         if (!obj->IsReadyToSave())
    205             continue;
     219        if (written)
     220            *fOut << " ";
    206221
    207222        //
     
    224239
    225240        if (num!=0)
    226             *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl;
     241            *fLog << warn << "WARNING - Number of objects written mismatch!" << endl;
    227242    }
    228243    return kTRUE;
Note: See TracChangeset for help on using the changeset viewer.