Ignore:
Timestamp:
09/02/04 14:32:50 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
5 edited

Legend:

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

    r4710 r4828  
    101101    virtual void SetDisplay(MStatusDisplay *d) { fDisplay = d; }
    102102
    103     // FIXME: Change to ostream!
     103    // FIXME: Change to ostream! Seems to be difficult, because
     104    //        MTaskListStreamPrimitive calls SavePrimitive(ofstream&).
     105    //        Maybe with a cast?
    104106    virtual void StreamPrimitive(ofstream &out) const;
    105107
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r4694 r4828  
    5151
    5252#include "MIter.h"
     53#include "MTaskList.h"
    5354
    5455ClassImp(MParList);
     
    376377    TObject *l = FindObject(tlist, "MTaskList");
    377378    return (MTask*)(l ? l->FindObject(name) : NULL);
     379}
     380
     381// --------------------------------------------------------------------------
     382//
     383//  Find a tasklist which contains a task with name name
     384//
     385MTaskList *MParList::FindTaskListWithTask(const char *name) const
     386{
     387    TIter Next(fContainer);
     388    TObject *o=0;
     389    while ((o=Next()))
     390    {
     391        MTaskList *l1 = dynamic_cast<MTaskList*>(o);
     392        if (!l1)
     393            continue;
     394
     395        MTaskList *l2 = l1->FindTaskList(name);
     396        if (l2)
     397            return l2;
     398    }
     399    return 0;
     400}
     401
     402// --------------------------------------------------------------------------
     403//
     404//  Find a tasklist which contains a task task
     405//
     406MTaskList *MParList::FindTaskListWithTask(const MTask *task) const
     407{
     408    TIter Next(fContainer);
     409    TObject *o=0;
     410    while ((o=Next()))
     411    {
     412        MTaskList *l1 = dynamic_cast<MTaskList*>(o);
     413        if (!l1)
     414            continue;
     415
     416        MTaskList *l2 = l1->FindTaskList(task);
     417        if (l2)
     418            return l2;
     419    }
     420    return 0;
    378421}
    379422
  • trunk/MagicSoft/Mars/mbase/MParList.h

    r4694 r4828  
    2222class MLog;
    2323class MTask;
     24class MTaskList;
    2425
    2526class MParList : public MParContainer
     
    5354    void SetDisplay(MStatusDisplay *d);
    5455
    55     TObject *FindObject(const char *name) const;
    56     TObject *FindObject(const TObject *obj) const;
     56    TObject   *FindObject(const char *name) const;
     57    TObject   *FindObject(const TObject *obj) const;
    5758
    58     TObject *FindObject(const char *name, const char *classname) const;
    59     TObject *FindObject(const TObject *obj, const char *classname) const;
     59    TObject   *FindObject(const char *name, const char *classname) const;
     60    TObject   *FindObject(const TObject *obj, const char *classname) const;
    6061
    61     MTask   *FindTask(const char *name, const char *tlist="MTaskList") const;
     62    MTask     *FindTask(const char *name, const char *tlist="MTaskList") const;
     63    MTaskList *FindTaskListWithTask(const char *name) const;
     64    MTaskList *FindTaskListWithTask(const MTask *task) const;
    6265
    6366    MParContainer *FindCreateObj(const char *classname, const char *objname=NULL);
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r4601 r4828  
    229229Bool_t MTaskList::AddToListBefore(MTask *task, const MTask *where, const char *type)
    230230{
     231    if (task==this)
     232    {
     233        *fLog << warn << "WARNING - You cannot add a tasklist to itself.  This" << endl;
     234        *fLog << "          would create infinite recursions...ignored." << endl;
     235        return kFALSE;
     236
     237    }
     238
    231239    // FIXME: We agreed to put the task into list in an ordered way.
    232240    if (!CheckAddToList(task, type, where))
     
    249257Bool_t MTaskList::AddToListAfter(MTask *task, const MTask *where, const char *type)
    250258{
     259    if (task==this)
     260    {
     261        *fLog << warn << "WARNING - You cannot add a tasklist to itself.  This" << endl;
     262        *fLog << "          would create infinite recursions...ignored." << endl;
     263        return kFALSE;
     264
     265    }
     266
    251267    // FIXME: We agreed to put the task into list in an ordered way.
    252 
    253268    if (!CheckAddToList(task, type, where))
    254269        return kFALSE;
     
    270285Bool_t MTaskList::AddToList(MTask *task, const char *type)
    271286{
     287    if (task==this)
     288    {
     289        *fLog << warn << "WARNING - You cannot add a tasklist to itself.  This" << endl;
     290        *fLog << "          would create infinite recursions...ignored." << endl;
     291        return kFALSE;
     292
     293    }
     294
    272295    // FIXME: We agreed to put the task into list in an ordered way.
    273 
    274296    if (!CheckAddToList(task, type))
    275297        return kFALSE;
     
    301323{
    302324    return fTasks->FindObject(obj);
     325}
     326
     327// --------------------------------------------------------------------------
     328//
     329// find recursively a tasklist which contains a task with name task
     330//
     331MTaskList *MTaskList::FindTaskList(const char *task)
     332{
     333    if (FindObject(task))
     334        return this;
     335
     336    TIter Next(fTasks);
     337    TObject *o = 0;
     338    while ((o=Next()))
     339    {
     340        MTaskList *l = dynamic_cast<MTaskList*>(o);
     341        if (!l)
     342            continue;
     343
     344        if (l->FindObject(task))
     345            return l;
     346    }
     347    return 0;
     348}
     349
     350// --------------------------------------------------------------------------
     351//
     352// find recursively a tasklist which contains a task task
     353//
     354MTaskList *MTaskList::FindTaskList(const MTask *task)
     355{
     356    if (FindObject(task))
     357        return this;
     358
     359    TIter Next(fTasks);
     360    TObject *o = 0;
     361    while ((o=Next()))
     362    {
     363        MTaskList *l = dynamic_cast<MTaskList*>(o);
     364        if (!l)
     365            continue;
     366
     367        if (l->FindObject(task))
     368            return l;
     369    }
     370
     371    return 0;
    303372}
    304373
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r4601 r4828  
    6262        return (MTask*)FindObject(obj);
    6363    }
     64    MTaskList *FindTaskList(const char *task);
     65    MTaskList *FindTaskList(const MTask *task);
    6466
    6567    Bool_t ReInit(MParList *pList=NULL);
Note: See TracChangeset for help on using the changeset viewer.