Ignore:
Timestamp:
02/21/02 14:46:59 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
3 edited

Legend:

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

    r1218 r1222  
    4040
    4141#include <TClass.h>      // IsA
     42#include <TBaseClass.h>  // GetClassPointer
    4243#include <TROOT.h>       // TROOT::Identlevel
    4344#include <TMethodCall.h> // TMethodCall, AsciiWrite
     
    216217//  Write out a data member given as a TDataMember object to an output stream.
    217218//
    218 Bool_t MParContainer::WriteDataMember(ostream &out, TDataMember *member) const
     219Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member) const
    219220{
    220221    if (!member)
    221222        return kFALSE;
    222223
    223     if (!member->IsPersistent())
    224         return kFALSE;
    225 
    226     /*const*/ TMethodCall *call = member->GetterMethod(); //FIXME: Root
     224    if (!member->IsPersistent() || member->Property()&kIsStatic)
     225        return kFALSE;
     226
     227    /*const*/ TMethodCall *call = ((TDataMember*)member)->GetterMethod(); //FIXME: Root
    227228    if (!call)
    228         return kFALSE;
     229    {
     230        *fLog << warn << "Sorry, no getter method found for " << member->GetName() << endl;
     231        return kFALSE;
     232    }
    229233
    230234    switch (call->ReturnType())
     
    256260Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const
    257261{
    258     return WriteDataMember(out, IsA()->GetDataMember(member));
     262    /*const*/ TClass *cls = IsA()->GetBaseDataMember(member);
     263    if (!cls)
     264        return kFALSE;
     265
     266    return WriteDataMember(out, cls->GetDataMember(member));
     267}
     268
     269// --------------------------------------------------------------------------
     270//
     271//  Write out a data member from a given TList of TDataMembers.
     272//  returns kTRUE when at least one member was successfully written
     273//
     274Bool_t MParContainer::WriteDataMember(ostream &out, const TList *list) const
     275{
     276    Bool_t rc = kFALSE;
     277
     278    TDataMember *data = NULL;
     279
     280    TIter Next(list);
     281    while ((data=(TDataMember*)Next()))
     282        rc |= WriteDataMember(out, data);
     283
     284    return rc;
    259285}
    260286
     
    267293//  Only data members which are of integer (Bool_t, Int_t, ...) or
    268294//  floating point (Float_t, Double_t, ...) type are written.
    269 //
    270 void MParContainer::AsciiWrite(ostream &out) const
     295//  returns kTRUE when at least one member was successfully written
     296//
     297Bool_t MParContainer::AsciiWrite(ostream &out) const
    271298{
    272299    // *fLog << warn << "To use the the ascii output of " << GetName();
    273300    // *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl;
    274301
    275     TDataMember *data = NULL;
    276 
    277     TIter Next(IsA()->GetListOfDataMembers());
    278     while ((data=(TDataMember*)Next()))
    279         WriteDataMember(out, data);
    280 }
     302    Bool_t rc = WriteDataMember(out, IsA()->GetListOfDataMembers());
     303
     304    TIter NextBaseClass(IsA()->GetListOfBases());
     305    TBaseClass *base;
     306    while ((base = (TBaseClass*) NextBaseClass()))
     307    {
     308        /*const*/ TClass *cls = base->GetClassPointer();
     309
     310        if (!cls)
     311            continue;
     312
     313        rc |= WriteDataMember(out, cls->GetListOfDataMembers());
     314    }
     315
     316    return rc;
     317}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1218 r1222  
    6767
    6868    Bool_t WriteDataMember(ostream &out, const char *member) const;
    69     Bool_t WriteDataMember(ostream &out, TDataMember *member) const;
     69    Bool_t WriteDataMember(ostream &out, const TDataMember *member) const;
     70    Bool_t WriteDataMember(ostream &out, const TList *list) const;
    7071
    7172    virtual void AsciiRead(ifstream &fin);
    72     virtual void AsciiWrite(ostream &out) const;
     73    virtual Bool_t AsciiWrite(ostream &out) const;
    7374
    7475    ClassDef(MParContainer, 0)  //The basis for all parameter containers
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc

    r1219 r1222  
    154154
    155155        if (memb->GetName()[0]=='\0')
    156             cont->AsciiWrite(*fOut);
     156        {
     157            if (!cont->AsciiWrite(*fOut))
     158                continue;
     159        }
    157160        else
    158161        {
     
    167170    }
    168171
    169     if (written)
    170         *fOut << endl;
     172    if (!written)
     173        return;
     174
     175    *fOut << endl;
    171176
    172177    if (num!=0)
    173       *fLog << warn << "Warning - given number of containers doesn't fit number of written containers." << endl;
     178        *fLog << warn << "Warning - given number of containers doesn't fit number of written containers." << endl;
    174179}
    175180
Note: See TracChangeset for help on using the changeset viewer.