Ignore:
Timestamp:
01/21/02 20:52:12 (23 years ago)
Author:
rkb
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r1080 r1203  
    3737#include "MParContainer.h"
    3838
     39#include <fstream.h>     // ofstream, AsciiWrite
     40
    3941#include <TClass.h>      // IsA
    4042#include <TROOT.h>       // TROOT::Identlevel
     43#include <TMethodCall.h> // TMethodCall, AsciiWrite
     44#include <TDataMember.h> // TDataMember, AsciiWrite
    4145#include <TVirtualPad.h> // gPad
    4246
     
    211215//
    212216//  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
    213 //  container, overload this function.
     217//  container, you may overload this function. If you don't overload it
     218//  the data member of a class are written to the file in the order of
     219//  appearance in the class header (be more specfic: root dictionary)
     220//  Only data members which are of integer (Bool_t, Int_t, ...) or
     221//  floating point (Float_t, Double_t, ...) type are written.
    214222//
    215223void MParContainer::AsciiWrite(ofstream &fout) const
    216224{
    217     *fLog << warn << "To use the the ascii output of " << GetName();
    218     *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl;
    219 }
     225    // *fLog << warn << "To use the the ascii output of " << GetName();
     226    // *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl;
     227
     228    TDataMember *data = NULL;
     229
     230    TIter Next(IsA()->GetListOfDataMembers());
     231    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}
Note: See TracChangeset for help on using the changeset viewer.