/* Web Polygraph http://www.web-polygraph.org/
* (C) 2003-2006 The Measurement Factory
* Licensed under the Apache License, Version 2.0 */
#include "pgl/pgl.h"
#include "pgl/AgentSym.h"
#include "pgl/ProxySym.h"
#include "pgl/AgentArrIter.h"
AgentArrIter::AgentArrIter(CfgSyms &aCfgSyms, const Addrs *aLocalAddrs, const String &anAgentType):
theAgentType(anAgentType), doIncludeProxySides(false) {
theCfgs = aCfgSyms;
start(aLocalAddrs);
}
void AgentArrIter::includeProxySides(bool doIt) {
doIncludeProxySides = doIt;
}
AgentSym *AgentArrIter::agentSym() {
HostsBasedSym *sym = cfgSym(theCfgIdx);
if (doIncludeProxySides && sym->isA(ProxySym::TheType)) {
ProxySym *proxy = &(ProxySym&)sym->cast(ProxySym::TheType);
sym = proxy->side(theAgentType);
}
return &(AgentSym&)sym->cast(theAgentType);
}
HostsBasedSym *AgentArrIter::cfgSym(int idx) const {
return theCfgs[idx];
}
int AgentArrIter::cfgCount() const {
return theCfgs.count();
}
bool AgentArrIter::belongs(const HostsBasedSym *cfgSym, const NetAddr &host) const {
if (doIncludeProxySides && cfgSym->isA(ProxySym::TheType)) {
ProxySym *proxy = &(ProxySym&)cfgSym->cast(ProxySym::TheType);
cfgSym = proxy->side(theAgentType);
}
return cfgSym && cfgSym->isA(theAgentType) &&
HostsBasedIter::belongs(cfgSym, host);
}
syntax highlighted by Code2HTML, v. 0.9.1