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