hlswmaster-ng/modulelist.cpp

45 lines
759 B
C++
Raw Normal View History

2006-02-02 16:55:44 +01:00
#include "logging.h"
#include "modulelist.h"
2006-02-05 16:44:38 +01:00
ModuleList::ModuleList(Config& conf)
: conf(conf)
2006-02-02 16:55:44 +01:00
{
}
ModuleList::~ModuleList()
{
while (!mlist.isEmpty())
delete mlist.get();
}
void ModuleList::reg(Module* mod)
{
2006-02-05 16:44:38 +01:00
LogSystem::log(LOG_NOTICE, "Registering module '%s'", mod->getName());
mod->init(&conf);
2006-02-02 16:55:44 +01:00
mlist.addTail(mod);
}
void ModuleList::scan(MultiSock* msock)
{
Iterator<Module> *it = mlist.createIterator();
while (it->hasNext())
it->next()->scan(msock);
delete it;
}
int ModuleList::parse(NetPkt* pkt, GameList* slist)
{
2006-02-20 12:31:34 +01:00
int retval = PARSE_REJECT;
2006-02-02 16:55:44 +01:00
Iterator<Module> *it = mlist.createIterator();
while (it->hasNext()) {
retval = it->next()->parse(pkt, slist);
2006-02-20 12:31:34 +01:00
if (retval != PARSE_REJECT)
2006-02-02 16:55:44 +01:00
break;
}
delete it;
return retval;
}