/* 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 "xstd/h/iostream.h" #include #include "base/ObjId.h" #include "base/ForeignTrace.h" #include "runtime/LogComment.h" #include "client/ForeignWorld.h" int ForeignWorld::TheWss = 0; ForeignWorld::ForeignWorld() { } void ForeignWorld::configure(const String &aName) { Assert(!id()); id(UniqId::Create()); theName = aName; Comment(7) << "loading URL trace '" << theName << "'" << endl; ForeignTrace trace; trace.configure(theName); if (trace.gatherUrls(theUrls) == 0) { Comment(1) << "error: corrupted or empty trace '" << theName << "'" << endc; } } bool ForeignWorld::canProduce() const { return ObjWorld::canProduce() && theSize < theUrls.count(); } void ForeignWorld::repeat(ObjId &oid, ObjSelector *sel) { static const String tag("foreign"); oid.foreignUrl(tag); // hack: let underlying levels know the oid is foreign ObjWorld::repeat(oid, sel); Assert(oid.name() > 0); oid.foreignUrl(*theUrls[oid.name() % theUrls.count()]); // now set real URL } void ForeignWorld::produce(ObjId &oid, RndGen &rng) { ObjWorld::produce(oid, rng); incWss(TheWss); Assert(oid.name() > 0); oid.foreignUrl(*theUrls[oid.name() % theUrls.count()]); }