Registration.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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 
16 namespace Mgr {
17 
20 {
21 public:
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 
29 private:
31 };
32 
35 {
36 public:
38 
39 public:
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 
47 private:
49 };
50 
51 } // namespace Mgr
52 
53 void
54 Mgr::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 
67 void
68 Mgr::RegisterAction(char const * action, char const * desc,
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 
ActionPointer() ClassActionCreationHandler(const CommandPointer &cmd)
Definition: forward.h:36
static Acl::Node * Make(TypeName typeName)
creates an Acl::Node object of the named (and already registered) Node child type
Definition: Acl.cc:61
Handler * handler
configured Action object creator
Definition: Registration.cc:48
Action::Pointer create(const CommandPointer &cmd) const override
returns a pointer to the new Action object for cmd; never nil
Definition: Registration.cc:25
FunActionCreator(OBJH *const aHandler)
Definition: Registration.cc:22
static CacheManager * GetInstance()
Protected
whether default cachemgr_passwd configuration denies the Action
ClassActionCreator(Handler *const aHandler)
Definition: Registration.cc:40
void OBJH(StoreEntry *)
Definition: forward.h:44
creates Action using supplied Action::Create method and command
Definition: Registration.cc:34
OBJH * handler
legacy function to pass to the FunAction wrapper
Definition: Registration.cc:30
static Pointer Create(const CommandPointer &cmd, OBJH *aHandler)
Definition: FunAction.cc:25
Action::Pointer create(const Command::Pointer &cmd) const override
returns a pointer to the new Action object for cmd; never nil
Definition: Registration.cc:43
void registerProfile(const Mgr::ActionProfilePointer &)
remembers the given profile while ignoring attempts to register a same-name duplicate
void RegisterAction(char const *action, char const *desc, OBJH *handler, Protected, Atomic, Format)
Definition: Registration.cc:54
Atomic
whether Action::dump() writes the entire report before returning
creates FunAction using ActionCreator API
Definition: Registration.cc:19
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:192
ClassActionCreationHandler Handler
Definition: Registration.cc:37
Cache Manager API.
Definition: Action.h:20

 

Introduction

Documentation

Support

Miscellaneous