]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Moved Action initialization to object constructors.
authorKinkie <kinkie@squid-cache.org>
Thu, 3 Jul 2008 15:49:47 +0000 (17:49 +0200)
committerKinkie <kinkie@squid-cache.org>
Thu, 3 Jul 2008 15:49:47 +0000 (17:49 +0200)
src/CacheManager.h
src/cache_manager.cc

index 832d97a92bd475bb04c28b1162a2b348af1a976a..0437ec31aca6b799ae54d3aeadb91caa8aca7235 100644 (file)
@@ -35,6 +35,7 @@
 #define SQUID_CACHEMANAGER_H
 
 #include "squid.h"
+#include <list>
 
 /**
  \defgroup CacheManagerAPI Cache Manager API
@@ -51,14 +52,22 @@ public:
          unsigned int pw_req:1;
          unsigned int atomic:1;
      } flags;
+     virtual ~CacheManagerAction();
+     CacheManagerAction(char const *anAction, char const *aDesc, unsigned int isPwReq, unsigned int isAtomic);
+
      CacheManagerAction *next;
-     virtual ~CacheManagerAction() { }
 };
 
+/**
+ \ingroup CacheManagerAPI
+ * wrapper allowing c-style callbacks to be used. Arguments are supposed to
+ * managed by the caller, as they will be copied over by the constructor.
+ */
 class CacheManagerActionLegacy : public CacheManagerAction {
 public:
      OBJH *handler;
      virtual void run (StoreEntry *sentry);
+     CacheManagerActionLegacy(char const *anAction, char const *aDesc, unsigned int isPwReq, unsigned int isAtomic, OBJH *aHandler);
 };
 
 class CacheManagerShutdownAction : public CacheManagerAction {
@@ -66,14 +75,9 @@ public:
      virtual void run (StoreEntry *sentry);
 };
 
-/// \ingroup CacheManagerInternal
-typedef struct
-{
-    StoreEntry *entry;
-    char *action;
-    char *user_name;
-    char *passwd;
-} cachemgrStateData;
+class CacheManagerActionList : public std::list<CacheManagerAction> {
+       
+};
 
 /// \ingroup CacheManagerInternal
 typedef struct
index 9a616c7b78bc18d2c08da1533a88d74246964e55..9c8a6dab5f5d140ede5852f7a27488067523e982 100644 (file)
@@ -81,13 +81,8 @@ CacheManager::registerAction(char const * action, char const * desc, OBJH * hand
     }
 
     assert (strstr (" ", action) == NULL);
-    a = new CacheManagerActionLegacy;
-    a->action = xstrdup(action);
-    a->desc = xstrdup(desc);
-    a->handler = handler;
-    a->flags.pw_req = pw_req_flag;
-    a->flags.atomic = atomic;
-    a->next=0;
+    a = new CacheManagerActionLegacy(action,desc,pw_req_flag,atomic,handler);
+    a->next=0; 
 
     for (A = &ActionTable; *A; A = &(*A)->next);
     *A = a;
@@ -436,3 +431,18 @@ void CacheManagerActionLegacy::run(StoreEntry *sentry)
        handler(sentry);
 }
 
+CacheManagerAction::CacheManagerAction(char const *anAction, char const *aDesc, unsigned int isPwReq, unsigned int isAtomic)
+{
+    flags.pw_req = isPwReq;
+    flags.atomic = isAtomic;
+    action = xstrdup (anAction);
+    desc = xstrdup (aDesc);
+}
+CacheManagerAction::~CacheManagerAction() {
+    xfree(action);
+    xfree(desc);
+}
+
+CacheManagerActionLegacy::CacheManagerActionLegacy(char const *anAction, char const *aDesc, unsigned int isPwReq, unsigned int isAtomic, OBJH *aHandler) : CacheManagerAction(anAction, aDesc, isPwReq, isAtomic), handler(aHandler)
+{
+}