]> git.ipfire.org Git - thirdparty/squid.git/blob - src/base/RunnersRegistry.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / base / RunnersRegistry.cc
1 #include "squid.h"
2 #include "base/RunnersRegistry.h"
3 #include <list>
4 #include <map>
5
6 typedef std::list<RegisteredRunner*> Runners;
7 typedef std::map<RunnerRegistry, Runners*> Registries;
8
9 /// all known registries
10 static Registries *TheRegistries = NULL;
11
12 /// returns the requested runners list, initializing structures as needed
13 static Runners &
14 GetRunners(const RunnerRegistry &registryId)
15 {
16 if (!TheRegistries)
17 TheRegistries = new Registries;
18
19 if (TheRegistries->find(registryId) == TheRegistries->end())
20 (*TheRegistries)[registryId] = new Runners;
21
22 return *(*TheRegistries)[registryId];
23 }
24
25 int
26 RegisterRunner(const RunnerRegistry &registryId, RegisteredRunner *rr)
27 {
28 Runners &runners = GetRunners(registryId);
29 runners.push_back(rr);
30 return runners.size();
31 }
32
33 int
34 ActivateRegistered(const RunnerRegistry &registryId)
35 {
36 Runners &runners = GetRunners(registryId);
37 typedef Runners::iterator RRI;
38 for (RRI i = runners.begin(); i != runners.end(); ++i)
39 (*i)->run(registryId);
40 return runners.size();
41 }
42
43 void
44 DeactivateRegistered(const RunnerRegistry &registryId)
45 {
46 Runners &runners = GetRunners(registryId);
47 while (!runners.empty()) {
48 delete runners.back();
49 runners.pop_back();
50 }
51 }
52
53 bool
54 UseThisStatic(const void *)
55 {
56 return true;
57 }