Ignore:
Timestamp:
02/21/02 12:08:03 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MFilterList.cc

    r1080 r1218  
    143143    const char *name = filter->GetName();
    144144
    145     // FIXME: We agreed to put the task into list in an ordered way.
    146 
    147145    if (fFilters.FindObject(filter))
    148146    {
  • trunk/MagicSoft/Mars/mbase/MGList.cc

    r1116 r1218  
    9898    //      Is this another bug in root?
    9999    //
     100#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,07)
    100101    if (!obj->IsA()->InheritsFrom(TGWidget::Class()))
    101102        return NULL;
     103#endif
    102104
    103105    return (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj);
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1211 r1218  
    214214// --------------------------------------------------------------------------
    215215//
     216//  Write out a data member given as a TDataMember object to an output stream.
     217//
     218Bool_t MParContainer::WriteDataMember(ostream &out, TDataMember *member) const
     219{
     220    if (!member)
     221        return kFALSE;
     222
     223    if (!member->IsPersistent())
     224        return kFALSE;
     225
     226    /*const*/ TMethodCall *call = member->GetterMethod(); //FIXME: Root
     227    if (!call)
     228        return kFALSE;
     229
     230    switch (call->ReturnType())
     231    {
     232    case TMethodCall::kLong:
     233        Long_t l;
     234        call->Execute((void*)this, l); // FIXME: const, root
     235        out << l << " ";
     236        return kTRUE;
     237
     238    case TMethodCall::kDouble:
     239        Double_t d;
     240        call->Execute((void*)this, d); // FIXME: const, root
     241        out << d << " ";
     242        return kTRUE;
     243
     244    case TMethodCall::kOther:
     245        /* someone may want to enhance this? */
     246        return kFALSE;
     247    }
     248
     249    return kFALSE;
     250}
     251
     252// --------------------------------------------------------------------------
     253//
     254//  Write out a data member given by name to an output stream.
     255//
     256Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const
     257{
     258    return WriteDataMember(out, IsA()->GetDataMember(member));
     259}
     260
     261// --------------------------------------------------------------------------
     262//
    216263//  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
    217264//  container, you may overload this function. If you don't overload it
     
    221268//  floating point (Float_t, Double_t, ...) type are written.
    222269//
    223 void MParContainer::AsciiWrite(ofstream &fout) const
     270void MParContainer::AsciiWrite(ostream &out) const
    224271{
    225272    // *fLog << warn << "To use the the ascii output of " << GetName();
     
    230277    TIter Next(IsA()->GetListOfDataMembers());
    231278    while ((data=(TDataMember*)Next()))
    232     {
    233         if (!data->IsPersistent())
    234             continue;
    235 
    236         /*const*/ TMethodCall *call = data->GetterMethod(); //FIXME: Root
    237         if (!call)
    238             continue;
    239 
    240         switch (call->ReturnType())
    241         {
    242         case TMethodCall::kLong:
    243             Long_t l;
    244             call->Execute((void*)this, l); // FIXME: const, root
    245             fout << l << " ";
    246             continue;
    247 
    248         case TMethodCall::kDouble:
    249             Double_t d;
    250             call->Execute((void*)this, d); // FIXME: const, root
    251             fout << d << " ";
    252             continue;
    253 
    254         case TMethodCall::kOther:
    255             /* someone may want to enhance this? */
    256             continue;
    257         }
    258     }
    259 }
     279        WriteDataMember(out, data);
     280}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1086 r1218  
    2222class ofstream;
    2323class ifstream;
     24
     25class TDataMember;
    2426
    2527class MParContainer : public TObject
     
    6466    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
    6567
     68    Bool_t WriteDataMember(ostream &out, const char *member) const;
     69    Bool_t WriteDataMember(ostream &out, TDataMember *member) const;
     70
    6671    virtual void AsciiRead(ifstream &fin);
    67     virtual void AsciiWrite(ofstream &fout) const;
     72    virtual void AsciiWrite(ostream &out) const;
    6873
    6974    ClassDef(MParContainer, 0)  //The basis for all parameter containers
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc

    r1192 r1218  
    4444#include <fstream.h>
    4545
     46#include <TClass.h>      // IsA
     47#include <TMethodCall.h> // TMethodCall, AsciiWrite
     48#include <TDataMember.h> // TDataMember, AsciiWrite
     49
    4650#include "MLog.h"
    4751#include "MLogManip.h"
     
    8185    Init(filename, name, title);
    8286
    83     AddContainer(contname);
     87    if (contname)
     88        AddContainer(contname);
    8489}
    8590
     
    100105    Init(filename, name, title);
    101106
    102     AddContainer(cont);
     107    if (cont)
     108        AddContainer(cont);
    103109}
    104110
     
    111117{
    112118    fContNames.SetOwner();
     119    fMembers.SetOwner();
    113120
    114121    delete fOut;
     
    130137    Int_t num = fContainer.GetEntries();
    131138
    132     TIter Next(&fContainer);
    133 
    134     while ((cont=(MParContainer*)Next()))
     139    TIter NextCont(&fContainer);
     140    TIter NextMemb(&fMembers);
     141
     142    while ((cont=(MParContainer*)NextCont()))
    135143    {
     144        const TObject *memb = NextMemb();
     145
    136146        if (!cont->IsReadyToSave())
    137147            continue;
    138148
    139         cont->AsciiWrite(*fOut);
     149        if (memb->GetName()[0]=='\0')
     150            cont->AsciiWrite(*fOut);
     151        else
     152        {
     153            if (!cont->WriteDataMember(*fOut, memb->GetName()))
     154                continue;
     155        }
     156
    140157        *fOut << " ";
    141158        written = kTRUE;
     
    183200        }
    184201
    185         AddContainer(cont);
     202        AddContainer(cont, obj->GetTitle());
    186203    }
    187204
     
    193210// Add another container (by name) to be written to the ascii file.
    194211// The container will be output one after each other in one line.
    195 //
    196 void MWriteAsciiFile::AddContainer(const char *cname)
    197 {
    198     TNamed *named = new TNamed(cname, "");
     212// If you want to write only one data member of the container
     213// specify the name of the data member (eg. fAlpha) Make sure,
     214// that a "GetteMethod" for this data type exists (strif the f and
     215// replace it by Get)
     216//
     217void MWriteAsciiFile::AddContainer(const char *cname, const char *member)
     218{
     219    TNamed *named = new TNamed(cname, member);
    199220    fContNames.AddLast(named);
    200221}
     
    204225// Add another container (by pointer) to be written to the ascii file.
    205226// The container will be output one after each other in one line.
    206 //
    207 void MWriteAsciiFile::AddContainer(MParContainer *cont)
     227// If you want to write only one data member of the container
     228// specify the name of the data member (eg. fAlpha) Make sure,
     229// that a "GetteMethod" for this data type exists (strif the f and
     230// replace it by Get)
     231//
     232void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member)
    208233{
    209234    fContainer.AddLast(cont);
    210 }
    211 
     235
     236    TNamed *named = new TNamed(member, "");
     237    fMembers.AddLast(named);
     238}
     239
Note: See TracChangeset for help on using the changeset viewer.