Changeset 1935 for trunk


Ignore:
Timestamp:
04/10/03 10:26:07 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1934 r1935  
    11                                                 -*-*- END OF LINE -*-*-
     2
     3 2003/04/10: Thomas Bretz
     4 
     5   * mbase/MContinue.[h,cc]:
     6     - changed, so that also a filter given as a pointer is added to
     7       the tasklist automatically
     8 
     9   * mbase/MTaskList.[h,cc]:
     10     - added RemoveFromList-function
     11
     12
    213
    314 2003/04/09: Thomas Bretz
  • trunk/MagicSoft/Mars/mbase/MContinue.cc

    r1913 r1935  
    105105// --------------------------------------------------------------------------
    106106//
    107 //  In case the filter was created automatically, PreProcess tries to find
    108 //  the tasklist MTaskList, adds the filter before this instance to the
    109 //  tasklist and preprocesses the filter.
     107//  PreProcess tries to find the tasklist MTaskList, adds the filter
     108//  before this instance to the tasklist and preprocesses the filter.
    110109//
    111110Bool_t MContinue::PreProcess(MParList *list)
    112111{
    113     if (!TestBit(kIsOwner))
    114         return kTRUE;
    115 
    116     MTaskList *tlist = (MTaskList*)list->FindObject("MTaskList");
    117     if (!tlist)
    118     {
    119         *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
    120         return kFALSE;
    121     }
    122 
    123112    if (!GetFilter())
    124113    {
     
    127116    }
    128117
    129     if (!tlist->AddToListBefore(GetFilter(), this))
     118    fTaskList = (MTaskList*)list->FindObject("MTaskList");
     119    if (!fTaskList)
     120    {
     121        *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
     122        return kFALSE;
     123    }
     124
     125    if (fTaskList->FindObject(GetFilter()))
     126    {
     127        *fLog << warn << dbginf << "WARNING - The filter is already in the tasklist..." << endl;
     128        return kTRUE;
     129    }
     130
     131    if (!fTaskList->AddToListBefore(GetFilter(), this))
    130132    {
    131133        *fLog << err << dbginf << "ERROR - Adding filter before MContinue... abort." << endl;
     
    133135    }
    134136
     137    SetBit(kFilterIsPrivate);
     138
    135139    return GetFilter()->CallPreProcess(list);
    136140}
     141
     142// --------------------------------------------------------------------------
     143//
     144// If the filter was added to the tasklist automatically it is removed
     145// from the tasklist.
     146//
     147Bool_t MContinue::PostProcess()
     148{
     149    if (!TestBit(kFilterIsPrivate))
     150        return kTRUE;
     151
     152    if (fTaskList->RemoveFromList(GetFilter()))
     153        return kTRUE;
     154
     155    *fLog << err << "ERROR: MContinue::PostProcess - Cannot remove Filter from tasklist" << endl;
     156
     157    return kFALSE;
     158}
  • trunk/MagicSoft/Mars/mbase/MContinue.h

    r1715 r1935  
    1616
    1717class MFilter;
     18class MTaskList;
    1819
    1920class MContinue : public MTask
    2021{
    2122private:
     23    MTaskList *fTaskList;  //! pointer to the present tasklist
     24
    2225    Bool_t PreProcess(MParList *list);
    2326    Bool_t Process() { return kCONTINUE; }
     27    Bool_t PostProcess();
    2428
    25     enum { kIsOwner = BIT(14) };
     29    enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15) };
    2630
    2731public:
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r1902 r1935  
    754754    return kTRUE;
    755755}
     756
     757// --------------------------------------------------------------------------
     758//
     759// Removes a task from the tasklist. Returns kFALSE if the object was not
     760// found in the list.
     761//
     762Bool_t MTaskList::RemoveFromList(MTask *task)
     763{
     764    TObject *obj = fTasks->Remove(task);
     765
     766    //
     767    // If the task was found in the list try to remove it from the second
     768    // list, too.
     769    //
     770    if (obj)
     771        fTasksProcess.Remove(task);
     772
     773    return obj ? kTRUE : kFALSE;
     774
     775}
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r1880 r1935  
    4949    Bool_t AddToList(MTask *task, const char *tType="All");
    5050
     51    Bool_t RemoveFromList(MTask *task);
     52
    5153    TObject *FindObject(const char *name) const;
    5254    TObject *FindObject(const TObject *obj) const;
Note: See TracChangeset for help on using the changeset viewer.