2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_ESIELEMENT_H
10 #define SQUID_ESIELEMENT_H
12 #include "base/RefCount.h"
14 #include "esi/Segment.h"
17 ESI_PROCESS_COMPLETE
= 0,
18 ESI_PROCESS_PENDING_WONTFAIL
= 1,
19 ESI_PROCESS_PENDING_MAYFAIL
= 2,
20 ESI_PROCESS_FAILED
= 3
25 struct esiTreeParent
: public RefCountable
{
26 virtual void provideData (ESISegment::Pointer data
, ESIElement
* source
) {
27 /* make abstract when all functionality complete */
31 virtual void fail(ESIElement
* source
, char const *reason
= NULL
) {}
33 virtual ~esiTreeParent() {}
36 typedef RefCount
<esiTreeParent
> esiTreeParentPtr
;
40 class ESIElement
: public esiTreeParent
44 typedef RefCount
<ESIElement
> Pointer
;
46 /* the types we have */
47 enum ESIElementType_t
{
58 ESI_ELEMENT_OTHERWISE
,
61 static ESIElementType_t
IdentifyElement (const char *);
62 virtual bool addElement(ESIElement::Pointer
) {
63 /* Don't accept children */
64 debugs(86,5, "ESIElement::addElement: Failed for " << this);
68 virtual void render (ESISegment::Pointer
) = 0;
69 /* process this element */
70 virtual esiProcessResult_t
process (int dovars
) {
71 debugs(86,5, "esiProcessComplete: Processed " << this);
72 return ESI_PROCESS_COMPLETE
;
75 virtual bool mayFail() const {
79 virtual Pointer
makeCacheable() const = 0;
80 virtual Pointer
makeUsable(esiTreeParentPtr
, ESIVarState
&) const = 0;
82 /* The top level no longer needs this element */
83 virtual void finish() = 0;
86 #endif /* SQUID_ESIELEMENT_H */