]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/FunAction.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / FunAction.h
1 /*
2 * $Id$
3 *
4 * DEBUG: section 16 Cache Manager API
5 *
6 */
7
8 #ifndef SQUID_MGR_FUN_ACTION_H
9 #define SQUID_MGR_FUN_ACTION_H
10
11 #include "mgr/Action.h"
12 #include "mgr/ActionCreator.h"
13
14 namespace Mgr
15 {
16
17 /// function-based cache manager Action; a wrapper for so called legacy actions
18 /// that do everything using a single OBJH function
19 class FunAction: public Action
20 {
21 protected:
22 FunAction(const CommandPointer &cmd, OBJH *aHandler);
23
24 public:
25 static Pointer Create(const CommandPointer &cmd, OBJH *aHandler);
26
27 /* Action API */
28 virtual void respond(const Request& request);
29 // we cannot aggregate because we do not even know what the handler does
30 virtual bool aggregatable() const { return false; }
31
32 protected:
33 /* Action API */
34 virtual void dump(StoreEntry *entry);
35
36 private:
37 OBJH *handler; ///< legacy function that collects and dumps info
38 };
39
40 /// creates FunAction using ActionCreator API
41 class FunActionCreator: public ActionCreator
42 {
43 public:
44 explicit FunActionCreator(OBJH *aHandler): handler(aHandler) {}
45
46 /* ActionCreator API */
47 virtual Action::Pointer create(const CommandPointer &cmd) const {
48 return FunAction::Create(cmd, handler);
49 }
50
51 private:
52 OBJH *handler; ///< legacy function to pass to the FunAction wrapper
53 };
54
55 } // namespace Mgr
56
57 #endif /* SQUID_MGR_FUN_ACTION_H */