Panda3D
 All Classes Functions Variables Enumerations
documentSpec.h
1 // Filename: documentSpec.h
2 // Created by: drose (28Jan03)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef DOCUMENTSPEC_H
16 #define DOCUMENTSPEC_H
17 
18 #include "pandabase.h"
19 #include "urlSpec.h"
20 #include "httpEntityTag.h"
21 #include "httpDate.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : DocumentSpec
25 // Description : A descriptor that refers to a particular version of a
26 // document. This includes the URL of the document and
27 // its identity tag and last-modified dates.
28 //
29 // The DocumentSpec may also be used to request a newer
30 // document than a particular one if available, for
31 // instance to refresh a cached document.
32 ////////////////////////////////////////////////////////////////////
33 class EXPCL_PANDAEXPRESS DocumentSpec {
34 PUBLISHED:
35  INLINE DocumentSpec();
36  INLINE DocumentSpec(const string &url);
37  INLINE DocumentSpec(const URLSpec &url);
38  INLINE DocumentSpec(const DocumentSpec &copy);
39  INLINE void operator = (const DocumentSpec &copy);
40 
41  INLINE bool operator == (const DocumentSpec &other) const;
42  INLINE bool operator != (const DocumentSpec &other) const;
43  INLINE bool operator < (const DocumentSpec &other) const;
44  int compare_to(const DocumentSpec &other) const;
45 
46  INLINE void set_url(const URLSpec &url);
47  INLINE const URLSpec &get_url() const;
48 
49  INLINE void set_tag(const HTTPEntityTag &tag);
50  INLINE bool has_tag() const;
51  INLINE const HTTPEntityTag &get_tag() const;
52  INLINE void clear_tag();
53 
54  INLINE void set_date(const HTTPDate &date);
55  INLINE bool has_date() const;
56  INLINE const HTTPDate &get_date() const;
57  INLINE void clear_date();
58 
59  enum RequestMode {
60  RM_any,
61  RM_equal,
62  RM_newer,
63  RM_equal_or_newer,
64  };
65 
66  INLINE void set_request_mode(RequestMode request_mode);
67  INLINE RequestMode get_request_mode() const;
68 
69  enum CacheControl {
70  CC_allow_cache,
71  CC_revalidate,
72  CC_no_cache,
73  };
74 
75  INLINE void set_cache_control(CacheControl cache_control);
76  INLINE CacheControl get_cache_control() const;
77 
78  bool input(istream &in);
79  void output(ostream &out) const;
80  void write(ostream &out, int indent_level = 0) const;
81 
82 private:
83  URLSpec _url;
84  HTTPEntityTag _tag;
85  HTTPDate _date;
86  RequestMode _request_mode;
87  CacheControl _cache_control;
88 
89  enum Flags {
90  F_has_tag = 0x0001,
91  F_has_date = 0x0002,
92  };
93  int _flags;
94 };
95 
96 INLINE istream &operator >> (istream &in, DocumentSpec &doc);
97 INLINE ostream &operator << (ostream &out, const DocumentSpec &doc);
98 
99 #include "documentSpec.I"
100 
101 #endif
A container for a URL, e.g.
Definition: urlSpec.h:29
A container for an &quot;entity tag&quot; from an HTTP server.
Definition: httpEntityTag.h:27
A container for an HTTP-legal time/date indication.
Definition: httpDate.h:30
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:79
A descriptor that refers to a particular version of a document.
Definition: documentSpec.h:33