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