/* Web Polygraph       http://www.web-polygraph.org/
 * (C) 2003-2006 The Measurement Factory
 * Licensed under the Apache License, Version 2.0 */

#include "base/polygraph.h"

#include "runtime/HostMap.h"
#include "client/Client.h"
#include "client/CltCfg.h"
#include "client/PrivWorlds.h"


PrivWorldIterator::PrivWorldIterator(Client *aClient): theClient(aClient), 
	theIdx(0) {
	sync();
}

int PrivWorldIterator::count() const {
	return theClient->theCfg->theViservs.count();
}

bool PrivWorldIterator::atEnd() const {
	return theIdx >= count();
}

int PrivWorldIterator::viserv() const {
	return theClient->theCfg->theViservs[theIdx];
}

HostCfg *PrivWorldIterator::host() const {
	return TheHostMap->at(viserv());
}

const NetAddr &PrivWorldIterator::addr() const {
	return host()->theAddr;
}

PrivWorld &PrivWorldIterator::privWorld() const {
	return theClient->thePrivWorlds[viserv()];
}

PrivWorldIterator &PrivWorldIterator::operator ++() {
	next();
	return *this;
}

void PrivWorldIterator::next() {
	theIdx++;
	sync();
}

void PrivWorldIterator::sync() {
	// all priv worlds should be returned; theViserv index determines what
	// priv worlds are in use, and that's the index we iterate here
	return;
}


syntax highlighted by Code2HTML, v. 0.9.1