Changeset 8930 for trunk


Ignore:
Timestamp:
06/09/08 13:36:25 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8929 r8930  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21
     22 2008/06/09 Thomas Bretz
     23
     24  * mbase/MArgs.[h,cc]:
     25    - for convinience store the full command line as Title
     26    - replaced *fArgv by fArgv
     27
     28  * mbase/MObjLookup.cc:
     29    - replaced C-style cast by reinterpret_cast
     30
    2031
    2132
  • trunk/MagicSoft/Mars/mbase/MArgs.cc

    r7808 r8930  
    1818!   Author(s): Thomas Bretz, 7/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2003-2004
     20!   Copyright: MAGIC Software Development, 2003-2008
    2121!
    2222!
     
    6262MArgs::MArgs(int argc, char **argv, Bool_t root) : fArgc(argc)
    6363{
     64    TString cmdline;
    6465    // FIXME: argv has no const-qualifier to be idetical with
    6566    //        TApplication.
    66     fName = argv[0];
    67 
    68     fArgv = new TList;
    69     fArgv->SetOwner();
     67    fName  = argv[0];
     68    fTitle = argv[0];
     69
     70    fArgv.SetOwner();
    7071
    7172    for (int i=1; i<argc; i++)
    7273    {
    73         MArgsEntry &o = *new MArgsEntry(argv[i]);
    74         fArgv->Add(&o);
     74        fTitle += " ";
     75        fTitle += argv[i];
     76        fArgv.Add(new MArgsEntry(argv[i]));
    7577    }
    7678
     
    7981
    8082    HasOnlyAndRemove("-b");
    81 }
    82 
    83 // --------------------------------------------------------------------------
    84 //
    85 // Deletes fArgv.
    86 //
    87 MArgs::~MArgs()
    88 {
    89     delete fArgv;
    9083}
    9184
     
    9588// Using 'options' as option only 'options' are printed.
    9689// Using 'arguments' as option only 'arguments' are printed.
     90// Using 'cmdline' as option the command line is printed instead of
     91//       just the program name
    9792//
    9893void MArgs::Print(const Option_t *o) const
    9994{
    100     gLog << all << underline << fName << ":" << endl;
    101 
    102     const TString str(o);
     95    TString str(o);
     96
     97    gLog << all << underline;
     98    if (str.Contains("cmdline"))
     99        gLog << fTitle << endl;
     100    else
     101        gLog << fName << ":" << endl;
     102
     103    str.ReplaceAll("cmdline", "");
     104    str.ReplaceAll(" ", "");
    103105
    104106    if (!str.CompareTo("options", TString::kIgnoreCase))
    105107    {
    106         TIter Next(fArgv);
     108        TIter Next(&fArgv);
    107109        TString *s = NULL;
    108110        while ((s=dynamic_cast<TString*>(Next())))
     
    114116    if (!str.CompareTo("arguments", TString::kIgnoreCase))
    115117    {
    116         TIter Next(fArgv);
     118        TIter Next(&fArgv);
    117119        TString *s = NULL;
    118120        while ((s=dynamic_cast<TString*>(Next())))
     
    122124    }
    123125
    124     fArgv->Print();
     126    fArgv.Print();
    125127}
    126128
     
    156158TString MArgs::GetString(const TString name) const
    157159{
    158     TIter Next(fArgv);
     160    TIter Next(&fArgv);
    159161    TString *s = NULL;
    160162    while ((s=dynamic_cast<TString*>(Next())))
     
    200202    const TString name = n.Strip(TString::kBoth);
    201203
    202     TIter Next(fArgv);
     204    TIter Next(&fArgv);
    203205    TString *s = NULL;
    204206    while ((s=dynamic_cast<TString*>(Next())))
     
    206208        {
    207209            TString str = s->Data()+s->Index(name)+name.Length();
    208             delete fArgv->Remove(dynamic_cast<TObject*>(s));
     210            delete fArgv.Remove(dynamic_cast<TObject*>(s));
    209211            return str;
    210212        }
     
    281283    Int_t num = 0;
    282284
    283     TIter Next(fArgv);
     285    TIter Next(&fArgv);
    284286    TString *s = NULL;
    285287    while ((s=dynamic_cast<TString*>(Next())))
     
    303305    Int_t num = 0;
    304306
    305     TIter Next(fArgv);
     307    TIter Next(&fArgv);
    306308    TString *s = NULL;
    307309    while ((s=dynamic_cast<TString*>(Next())))
     
    320322    Int_t num = 0;
    321323
    322     TIter Next(fArgv);
     324    TIter Next(&fArgv);
    323325    TString *s = NULL;
    324326    while ((s=dynamic_cast<TString*>(Next())))
     
    335337Int_t MArgs::GetNumEntries() const
    336338{
    337     return fArgv->GetSize();
     339    return fArgv.GetSize();
    338340}
    339341
     
    349351    const TString name = n.Strip(TString::kBoth);
    350352
    351     TIter Next(fArgv);
     353    TIter Next(&fArgv);
    352354    TString *s = NULL;
    353355    while ((s=dynamic_cast<TString*>(Next())))
     
    369371    const TString name = n.Strip(TString::kBoth);
    370372
    371     TIter Next(fArgv);
     373    TIter Next(&fArgv);
    372374    TString *s = NULL;
    373375    while ((s=dynamic_cast<TString*>(Next())))
     
    391393    const TString name = n.Strip(TString::kBoth);
    392394
    393     TIter Next(fArgv);
     395    TIter Next(&fArgv);
    394396    TString *s = NULL;
    395397    while ((s=dynamic_cast<TString*>(Next())))
     
    417419    Bool_t rc = kFALSE;
    418420
    419     TIter Next(fArgv);
     421    TIter Next(&fArgv);
    420422    TString *s = NULL;
    421423    while ((s=dynamic_cast<TString*>(Next())))
    422424        if (*s==name)
    423425        {
    424             delete fArgv->Remove(dynamic_cast<TObject*>(s));
     426            delete fArgv.Remove(dynamic_cast<TObject*>(s));
    425427            rc = kTRUE;
    426428        }
  • trunk/MagicSoft/Mars/mbase/MArgs.h

    r7169 r8930  
    2727{
    2828private:
    29     Int_t  fArgc;
    30     TList *fArgv; //->
     29    Int_t fArgc; //!
     30    TList fArgv; //!
    3131
    3232public:
    3333    MArgs(int argc, char **argv, Bool_t root=kFALSE);
    34     ~MArgs();
    3534
     35    // TObject
    3636    void Print(const Option_t *o="") const;
    3737
     
    3939    // FIXME: Add default option
    4040
     41    // MArgs
    4142    Int_t    GetInt(const TString name) const;
    4243    Double_t GetFloat(const TString name) const;
  • trunk/MagicSoft/Mars/mbase/MObjLookup.cc

    r8892 r8930  
    4949    while (iter.Next(key, value))
    5050    {
    51         TObject *o = (TObject*)value;
     51        TObject *o = reinterpret_cast<TObject*>(value);
    5252        if (o->TestBit(kCanDelete) || TestBit(kIsOwner))
    5353            delete o;
     
    8888TObject *MObjLookup::GetObj(Long_t key) const
    8989{
    90     TObject *o = (TObject*)const_cast<TExMap&>(fMap).GetValue(key);
     90    TObject *o = reinterpret_cast<TObject*>(const_cast<TExMap&>(fMap).GetValue(key));
    9191    return o ? o : fDefault;
    9292}
Note: See TracChangeset for help on using the changeset viewer.