#include "squid.h" #include "base/RunnersRegistry.h" #include #include typedef std::list Runners; typedef std::map Registries; /// all known registries static Registries *TheRegistries = NULL; /// returns the requested runners list, initializing structures as needed static Runners & GetRunners(const RunnerRegistry ®istryId) { if (!TheRegistries) TheRegistries = new Registries; if (TheRegistries->find(registryId) == TheRegistries->end()) (*TheRegistries)[registryId] = new Runners; return *(*TheRegistries)[registryId]; } int RegisterRunner(const RunnerRegistry ®istryId, RegisteredRunner *rr) { Runners &runners = GetRunners(registryId); runners.push_back(rr); return runners.size(); } int ActivateRegistered(const RunnerRegistry ®istryId) { Runners &runners = GetRunners(registryId); typedef Runners::iterator RRI; for (RRI i = runners.begin(); i != runners.end(); ++i) (*i)->run(registryId); return runners.size(); } void DeactivateRegistered(const RunnerRegistry ®istryId) { Runners &runners = GetRunners(registryId); while (!runners.empty()) { delete runners.back(); runners.pop_back(); } } bool UseThisStatic(const void *) { return true; }