1 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
2 #define SQUID_ADAPTATION__ACCESS_CHECK_H
4 #include "AccessLogEntry.h"
6 #include "adaptation/Elements.h"
7 #include "adaptation/forward.h"
8 #include "adaptation/Initiator.h"
9 #include "adaptation/ServiceFilter.h"
10 #include "base/AsyncJob.h"
14 class ACLFilledChecklist
;
21 // checks adaptation_access rules to find a matching adaptation service
22 class AccessCheck
: public virtual AsyncJob
25 typedef void AccessCheckCallback(ServiceGroupPointer group
, void *data
);
27 // use this to start async ACL checks; returns true if started
28 static bool Start(Method method
, VectPoint vp
, HttpRequest
*req
,
29 HttpReply
*rep
, AccessLogEntry::Pointer
&al
, Adaptation::Initiator
*initiator
);
32 // use Start to start adaptation checks
33 AccessCheck(const ServiceFilter
&aFilter
, Adaptation::Initiator
*);
37 const ServiceFilter filter
;
38 CbcPointer
<Adaptation::Initiator
> theInitiator
; ///< the job which ordered this access check
39 ACLFilledChecklist
*acl_checklist
;
41 typedef int Candidate
;
42 typedef std::vector
<Candidate
> Candidates
;
43 Candidates candidates
;
44 Candidate
topCandidate() const { return *candidates
.begin(); }
45 ServiceGroupPointer
topGroup() const; // may return nil
47 void callBack(const ServiceGroupPointer
&g
);
48 bool isCandidate(AccessRule
&r
);
51 void checkCandidates();
52 static void AccessCheckCallbackWrapper(allow_t
, void*);
53 void noteAnswer(allow_t answer
);
58 virtual bool doneAll() const { return false; } /// not done until mustStop
60 bool usedDynamicRules();
64 CBDATA_CLASS2(AccessCheck
);
67 } // namespace Adaptation
69 #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */