Panda3D

Loading...
Searching...
No Matches
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 {
31PUBLISHED:
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
79PUBLISHED:
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
101INLINE std::istream &operator >> (std::istream &in, DocumentSpec &doc);
102INLINE 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
DocumentSpec::set_date
set_date
Changes the last-modified date associated with the DocumentSpec.
Definition documentSpec.h:82
DocumentSpec::set_cache_control
set_cache_control
Specifies what kind of cached value is acceptable for this document.
Definition documentSpec.h:85
DocumentSpec::get_cache_control
get_cache_control
Returns the request mode of this DocumentSpec.
Definition documentSpec.h:85
DocumentSpec::set_tag
set_tag
Changes the identity tag associated with the DocumentSpec.
Definition documentSpec.h:81
DocumentSpec::get_request_mode
get_request_mode
Returns the request mode of this DocumentSpec.
Definition documentSpec.h:84
DocumentSpec::get_url
get_url
Retrieves the URL of the DocumentSpec.
Definition documentSpec.h:80
DocumentSpec::set_url
set_url
Changes the URL of the DocumentSpec without modifying its other properties.
Definition documentSpec.h:80
DocumentSpec::get_tag
get_tag
Returns the identity tag associated with the DocumentSpec, if there is one.
Definition documentSpec.h:81
DocumentSpec::set_request_mode
set_request_mode
Sets the request mode of this DocumentSpec.
Definition documentSpec.h:84
DocumentSpec::clear_date
clear_date
Removes the last-modified date associated with the DocumentSpec, if there is one.
Definition documentSpec.h:82
DocumentSpec::get_date
get_date
Returns the last-modified date associated with the DocumentSpec, if there is one.
Definition documentSpec.h:82
DocumentSpec::clear_tag
clear_tag
Removes the identity tag associated with the DocumentSpec, if there is one.
Definition documentSpec.h:81
DocumentSpec::has_date
has_date
Returns true if a last-modified date is associated with the DocumentSpec.
Definition documentSpec.h:82
DocumentSpec::input
bool input(std::istream &in)
Can be used to read in the DocumentSpec from a stream generated either by output() or write().
Definition documentSpec.cxx:54
DocumentSpec::has_tag
has_tag
Returns true if an identity tag is associated with the DocumentSpec.
Definition documentSpec.h:81
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
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.