};
-class CacheManagerActionList : public Vector<CacheManagerAction *> {
-};
-
/**
\ingroup CacheManagerAPI
* a CacheManager - the menu system for interacting with squid.
void Start(int fd, HttpRequest * request, StoreEntry * entry);
static CacheManager* GetInstance();
- const char *ActionProtection(const CacheManagerAction * at); //needs to be called from C
+ const char *ActionProtection(const CacheManagerAction * at);
protected:
- // command classes. They are private to the cachemanager because they
- // may require access to local data sources, plus we avoid polluting
+ // command classes. They are private to the cachemanager, they
+ // may require access to local data, plus we avoid polluting
// the namespace more than needed.
class ShutdownAction : public CacheManagerAction {
public:
OfflineToggleAction();
};
class MenuAction : public CacheManagerAction {
+ private:
+ //needs to reference the cachemgr in order to get to ActionsList
+ CacheManager *cmgr;
public:
virtual void run (StoreEntry *sentry);
- MenuAction();
+ MenuAction(CacheManager *);
+
};
-/// \ingroup CacheManagerInternal
-typedef struct
-{
- StoreEntry *entry;
- char *action;
- char *user_name;
- char *passwd;
-} cachemgrStateData;
+ /// \ingroup CacheManagerInternal
+ typedef struct
+ {
+ StoreEntry *entry;
+ char *action;
+ char *user_name;
+ char *passwd;
+ } cachemgrStateData;
CacheManager();
int CheckPassword(cachemgrStateData * mgr);
char *PasswdGet(cachemgr_passwd *, const char *);
+ // \ingroup CacheManagerInternal
+ typedef Vector<CacheManagerAction *> CacheManagerActionList;
+ CacheManagerActionList ActionsList;
+
+
private:
static CacheManager* instance;
-/// \ingroup CacheManagerInternal
-CacheManagerActionList *ActionsList = NULL;
-
CacheManager::CacheManager()
{
- if (ActionsList != NULL)
- delete(ActionsList); //TODO: Laaazy. Will be moved to class member
- ActionsList = new CacheManagerActionList;
+ //if (ActionsList != NULL)
+ // delete(ActionsList); //TODO: Laaazy. Will be moved to class member
+ //ActionsList = new CacheManagerActionList;
registerAction(new OfflineToggleAction);
registerAction(new ShutdownAction);
registerAction(new ReconfigureAction);
- registerAction(new MenuAction);
+ registerAction(new MenuAction(this));
}
void
assert (strstr (" ", action) == NULL);
- *ActionsList += anAction;
+ ActionsList += anAction;
debugs(16, 3, "CacheManager::registerAction: registered " << action);
}
CacheManagerActionList::iterator a;
debugs(16, 5, "CacheManager::findAction: looking for action " << action);
- for ( a = ActionsList->begin(); a != ActionsList->end(); a++) {
+ for ( a = ActionsList.begin(); a != ActionsList.end(); a++) {
if (0 == strcmp((*a)->action, action)) {
debugs(16, 6, " found");
return *a;
CacheManagerActionList::iterator a;
debugs(16, 4, "CacheManager::MenuCommand invoked");
- for (a = ActionsList->begin(); a != ActionsList->end(); ++a) {
+ for (a = cmgr->ActionsList.begin(); a != cmgr->ActionsList.end(); ++a) {
debugs(16, 5, " showing action " << (*a)->action);
storeAppendPrintf(sentry, " %-22s\t%-32s\t%s\n",
- (*a)->action, (*a)->desc, CacheManager::GetInstance()->ActionProtection(*a));
+ (*a)->action, (*a)->desc, cmgr->ActionProtection(*a));
}
}
-CacheManager::MenuAction::MenuAction() : CacheManagerAction ("menu", "Cache Manager Menu", 1, 1) { }
+CacheManager::MenuAction::MenuAction(CacheManager *aMgr) : CacheManagerAction ("menu", "Cache Manager Menu", 1, 1), cmgr(aMgr) { }
/// \ingroup CacheManagerInternal
char *