3 * $Id: CacheManager.h,v 1.2 2008/02/26 21:49:34 amosjeffries Exp $
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
34 #ifndef SQUID_CACHEMANAGER_H
35 #define SQUID_CACHEMANAGER_H
41 \defgroup CacheManagerAPI Cache Manager API
44 \defgroup CacheManagerInternal Cache Manager intenal API (not for public use)
45 \ingroup CacheManagerAPI
49 \ingroup CacheManagerInternal
50 * The basic action handler. Its virtual method run(StoreEntry *) is invoked
51 * to perform the actual action.
53 class CacheManagerAction
{
55 virtual void run(StoreEntry
*sentry
) = 0;
60 unsigned int pw_req
:1;
61 unsigned int atomic
:1;
63 virtual ~CacheManagerAction();
64 CacheManagerAction(char const *anAction
, char const *aDesc
, unsigned int isPwReq
, unsigned int isAtomic
);
69 \ingroup CacheManagerInternal
70 * wrapper allowing c-style callbacks to be used. Arguments are supposed to
71 * managed by the caller.
72 * This object is generated by CacheManager::registerAction
74 class CacheManagerActionLegacy
: public CacheManagerAction
{
77 virtual void run (StoreEntry
*sentry
);
78 CacheManagerActionLegacy(char const *anAction
, char const *aDesc
, unsigned int isPwReq
, unsigned int isAtomic
, OBJH
*aHandler
);
83 \ingroup CacheManagerAPI
84 * a CacheManager - the menu system for interacting with squid.
85 * This is currently just an adapter to the global cachemgr* routines to
86 * provide looser coupling between modules, but once fully transitioned,
87 * an instance of this class will represent a single independent manager.
88 * TODO: update documentation to reflect the new singleton model.
94 /* the holy trinity - assignment, copy cons, destructor */
95 /* unimplemented - prevents bugs from synthetic */
96 CacheManager
& operator = (CacheManager
&);
97 /* unimplemented - prevents bugs from synthetic */
98 CacheManager(CacheManager
const &);
99 /* inline so that we dont need to link in cachemgr.cc at all in tests */
100 virtual ~CacheManager() {}
102 void registerAction(char const * action
, char const * desc
, OBJH
* handler
, int pw_req_flag
, int atomic
);
103 void registerAction(CacheManagerAction
*anAction
);
104 CacheManagerAction
* findAction(char const * action
);
106 void Start(int fd
, HttpRequest
* request
, StoreEntry
* entry
);
108 static CacheManager
* GetInstance();
109 const char *ActionProtection(const CacheManagerAction
* at
);
112 // command classes. They are private to the cachemanager, they
113 // may require access to local data, plus we avoid polluting
114 // the namespace more than needed.
115 class ShutdownAction
: public CacheManagerAction
{
117 virtual void run (StoreEntry
*sentry
);
120 class ReconfigureAction
: public CacheManagerAction
{
122 virtual void run (StoreEntry
*sentry
);
125 class OfflineToggleAction
: public CacheManagerAction
{
127 virtual void run (StoreEntry
*sentry
);
128 OfflineToggleAction();
130 class MenuAction
: public CacheManagerAction
{
132 //needs to reference the cachemgr in order to get to ActionsList
135 virtual void run (StoreEntry
*sentry
);
136 MenuAction(CacheManager
*);
140 /// \ingroup CacheManagerInternal
151 cachemgrStateData
* ParseUrl(const char *url
);
152 void ParseHeaders(cachemgrStateData
* mgr
, const HttpRequest
* request
);
153 int CheckPassword(cachemgrStateData
* mgr
);
154 char *PasswdGet(cachemgr_passwd
*, const char *);
156 // \ingroup CacheManagerInternal
157 typedef Vector
<CacheManagerAction
*> CacheManagerActionList
;
158 CacheManagerActionList ActionsList
;
162 static CacheManager
* instance
;
164 void StateFree(cachemgrStateData
* mgr
);
169 #endif /* SQUID_CACHEMANAGER_H */