hlswmaster-ng/modulelist.cpp

45 lines
755 B
C++

#include "modulelist.h"
#include "logging.h"
ModuleList::ModuleList(Config& conf)
: conf(conf)
{
}
ModuleList::~ModuleList()
{
while (!mlist.isEmpty())
delete mlist.get();
}
void ModuleList::reg(Module* mod)
{
LogSystem::log(LOG_NOTICE, "Registering module '%s'", mod->getName());
mod->init(&conf);
mlist.add(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)
{
int retval = PARSE_REJECT;
Iterator<Module> *it = mlist.createIterator();
while (it->hasNext()) {
retval = it->next()->parse(pkt, slist);
if (retval != PARSE_REJECT)
break;
}
delete it;
return retval;
}