Panda3D

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