using namespace std;
#include "htaskset.h"
#include "hdebug.h"
#include "hmessagemgr.h"
#include "hades.h"
#include "TROOT.h"
#include "TClass.h"
#include "haddef.h"
#include "TBrowser.h"
#include <iostream>
#include <iomanip>
HTaskSet::HTaskSet(const Text_t name[],const Text_t title[]) : HTask(name,title) {
fFirstTask=0;
fNextTask=0;
fIsTimed=kFALSE;
owner=0;
for (Int_t i=0;i<8;i++) ids[i] = -1;
}
HTaskSet::HTaskSet(void) {
fIsTimed=kFALSE;
owner=0;
for (Int_t i=0;i<8;i++) ids[i] = -1;
}
HTaskSet::HTaskSet(HTaskSet &ts) {
fFirstTask=ts.fFirstTask;
fNextTask=ts.fNextTask;
fTasks.AddAll(&ts.fTasks);
fIsTimed=ts.fIsTimed;
owner=ts.owner;
for (Int_t i=0;i<8;i++) ids[i] = ts.ids[i];
}
HTaskSet::~HTaskSet(void) {
fTasks.Delete();
}
HTask* HTaskSet::getTask(const Char_t *name) {
if (strcmp(GetName(),name)==0) return this;
HTask* task=NULL;
HTask* found=NULL;
TIterator *iter=fTasks.MakeIterator();
while ( (task=(HTask*)iter->Next()) ) {
if ( (found=task->getTask(name)) ) return found;
}
return NULL;
}
Bool_t HTaskSet::add( HTask* task ){
if ( fTasks.IsEmpty() ) {
fTasks.Add( task );
fFirstTask=task;
task->setOwner(this);
return kTRUE;
} else {
HTask* pTask = (HTask*) fTasks.Last();
pTask->connectTask(task,0);
if (!(fTasks.FindObject(task))) fTasks.Add( task );
task->setOwner(this);
return kTRUE;
}
}
Bool_t HTaskSet::connect(HTask *task) {
if (!fTasks.FindObject(task)) fTasks.Add(task);
fFirstTask=task;
task->setOwner(this);
return kTRUE;
}
Bool_t HTaskSet::connect(HTask *task,HTask *where,Int_t n) {
if(!task) return kTRUE;
if (where) {
if (fTasks.FindObject(where)) {
where->connectTask(task,n);
if (!(fTasks.FindObject(task))) fTasks.Add(task);
} else return kFALSE;
} else {
fTasks.Add(task);
fFirstTask=task;
}
task->setOwner(this);
return kTRUE;
}
Bool_t HTaskSet::connect(HTask *task,const Text_t *where,Int_t n) {
if(!task) return kTRUE;
if(where) {
HTask *wh=NULL;
wh=(HTask *)fTasks.FindObject(where);
if (wh) {
if(wh->connectTask(task,n)) {
if (!(fTasks.FindObject(task))) fTasks.Add(task);
} else {
WARNING_msg(10,HMessageMgr::DET_ALL,"Problem in connecting task!\n");
return kFALSE;
}
} else return kFALSE;
task->setOwner(this);
return kTRUE;
}
return kFALSE;
}
Bool_t HTaskSet::connect(const Text_t task[],const Text_t where[],Int_t n) {
HTask *ta=NULL,*wh=NULL;
wh=(HTask *)fTasks.FindObject(where);
ta=(HTask *)fTasks.FindObject(task);
if (ta && wh) {
wh->connectTask(ta,n);
if (!(fTasks.FindObject(task))) fTasks.Add(ta);
} else return kFALSE;
ta->setOwner(this);
return kTRUE;
}
void HTaskSet::Clear(Option_t *opt) {
fTasks.Delete();
fFirstTask=NULL;
fNextTask=NULL;
}
Bool_t HTaskSet::init(void) {
TIter next(&fTasks);
HTask *task=NULL;
if(fIsTimed) resetTimer();
while ( (task=(HTask *)next())!=NULL) {
if (!task->init()) {
Error("init","%s initialization failed!",task->GetName());
return kFALSE;
}
}
return kTRUE;
}
Bool_t HTaskSet::reinit(void) {
TIter next(&fTasks);
HTask *task=NULL;
while ( (task=(HTask *)next())!=NULL) {
if (!(task->reinit())) return kFALSE;
}
return kTRUE;
}
Bool_t HTaskSet::finalize(void) {
TIter next(&fTasks);
HTask *task=NULL;
while ( (task=(HTask *)next())!=NULL) {
if (!task->finalize()) return kFALSE;
}
return kTRUE;
}
void HTaskSet::print(void) {
TIter next(&fTasks);
HTask *task=NULL;
if(owner==NULL) {
gHades->getMsg()->info(10,HMessageMgr::DET_ALL,GetName(),"=== TASK SET: %-15s ========================\n",
GetName());
}
else if(owner->getOwner()==NULL) {
gHades->getMsg()->info(10,HMessageMgr::DET_ALL,GetName(),"--- Task Set: %-15s -------------------\n",
GetName());
}
else {
gHades->getMsg()->info(10,HMessageMgr::DET_ALL,GetName(),"- - Task set: %-15s - - - - - - - -\n",
GetName());
}
while ( (task=(HTask *)next())!=NULL) {
if(strcmp((task->IsA())->GetName(),"HTaskSet")==0) {
((HTaskSet*) task)->print();
SEPERATOR_msg("-",63);
}
else { task->getConnections(); }
}
if(owner==NULL) { SEPERATOR_msg("=",63); }
}
void HTaskSet::setIds(Int_t i0, Int_t i1, Int_t i2, Int_t i3, Int_t i4,
Int_t i5, Int_t i6, Int_t i7) {
ids[0] = i0;
ids[1] = i1;
ids[2] = i2;
ids[3] = i3;
ids[4] = i4;
ids[5] = i5;
ids[6] = i6;
ids[7] = i7;
}
HTask* HTaskSet::next(Int_t &errCode, Int_t evtId) {
if (fFirstTask) {
for (Int_t i=0;i<8; i++) if (evtId==ids[i]) return next(errCode);
}
return NULL;
}
HTask *HTaskSet::next(Int_t &errCode) {
HTask *task;
if (fFirstTask==NULL) return fNextTask;
Int_t err=0;
task=fFirstTask;
while (task) {
task=task->next(err);
}
errCode=err;
if (errCode == kSTOP || errCode == kSkipEvent) return NULL;
return fNextTask;
}
Bool_t HTaskSet::connectTask(HTask *task,Int_t) {
fNextTask=task;
return kTRUE;
}
Bool_t HTaskSet::IsFolder(void) const {
return kTRUE;
}
void HTaskSet::Browse(TBrowser *b) {
TIterator *next=fTasks.MakeIterator();
TObject *task=0;
while ( (task=(HTask *)next->Next()) != 0) {
b->Add(task);
}
delete next;
}
void HTaskSet::isTimed(Bool_t flag) {
TIter next(&fTasks);
HTask *task=NULL;
while ( (task=(HTask *)next()) != NULL ) task->isTimed(flag);
fIsTimed = flag;
}
void HTaskSet::resetTimer(void) {
if(fIsTimed) {
TIter next(&fTasks);
HTask *task=NULL;
while ( (task=(HTask *)next()) != NULL ) task->resetTimer();
}
}
void HTaskSet::printTimer(void) {
if(fIsTimed) {
TIter next(&fTasks);
HTask *task=NULL;
gHades->getMsg()->infoB(10,HMessageMgr::DET_ALL,"Timing information for taskset %s:\n",this->GetName());
while ( (task=(HTask *)next()) != NULL ) task->printTimer();
}
else gHades->getMsg()->infoB(10,HMessageMgr::DET_ALL,"No timing information has been collected for taskset %s!\n",
this->GetName());
}
void HTaskSet::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
HTask::Streamer(R__b);
fTasks.Streamer(R__b);
R__b >> fNextTask;
R__b >> fFirstTask;
if (R__v > 1 )R__b.ReadStaticArray(ids);
else for (Int_t i=0; i<8; i++) ids[i] = 0;
R__b.CheckByteCount(R__s, R__c, HTaskSet::IsA());
} else {
R__c = R__b.WriteVersion(HTaskSet::IsA(), kTRUE);
HTask::Streamer(R__b);
fTasks.Streamer(R__b);
R__b << fNextTask;
R__b << fFirstTask;
R__b.WriteArray(ids, 8);
R__b.SetByteCount(R__c, kTRUE);
}
}
ClassImp(HTaskSet)
Last change: Sat May 22 13:15:28 2010
Last generated: 2010-05-22 13:15
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.