Ignore:
Timestamp:
06/20/01 10:41:23 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/BaseLinkDef.h

    r843 r852  
    2929
    3030#pragma link C++ class MReadTree;
     31#pragma link C++ class MWriteFile;
    3132#pragma link C++ class MWriteAsciiFile;
     33#pragma link C++ class MWriteRootFile;
    3234
    3335#pragma link C++ class MArray;
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r843 r852  
    160160    //
    161161    if (maxcnt<0)
    162         while (fTaskList->Process() && ++dummy);
     162        // process first and increment if sucessfull
     163        while (fTaskList->Process()) dummy++;
    163164    else
    164         while (fTaskList->Process() && dummy--);
     165        // check for number and break if unsuccessfull
     166        while (dummy-- && fTaskList->Process());
    165167
    166168    //
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r847 r852  
    102102Bool_t MParList::AddToList(MParContainer *obj, MParContainer *where)
    103103{
     104    //
     105    //  check if the object (you want to add) exists
     106    //
     107
     108    if (!obj) return kTRUE;
     109
     110    *fLog << "Adding " << obj->GetName() << " to " << GetName() << "... " << flush;
    104111  //
    105   //  check if the object (you want to add) exists
    106   //
    107 
    108   if (!obj) return kTRUE;
    109 
    110   *fLog << "Adding " << obj->GetName() << " to " << GetName() << "... " << flush;
    111   //
    112   //  check if it is in the list yet
    113   //
    114   if (fContainer.FindObject(obj))
    115   {
    116       *fLog << dbginf << "Container already added" << endl;
    117       return kTRUE;
    118   }
    119 
    120   //
    121   //  check if you want to add the new parameter container somewhere
     112    //  check if it is in the list yet
     113    //
     114    if (fContainer.FindObject(obj))
     115    {
     116        *fLog << dbginf << "Container already added" << endl;
     117        return kTRUE;
     118    }
     119
     120    //
     121    //  check if you want to add the new parameter container somewhere
    122122  //  special (in that case you specify "where")
    123   // 
    124   if (where)
    125   {
    126       if (!fContainer.FindObject(where))
    127       {
    128           *fLog << dbginf << "Cannot find parameter container after which the new one should be added!" << endl;
    129           return kFALSE;
    130       }
    131   }
    132 
    133   fContainer.Add(obj);
    134   *fLog << "Done." << endl;
    135 
    136   return kTRUE;
     123    //
     124    if (where)
     125    {
     126        if (!fContainer.FindObject(where))
     127        {
     128            *fLog << dbginf << "Cannot find parameter container after which the new one should be added!" << endl;
     129            return kFALSE;
     130        }
     131    }
     132
     133    fContainer.Add(obj);
     134    *fLog << "Done." << endl;
     135
     136    return kTRUE;
    137137}
    138138
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc

    r850 r852  
    6464    fNameFile      = filename;
    6565    fNameContainer = contname;
     66
     67    fOut = new ofstream(fNameFile);
    6668}
    6769
     
    8082    fNameFile      = filename;
    8183    fNameContainer = cont->GetName();
     84
     85    fOut = new ofstream(fNameFile);
    8286}
    8387
     
    8993MWriteAsciiFile::~MWriteAsciiFile()
    9094{
    91     if (fOut)
    92         delete fOut;
     95    delete fOut;
    9396}
    9497
    9598// --------------------------------------------------------------------------
    9699//
    97 // Tries to open the given output file. And tries to get a pointer to the
    98 // instance of the container which should be written.
    99 // If the container has already the HasChanged flag it is immediatly written
    100 // to the output file.
     100// Check if our container is ready for writing. If so write it.
    101101//
    102 Bool_t MWriteAsciiFile::PreProcess (MParList *pList)
     102void MWriteAsciiFile::CheckAndWrite() const
     103{
     104    if (fContainer->HasChanged())
     105        fContainer->AsciiWrite(*fOut);
     106}
     107
     108// --------------------------------------------------------------------------
     109//
     110// Return open state of the file
     111//
     112Bool_t MWriteAsciiFile::IsFileOpen() const
     113{
     114    return (bool)(*fOut);
     115}
     116
     117// --------------------------------------------------------------------------
     118//
     119// If the container is yet unknown and the name of it is known only, try
     120// to get the container from the parameter list.
     121//
     122Bool_t MWriteAsciiFile::GetContainer(MParList *pList)
    103123{
    104124    //
    105125    // Try to find the container which should be stored.
    106126    //
    107     if (!fContainer)
    108     {
    109         fContainer = (MParContainer*)pList->FindObject(fNameContainer);
    110         if (!fContainer)
    111         {
    112             *fLog << dbginf << "Cannot find parameter container '" << fContainer << "'." << endl;
    113             return kFALSE;
    114         }
    115     }
     127    if (fContainer)
     128        return kTRUE;
    116129
    117     //
    118     // Try to open the output file
    119     //
    120     fOut = new ofstream(fNameFile);
     130    fContainer = (MParContainer*)pList->FindObject(fNameContainer);
     131    if (fContainer)
     132        return kTRUE;
    121133
    122     if (!(*fOut))
    123     {
    124         *fLog << dbginf << "Cannot open Ascii file '" << fNameFile << "' for writing." << endl;
    125         return kFALSE;
    126     }
    127 
    128     *fLog << "Ascii file '" << fNameFile << "' opened for writing." << endl;
    129 
    130     //
    131     // write the container if it is already in changed state
    132     //
    133     if (fContainer->HasChanged())
    134         fContainer->AsciiWrite(*fOut);
    135 
    136     return kTRUE;
     134    *fLog << dbginf << "Cannot find parameter container '" << fContainer << "'." << endl;
     135    return kFALSE;
    137136}
    138 
    139 // --------------------------------------------------------------------------
    140 //
    141 // Checks if the HasChanged flag of the output container is set. If it is set
    142 // the container is instructed to write itself to the ascii file.
    143 // (By calling its memberfunction AsciiWrite. You find the Prototype in
    144 // MParContainer)
    145 //
    146 Bool_t MWriteAsciiFile::Process()
    147 {
    148     if (fContainer->HasChanged())
    149         fContainer->AsciiWrite(*fOut);
    150 
    151     return kTRUE;
    152 }
    153 
    154 // --------------------------------------------------------------------------
    155 //
    156 // If the output container has the HasChanged flag set, it is written to the
    157 // output file (eg. this could be some calculated result)
    158 // If the output file object exists, delete it. (The file is closed
    159 // automatically in the corresponding destructor)
    160 //
    161 Bool_t MWriteAsciiFile::PostProcess()
    162 {
    163     //
    164     // check if the container changed state is set
    165     //
    166     if (fContainer->HasChanged())
    167         fContainer->AsciiWrite(*fOut);
    168 
    169     //
    170     // delete (close) file
    171     //
    172     delete fOut;
    173     fOut = NULL;
    174 
    175     return kTRUE;
    176 }
    177 
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.h

    r850 r852  
    22#define MWRITEASCIIFILE_H
    33
    4 #ifndef MTASK_H
    5 #include "MTask.h"
     4#ifndef MWRITEFILE_H
     5#include "MWriteFile.h"
    66#endif
    77
    8 class MWriteAsciiFile : public MTask
     8class MWriteAsciiFile : public MWriteFile //MTask
    99{
    1010private:
     
    1616    MParContainer *fContainer;
    1717
     18    virtual void   CheckAndWrite() const;
     19    virtual Bool_t IsFileOpen() const;
     20    virtual Bool_t GetContainer(MParList *pList);
     21    virtual const char *GetFileName() const { return fNameFile; }
     22
     23
    1824public:
    1925    MWriteAsciiFile(const char *filename, const char *contname,
     
    2329    ~MWriteAsciiFile();
    2430
    25     Bool_t PreProcess(MParList *pList);
    26     Bool_t Process();
    27     Bool_t PostProcess();
    28 
    2931    ClassDef(MWriteAsciiFile, 0)        // Class to write one container to an ascii file
    3032};
  • trunk/MagicSoft/Mars/mbase/Makefile

    r846 r852  
    3838           MEvtLoop.cc \
    3939           MReadTree.cc \
     40           MWriteFile.cc \
    4041           MWriteAsciiFile.cc \
     42           MWriteRootFile.cc \
    4143           MArray.cc \
    4244           MArrayB.cc \
Note: See TracChangeset for help on using the changeset viewer.