]> git.ipfire.org Git - thirdparty/squid.git/blame - src/esi/Element.h
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / esi / Element.h
CommitLineData
43ae1d95 1/*
5b74111a 2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
43ae1d95 3 *
bbc27441
AJ
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.
43ae1d95 7 */
8
9#ifndef SQUID_ESIELEMENT_H
10#define SQUID_ESIELEMENT_H
11
8bf217bd 12#include "base/RefCount.h"
582c2af2 13#include "Debug.h"
f99c2cfe 14#include "esi/Segment.h"
43ae1d95 15
16typedef enum {
17 ESI_PROCESS_COMPLETE = 0,
18 ESI_PROCESS_PENDING_WONTFAIL = 1,
19 ESI_PROCESS_PENDING_MAYFAIL = 2,
20 ESI_PROCESS_FAILED = 3
21} esiProcessResult_t;
22
23class ESIElement;
24
26ac0430
AJ
25struct esiTreeParent : public RefCountable {
26 virtual void provideData (ESISegment::Pointer data, ESIElement * source) {
43ae1d95 27 /* make abstract when all functionality complete */
28 assert (0);
29 }
30
924f73bc 31 virtual void fail(ESIElement * source, char const *reason = NULL) {}
43ae1d95 32
26ac0430 33 virtual ~esiTreeParent() {}
3d0ac046 34};
43ae1d95 35
36typedef RefCount<esiTreeParent> esiTreeParentPtr;
37
924f73bc 38class ESIVarState;
43ae1d95 39
1735e335 40class ESIElement : public esiTreeParent
43ae1d95 41{
1735e335 42
43public:
43ae1d95 44 typedef RefCount<ESIElement> Pointer;
45
46 /* the types we have */
47 enum ESIElementType_t {
48 ESI_ELEMENT_NONE,
49 ESI_ELEMENT_INCLUDE,
50 ESI_ELEMENT_COMMENT,
51 ESI_ELEMENT_REMOVE,
52 ESI_ELEMENT_TRY,
53 ESI_ELEMENT_ATTEMPT,
54 ESI_ELEMENT_EXCEPT,
55 ESI_ELEMENT_VARS,
56 ESI_ELEMENT_CHOOSE,
57 ESI_ELEMENT_WHEN,
924f73bc 58 ESI_ELEMENT_OTHERWISE,
59 ESI_ELEMENT_ASSIGN
43ae1d95 60 };
61 static ESIElementType_t IdentifyElement (const char *);
26ac0430 62 virtual bool addElement(ESIElement::Pointer) {
43ae1d95 63 /* Don't accept children */
e680134c 64 debugs(86,5, "ESIElement::addElement: Failed for " << this);
43ae1d95 65 return false;
66 }
67
68 virtual void render (ESISegment::Pointer) = 0;
69 /* process this element */
26ac0430 70 virtual esiProcessResult_t process (int dovars) {
e680134c 71 debugs(86,5, "esiProcessComplete: Processed " << this);
43ae1d95 72 return ESI_PROCESS_COMPLETE;
73 }
74
26ac0430 75 virtual bool mayFail() const {
43ae1d95 76 return true;
77 }
78
79 virtual Pointer makeCacheable() const = 0;
924f73bc 80 virtual Pointer makeUsable(esiTreeParentPtr, ESIVarState &) const = 0;
43ae1d95 81
82 /* The top level no longer needs this element */
83 virtual void finish() = 0;
84};
85
86#endif /* SQUID_ESIELEMENT_H */
f53969cc 87