]> git.ipfire.org Git - thirdparty/squid.git/blob - src/CacheManager.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / CacheManager.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 #ifndef SQUID_CACHEMANAGER_H
10 #define SQUID_CACHEMANAGER_H
11
12 #include "comm/forward.h"
13 #include "mgr/Action.h"
14 #include "mgr/ActionProfile.h"
15 #include "mgr/Command.h"
16 #include "mgr/forward.h"
17
18 #include <vector>
19
20 class HttpRequest;
21
22 /**
23 * a CacheManager - the menu system for interacting with squid.
24 * This is currently just an adapter to the global cachemgr* routines to
25 * provide looser coupling between modules, but once fully transitioned,
26 * an instance of this class will represent a single independent manager.
27 * TODO: update documentation to reflect the new singleton model.
28 */
29 class CacheManager
30 {
31 public:
32 typedef std::vector<Mgr::ActionProfilePointer> Menu;
33
34 void registerProfile(char const * action, char const * desc,
35 OBJH * handler,
36 int pw_req_flag, int atomic);
37 void registerProfile(char const * action, char const * desc,
38 Mgr::ClassActionCreationHandler *handler,
39 int pw_req_flag, int atomic);
40 Mgr::ActionProfilePointer findAction(char const * action) const;
41 Mgr::Action::Pointer createNamedAction(const char *actionName);
42 Mgr::Action::Pointer createRequestedAction(const Mgr::ActionParams &);
43 const Menu& menu() const { return menu_; }
44
45 void Start(const Comm::ConnectionPointer &client, HttpRequest * request, StoreEntry * entry);
46
47 static CacheManager* GetInstance();
48 const char *ActionProtection(const Mgr::ActionProfilePointer &profile);
49
50 protected:
51 CacheManager() {} ///< use Instance() instead
52
53 Mgr::CommandPointer ParseUrl(const char *url);
54 void ParseHeaders(const HttpRequest * request, Mgr::ActionParams &params);
55 int CheckPassword(const Mgr::Command &cmd);
56 char *PasswdGet(Mgr::ActionPasswordList *, const char *);
57
58 void registerProfile(const Mgr::ActionProfilePointer &profile);
59
60 Menu menu_;
61
62 private:
63 static CacheManager* instance;
64 };
65
66 #endif /* SQUID_CACHEMANAGER_H */
67