HttpHdrScTarget.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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_SRC_HTTPHDRSCTARGET_H
10 #define SQUID_SRC_HTTPHDRSCTARGET_H
11 
12 #include "defines.h" //for bit mask operations
13 #include "http/forward.h"
14 #include "SquidString.h"
15 
16 class Packable;
17 class StatHist;
18 class StoreEntry;
19 
25 {
26  // parsing is done in HttpHdrSc, need to grant them access.
27  friend class HttpHdrSc;
28 public:
29  static const int MAX_AGE_UNSET=-1; //max-age is unset
30  static const int MAX_STALE_UNSET=0; //max-stale is unset
31 
32  explicit HttpHdrScTarget(const char *aTarget): target(aTarget) {}
33  explicit HttpHdrScTarget(const String &aTarget): target(aTarget) {}
34  explicit HttpHdrScTarget(const HttpHdrScTarget &) = delete; // avoid accidental string copies
35  HttpHdrScTarget &operator =(const HttpHdrScTarget &) = delete; // avoid accidental string copies
36 
37  bool hasNoStore() const {return isSet(SC_NO_STORE); }
38  void noStore(bool v) { setMask(SC_NO_STORE,v); }
39  bool noStore() const { return isSet(SC_NO_STORE); }
40  void clearNoStore() { setMask(SC_NO_STORE, false); }
41 
42  bool hasNoStoreRemote() const {return isSet(SC_NO_STORE_REMOTE); }
44  bool noStoreRemote() const { return isSet(SC_NO_STORE_REMOTE); }
46 
47  bool hasMaxAge() const { return isSet(SC_MAX_AGE); }
48  void maxAge(int v) {
49  if (v >= 0) { //setting
50  setMask(SC_MAX_AGE,true);
51  max_age=v;
52  } else {
53  setMask(SC_MAX_AGE,false);
55  }
56  }
57  int maxAge() const { return max_age; }
59 
60  //max_stale has no associated status-bit
61  bool hasMaxStale() const { return max_stale != MAX_STALE_UNSET; }
62  void maxStale(int v) { max_stale=v; }
63  int maxStale() const { return max_stale; }
65 
66  bool hasContent() const { return isSet(SC_CONTENT); }
67  void Content(const String &v) {
68  setMask(SC_CONTENT,true);
69  content_=v;
70  }
71  String content() const { return content_; }
73 
74  bool hasTarget() const { return target.size() != 0; }
75  String Target() const { return target; }
76 
77  void mergeWith(const HttpHdrScTarget * new_sc);
78  void packInto(Packable *p) const;
79  void updateStats(StatHist *) const;
80 
81 private:
82  bool isSet(http_hdr_sc_type id) const {
83  assert (id >= SC_NO_STORE && id < SC_ENUM_END);
84  return EBIT_TEST(mask,id);
85  }
86 
87  void setMask(http_hdr_sc_type id, bool newval) {
88  if (newval) EBIT_SET(mask,id);
89  else EBIT_CLR(mask,id);
90  }
91 
92  int mask = 0;
97 };
98 
99 void httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size, int count);
100 
101 #endif /* SQUID_SRC_HTTPHDRSCTARGET_H */
102 
#define EBIT_CLR(flag, bit)
Definition: defines.h:66
#define EBIT_SET(flag, bit)
Definition: defines.h:65
bool noStore() const
HttpHdrScTarget(const String &aTarget)
bool hasTarget() const
void packInto(Packable *p) const
XXX: this function should be in HttpHdrScTarget.cc.
Definition: HttpHdrSc.cc:198
void mergeWith(const HttpHdrScTarget *new_sc)
void noStoreRemote(bool v)
HttpHdrScTarget(const char *aTarget)
@ SC_NO_STORE
Definition: forward.h:32
bool isSet(http_hdr_sc_type id) const
http_hdr_sc_type
Definition: forward.h:31
bool noStoreRemote() const
void clearNoStoreRemote()
int size
Definition: ModDevPoll.cc:69
@ SC_CONTENT
Definition: forward.h:35
bool hasNoStore() const
HttpHdrScTarget & operator=(const HttpHdrScTarget &)=delete
#define EBIT_TEST(flag, bit)
Definition: defines.h:67
#define assert(EX)
Definition: assert.h:17
@ SC_ENUM_END
Definition: forward.h:37
String Target() const
String content() const
@ SC_MAX_AGE
Definition: forward.h:34
static const int MAX_AGE_UNSET
void maxAge(int v)
static const int MAX_STALE_UNSET
void updateStats(StatHist *) const
size_type size() const
Definition: SquidString.h:73
int maxAge() const
void setMask(http_hdr_sc_type id, bool newval)
void httpHdrScTargetStatDumper(StoreEntry *sentry, int idx, double val, double size, int count)
Definition: HttpHdrSc.cc:257
bool hasMaxStale() const
void noStore(bool v)
bool hasContent() const
void Content(const String &v)
@ SC_NO_STORE_REMOTE
Definition: forward.h:33
int maxStale() const
bool hasMaxAge() const
bool hasNoStoreRemote() const
void clean()
Definition: String.cc:103
void maxStale(int v)

 

Introduction

Documentation

Support

Miscellaneous