Changeset 850


Ignore:
Timestamp:
06/13/01 13:09:40 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r848 r850  
    88   * mbase/MParContainer.[h,cc]:
    99     - added a 'dummy' function for AsciiRead, AsciiWrite
     10
     11   * mbase/MWriteAsciiFile.[h,cc]:
     12     - added new constructor (specify directly the pointer to the class)
     13
     14   * mgui/MHexagon.cc:
     15     - made Copy-function more readable
     16
     17   * mgui/MParContainer.cc:
     18     - made Copy-function more readable
    1019
    1120
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc

    r844 r850  
    5050// --------------------------------------------------------------------------
    5151//
    52 // Default constructor.
    5352// Specify the name of the ascii output file 'filename' and the name
    5453// of the container you want to write. (Normally this is the name
     
    5756//
    5857MWriteAsciiFile::MWriteAsciiFile(const char *filename, const char *contname,
    59                                  const char *name, const char *title) : fOut(NULL)
     58                                 const char *name, const char *title)
     59    : fOut(NULL), fContainer(NULL)
    6060{
    6161    *fName  = name  ? name  : "MWriteAsciiFile";
     
    6464    fNameFile      = filename;
    6565    fNameContainer = contname;
     66}
     67
     68// --------------------------------------------------------------------------
     69//
     70// Specify a the name of the ascii output file 'filename' and a pointer to
     71// the container you want to write.
     72//
     73MWriteAsciiFile::MWriteAsciiFile(const char *filename, MParContainer *cont,
     74                                 const char *name, const char *title)
     75    : fOut(NULL), fContainer(cont)
     76{
     77    *fName  = name  ? name  : "MWriteAsciiFile";
     78    *fTitle = title ? title : "Task to write one container to an ascii file";
     79
     80    fNameFile      = filename;
     81    fNameContainer = cont->GetName();
    6682}
    6783
     
    86102Bool_t MWriteAsciiFile::PreProcess (MParList *pList)
    87103{
     104    //
     105    // Try to find the container which should be stored.
     106    //
     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    }
     116
     117    //
     118    // Try to open the output file
     119    //
    88120    fOut = new ofstream(fNameFile);
    89121
     
    96128    *fLog << "Ascii file '" << fNameFile << "' opened for writing." << endl;
    97129
    98     fContainer = (MParContainer*)pList->FindObject(fNameContainer);
    99     if (!fContainer)
    100     {
    101         *fLog << dbginf << "Cannot find parameter container '" << fContainer << "'." << endl;
    102         return kFALSE;
    103     }
    104 
     130    //
     131    // write the container if it is already in changed state
     132    //
    105133    if (fContainer->HasChanged())
    106134        fContainer->AsciiWrite(*fOut);
     
    133161Bool_t MWriteAsciiFile::PostProcess()
    134162{
     163    //
     164    // check if the container changed state is set
     165    //
    135166    if (fContainer->HasChanged())
    136167        fContainer->AsciiWrite(*fOut);
    137168
     169    //
     170    // delete (close) file
     171    //
    138172    delete fOut;
    139173    fOut = NULL;
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.h

    r844 r850  
    1010private:
    1111    ofstream *fOut;
    12     TString  fNameFile;
    13     TString  fNameContainer;
     12
     13    TString fNameFile;
     14    TString fNameContainer;
    1415
    1516    MParContainer *fContainer;
    1617
    1718public:
    18     MWriteAsciiFile(const char *filename, const char *contname, const char *name=NULL, const char *title=NULL);
     19    MWriteAsciiFile(const char *filename, const char *contname,
     20                    const char *name=NULL, const char *title=NULL);
     21    MWriteAsciiFile(const char *filename, MParContainer *cont,
     22                    const char *name=NULL, const char *title=NULL);
    1923    ~MWriteAsciiFile();
    2024
Note: See TracChangeset for help on using the changeset viewer.