/* Web Polygraph http://www.web-polygraph.org/ * (C) 2003-2006 The Measurement Factory * Licensed under the Apache License, Version 2.0 */ #ifndef POLYGRAPH__RUNTIME_HOSTMAP_H #define POLYGRAPH__RUNTIME_HOSTMAP_H #include "xstd/Array.h" #include "xstd/NetAddr.h" class ContentSel; class ServerRep; class SslWrap; class PubWorld; class HttpCookies; // Host configuration record class HostCfg { public: HostCfg(const NetAddr &anAddr); public: NetAddr theAddr; ContentSel *theContent; // can be shared among HostCfgs const SslWrap *theSslWrap; // can be shared among HostCfgs ServerRep *theServerRep; PubWorld *thePubWorld; // for visible servers only HttpCookies *theCookies; }; // a NetAddr <-> Host configuration map // add-only operation class HostMap { public: HostMap(int aCapacity); // cap may be adjusted a bit ~HostMap(); int capacity() const { return theIndex.capacity(); } int hostCount() const { return theCount; } int iterationCount() const { return theIndex.count(); } HostCfg *at(int idx); // idx may be out of bounds HostCfg *at(const NetAddr &addr); ServerRep *serverRepAt(int idx); const SslWrap *findSslWrap(const NetAddr &addr) const; PubWorld *findPubWorld(const NetAddr &addr); PubWorld *findPubWorldAt(int idx); HostCfg *find(const NetAddr &addr); HostCfg *find(const NetAddr &addr, int &idx); bool findIdx(const NetAddr &addr, int &idx) const; HostCfg *addAt(int idx, const NetAddr &addr); protected: bool endSearch(const NetAddr &addr, int idx, bool &res) const; int hash0(const NetAddr &addr) const; int hash1(const NetAddr &addr) const; protected: Array theIndex; int theCount; // entries in the hash }; extern HostMap *TheHostMap; // move to globals? #endif