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