Element.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 = NULL) {}
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 dovars) {
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;
82  virtual Pointer makeUsable(esiTreeParentPtr, ESIVarState &) 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 
virtual esiProcessResult_t process(int dovars)
Definition: Element.h:72
virtual Pointer makeUsable(esiTreeParentPtr, ESIVarState &) const =0
void FinishAllElements(Esi::Elements &)
Definition: Esi.cc:1981
#define assert(EX)
Definition: assert.h:17
virtual void render(ESISegment::Pointer)=0
virtual Pointer makeCacheable() const =0
esiProcessResult_t
Definition: Element.h:18
void FinishAnElement(ESIElement::Pointer &, int pos=-1)
Definition: Esi.cc:1971
virtual void fail(ESIElement *source, char const *reason=NULL)
Definition: Element.h:33
std::vector< ESIElement::Pointer > Elements
an ordered set of ESI elements
Definition: Element.h:92
RefCount< esiTreeParent > esiTreeParentPtr
Definition: Element.h:38
void const char HLPCB void * data
Definition: stub_helper.cc:16
virtual bool addElement(ESIElement::Pointer)
Definition: Element.h:64
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
virtual void finish()=0
virtual bool mayFail() const
Definition: Element.h:77
virtual ~esiTreeParent()
Definition: Element.h:35
virtual void provideData(ESISegment::Pointer data, ESIElement *source)
Definition: Element.h:28
RefCount< ESIElement > Pointer
Definition: Element.h:46
#define NULL
Definition: types.h:166
static ESIElementType_t IdentifyElement(const char *)
Definition: Esi.cc:860
ESIElementType_t
Definition: Element.h:49

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors