Squid Web Cache master
Loading...
Searching...
No Matches
Registration.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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#include "squid.h"
12#include "CacheManager.h"
13#include "mgr/FunAction.h"
14#include "mgr/Registration.h"
15
16namespace Mgr {
17
20{
21public:
22 explicit FunActionCreator(OBJH * const aHandler): handler(aHandler) {}
23
24 /* ActionCreator API */
25 Action::Pointer create(const CommandPointer &cmd) const override {
26 return FunAction::Create(cmd, handler);
27 }
28
29private:
31};
32
35{
36public:
38
39public:
40 ClassActionCreator(Handler * const aHandler): handler(aHandler) {}
41
42 /* ActionCreator API */
43 Action::Pointer create(const Command::Pointer &cmd) const override {
44 return handler(cmd);
45 }
46
47private:
49};
50
51} // namespace Mgr
52
53void
54Mgr::RegisterAction(char const * action, char const * desc,
55 OBJH * handler,
56 const Protected protection,
57 const Atomic atomicity,
58 const Format format)
59{
60 debugs(16, 3, "function-based " << action);
61 const auto profile = ActionProfile::Pointer::Make(action,
62 desc, new FunActionCreator(handler),
63 protection, atomicity, format);
65}
66
67void
68Mgr::RegisterAction(char const * action, char const * desc,
69 ClassActionCreationHandler *handler,
70 const Protected protection,
71 const Atomic atomicity,
72 const Format format)
73{
74 debugs(16, 3, "class-based " << action);
75 const auto profile = ActionProfile::Pointer::Make(action,
76 desc, new ClassActionCreator(handler),
77 protection, atomicity, format);
79}
80
static CacheManager * GetInstance()
void registerProfile(const Mgr::ActionProfilePointer &)
remembers the given profile while ignoring attempts to register a same-name duplicate
creates Action using supplied Action::Create method and command
Action::Pointer create(const Command::Pointer &cmd) const override
returns a pointer to the new Action object for cmd; never nil
ClassActionCreationHandler Handler
ClassActionCreator(Handler *const aHandler)
Handler * handler
configured Action object creator
creates FunAction using ActionCreator API
OBJH * handler
legacy function to pass to the FunAction wrapper
FunActionCreator(OBJH *const aHandler)
Action::Pointer create(const CommandPointer &cmd) const override
returns a pointer to the new Action object for cmd; never nil
static Pointer Create(const CommandPointer &cmd, OBJH *aHandler)
Definition FunAction.cc:25
#define debugs(SECTION, LEVEL, CONTENT)
Definition Stream.h:192
void OBJH(StoreEntry *)
Definition forward.h:44
Cache Manager API.
Definition Action.h:21
Protected
whether default cachemgr_passwd configuration denies the Action
ActionPointer() ClassActionCreationHandler(const CommandPointer &cmd)
Definition forward.h:36
Atomic
whether Action::dump() writes the entire report before returning
void RegisterAction(char const *action, char const *desc, OBJH *handler, Protected, Atomic, Format)