]>
Commit | Line | Data |
---|---|---|
62c7f90e AR |
1 | #ifndef SQUID_ADAPTATION__SERVICE_GROUPS_H |
2 | #define SQUID_ADAPTATION__SERVICE_GROUPS_H | |
3 | ||
8e57fe25 AR |
4 | #include "SquidString.h" |
5 | #include "Array.h" | |
62c7f90e AR |
6 | #include "adaptation/forward.h" |
7 | ||
26ac0430 AJ |
8 | namespace Adaptation |
9 | { | |
62c7f90e AR |
10 | |
11 | // Interface for grouping adaptation services together. | |
12 | // Specific groups differ in how the first and the next services are selected | |
13 | class ServiceGroup | |
14 | { | |
15 | public: | |
16 | typedef Vector<String> Store; | |
17 | typedef Store::iterator iterator; | |
18 | typedef String Id; | |
19 | ||
20 | // Information sufficient to iterate services stored in the group, | |
21 | // grouped together to simplify initial/sequentialServices interfaces. | |
26ac0430 | 22 | // The iterators point back to |
62c7f90e AR |
23 | struct Loop { |
24 | Loop(const iterator &b, const iterator &e): begin(b), end(e) {} | |
b6b637eb AR |
25 | iterator begin; |
26 | iterator end; | |
27 | }; | |
62c7f90e AR |
28 | |
29 | public: | |
30 | ServiceGroup(const String &aKind); | |
31 | virtual ~ServiceGroup(); | |
32 | ||
33 | virtual void parse(); | |
34 | virtual void finalize(); // called after all are parsed | |
35 | ||
36 | virtual Loop initialServices() = 0; | |
37 | // TODO: virtual Loop sequentialServices() = 0; | |
38 | ||
39 | public: | |
40 | String kind; | |
41 | Id id; | |
42 | Store services; | |
43 | }; | |
44 | ||
45 | // a group of equivalent services; one service per set is usually used | |
46 | class ServiceSet: public ServiceGroup | |
47 | { | |
48 | public: | |
49 | ServiceSet(); | |
50 | virtual Loop initialServices(); | |
51 | }; | |
52 | ||
53 | // corner case: a group consisting of one service | |
54 | class SingleService: public ServiceGroup | |
55 | { | |
56 | public: | |
57 | SingleService(const String &aServiceKey); | |
58 | virtual Loop initialServices(); | |
59 | }; | |
60 | ||
61 | // TODO: a group of services that must be used one after another | |
62 | // class ServiceChain: public ServiceGroup | |
63 | ||
64 | ||
65 | typedef Vector<Adaptation::ServiceGroup*> Groups; | |
66 | extern Groups &AllGroups(); | |
67 | extern ServiceGroup *FindGroup(const ServiceGroup::Id &id); | |
68 | ||
69 | ||
70 | } // namespace Adaptation | |
71 | ||
72 | #endif /* SQUID_ADAPTATION__SERVICE_GROUPS_H */ | |
73 |