1 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
2 #define SQUID_ADAPTATION__ACCESS_CHECK_H
4 #include "ICAP/AsyncJob.h"
5 #include "adaptation/Elements.h"
6 #include "adaptation/forward.h"
11 namespace Adaptation
{
15 // checks adaptation_access rules to find a matching adaptation service
16 class AccessCheck
: public virtual AsyncJob
19 typedef void AccessCheckCallback(ServicePointer match
, void *data
);
21 // use this to start async ACL checks; returns true if started
22 static bool Start(Method method
, VectPoint vp
, HttpRequest
*req
,
23 HttpReply
*rep
, AccessCheckCallback
*cb
, void *cbdata
);
26 // use Start to start adaptation checks
27 AccessCheck(Method
, VectPoint
, HttpRequest
*, HttpReply
*, AccessCheckCallback
*, void *);
35 AccessCheckCallback
*callback
;
37 ACLChecklist
*acl_checklist
;
39 typedef int Candidate
;
40 typedef Vector
<Candidate
> Candidates
;
41 Candidates candidates
;
42 Candidate
topCandidate() { return *candidates
.begin(); }
45 ServicePointer
findBestService(AccessRule
&r
, bool preferUp
);
50 void checkCandidates();
51 static void AccessCheckCallbackWrapper(int, void*);
53 static EVH AccessCheckCallbackEvent
;
55 void noteAnswer(int answer
);
57 //AsyncJob virtual methods
58 virtual bool doneAll() const { return AsyncJob::doneAll() && done
;}
61 CBDATA_CLASS2(AccessCheck
);
64 } // namespace Adaptation
66 #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */