Element.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 #ifndef SQUID_ESIELEMENT_H
10 #define SQUID_ESIELEMENT_H
11 
12 #include "base/RefCount.h"
13 #include "Debug.h"
14 #include "esi/Segment.h"
15 
16 #include <vector>
17 
18 typedef enum {
24 
25 class ESIElement;
26 
27 struct esiTreeParent : public RefCountable {
28  virtual void provideData (ESISegment::Pointer /* data */ , ESIElement * /* source */ ) {
29  /* make abstract when all functionality complete */
30  assert (0);
31  }
32 
33  virtual void fail(ESIElement * /* source */, char const * /* reason */ = nullptr) {}
34 
35  virtual ~esiTreeParent() {}
36 };
37 
39 
40 class ESIVarState;
41 
42 class ESIElement : public esiTreeParent
43 {
44 
45 public:
47 
48  /* the types we have */
62  };
63  static ESIElementType_t IdentifyElement (const char *);
65  /* Don't accept children */
66  debugs(86,5, "ESIElement::addElement: Failed for " << this);
67  return false;
68  }
69 
70  virtual void render (ESISegment::Pointer) = 0;
71  /* process this element */
72  virtual esiProcessResult_t process(int) {
73  debugs(86,5, "esiProcessComplete: Processed " << this);
74  return ESI_PROCESS_COMPLETE;
75  }
76 
77  virtual bool mayFail() const {
78  return true;
79  }
80 
81  virtual Pointer makeCacheable() const = 0;
83 
84  /* The top level no longer needs this element */
85  virtual void finish() = 0;
86 };
87 
89 namespace Esi {
90 
92 typedef std::vector<ESIElement::Pointer> Elements;
93 
94 } // namespace Esi
95 
99 extern void FinishAnElement(ESIElement::Pointer &, int pos = -1);
100 
101 // for all elements call finish() and set Pointer to nil
102 extern void FinishAllElements(Esi::Elements &);
103 
104 #endif /* SQUID_ESIELEMENT_H */
105 
@ ESI_ELEMENT_TRY
Definition: Element.h:54
@ ESI_PROCESS_PENDING_WONTFAIL
Definition: Element.h:20
virtual bool mayFail() const
Definition: Element.h:77
@ ESI_ELEMENT_INCLUDE
Definition: Element.h:51
@ ESI_ELEMENT_ATTEMPT
Definition: Element.h:55
@ ESI_ELEMENT_EXCEPT
Definition: Element.h:56
virtual esiProcessResult_t process(int)
Definition: Element.h:72
ESI protocol types and operators.
Definition: Element.h:89
RefCount< ESIElement > Pointer
Definition: Element.h:46
@ ESI_ELEMENT_CHOOSE
Definition: Element.h:58
@ ESI_ELEMENT_COMMENT
Definition: Element.h:52
virtual ~esiTreeParent()
Definition: Element.h:35
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
@ ESI_ELEMENT_REMOVE
Definition: Element.h:53
static ESIElementType_t IdentifyElement(const char *)
Definition: Esi.cc:852
void FinishAllElements(Esi::Elements &)
Definition: Esi.cc:1983
@ ESI_ELEMENT_NONE
Definition: Element.h:50
ESIElementType_t
Definition: Element.h:49
@ ESI_PROCESS_FAILED
Definition: Element.h:22
#define assert(EX)
Definition: assert.h:19
@ ESI_ELEMENT_ASSIGN
Definition: Element.h:61
virtual void finish()=0
virtual void render(ESISegment::Pointer)=0
esiProcessResult_t
Definition: Element.h:18
void FinishAnElement(ESIElement::Pointer &, int pos=-1)
Definition: Esi.cc:1973
@ ESI_PROCESS_PENDING_MAYFAIL
Definition: Element.h:21
virtual bool addElement(ESIElement::Pointer)
Definition: Element.h:64
virtual Pointer makeUsable(esiTreeParentPtr, ESIVarState &) const =0
@ ESI_PROCESS_COMPLETE
Definition: Element.h:19
@ ESI_ELEMENT_WHEN
Definition: Element.h:59
@ ESI_ELEMENT_OTHERWISE
Definition: Element.h:60
virtual void fail(ESIElement *, char const *=nullptr)
Definition: Element.h:33
@ ESI_ELEMENT_VARS
Definition: Element.h:57
RefCount< esiTreeParent > esiTreeParentPtr
Definition: Element.h:38
virtual Pointer makeCacheable() const =0
std::vector< ESIElement::Pointer > Elements
an ordered set of ESI elements
Definition: Element.h:92
virtual void provideData(ESISegment::Pointer, ESIElement *)
Definition: Element.h:28

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors