PHModuleManager.C
//-----------------------------------------------------------------------------
// $Header: /afs/rhic/phenix/cvsroot/offline/framework/phool/PHModuleManager.C,v 1.5 2000/10/17 19:17:54 irina Exp $
//
// The PHOOL's Software
// Copyright (C) PHENIX collaboration, 1999
//
// Implementation of class ...
//
// Author: Matthias Messer
//-----------------------------------------------------------------------------
#include "PHModuleManager.h"
#include "PHDataNode.h"
#include "PHModule.h"
#include "PHNodeIterator.h"
#include "PHCallEvent.h"
#include "PHCallInit.h"
PHModuleManager::PHModuleManager()
{
modules = new PHCompositeNode("modules");
}
PHModuleManager::~PHModuleManager()
{
//
// Note: This will delete the whole tree of module-nodes
// and thus also the modules themselves.
//
delete modules;
}
void PHModuleManager::clear()
{
delete modules;
modules = new PHCompositeNode("modules");
}
PHBoolean PHModuleManager::append(PHModule* module)
{
if (module) {
modules->addNode(new PHDataNode<PHModule>(module, module->getName()));
return True;
}
else {
return False;
}
}
PHModule* PHModuleManager::remove(const PHString& searchName)
{
PHNodeIterator moduleIter(modules);
PHDataNode<PHModule> *node = (PHDataNode<PHModule>*)moduleIter.findFirst("PHDataNode", searchName);
PHModule *module = 0;
if (node) {
module = node->getData();
node->setData(0);
delete node;
}
return module;
}
void PHModuleManager::event(PHCompositeNode *startNode) const
{
PHNodeIterator moduleIter(modules);
PHCallEvent callEvent(startNode);
moduleIter.forEach(callEvent);
}
void PHModuleManager::init()
{
PHNodeIterator moduleIter(modules);
PHCallInit callInit;
moduleIter.forEach(callInit);
}
//
// Non member functions
//
PHModuleManager& operator << (PHModuleManager& manager, PHModule* anotherModule)
{
manager.append(anotherModule);
return manager;
}