Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/downloader/documentSpec.I

Go to the documentation of this file.
00001 // Filename: documentSpec.I
00002 // Created by:  drose (28Jan03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: DocumentSpec::Constructor
00022 //       Access: Published
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE DocumentSpec::
00026 DocumentSpec() {
00027   _request_mode = RM_any;
00028   _cache_control = CC_allow_cache;
00029   _flags = 0;
00030 }
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: DocumentSpec::Constructor
00034 //       Access: Published
00035 //  Description:
00036 ////////////////////////////////////////////////////////////////////
00037 INLINE DocumentSpec::
00038 DocumentSpec(const string &url) :
00039   _url(url)
00040 {
00041   _request_mode = RM_any;
00042   _cache_control = CC_allow_cache;
00043   _flags = 0;
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: DocumentSpec::Constructor
00048 //       Access: Published
00049 //  Description:
00050 ////////////////////////////////////////////////////////////////////
00051 INLINE DocumentSpec::
00052 DocumentSpec(const URLSpec &url) :
00053   _url(url)
00054 {
00055   _request_mode = RM_any;
00056   _cache_control = CC_allow_cache;
00057   _flags = 0;
00058 }
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //     Function: DocumentSpec::Copy Constructor
00062 //       Access: Published
00063 //  Description:
00064 ////////////////////////////////////////////////////////////////////
00065 INLINE DocumentSpec::
00066 DocumentSpec(const DocumentSpec &copy) :
00067   _url(copy._url),
00068   _tag(copy._tag),
00069   _date(copy._date),
00070   _request_mode(copy._request_mode),
00071   _cache_control(copy._cache_control),
00072   _flags(copy._flags)
00073 {
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: DocumentSpec::Copy Assignment Operator
00078 //       Access: Published
00079 //  Description:
00080 ////////////////////////////////////////////////////////////////////
00081 INLINE void DocumentSpec::
00082 operator = (const DocumentSpec &copy) {
00083   _url = copy._url;
00084   _tag = copy._tag;
00085   _date = copy._date;
00086   _request_mode = copy._request_mode;
00087   _cache_control = copy._cache_control;
00088   _flags = copy._flags;
00089 }
00090 
00091 ////////////////////////////////////////////////////////////////////
00092 //     Function: DocumentSpec::operator ==
00093 //       Access: Published
00094 //  Description:
00095 ////////////////////////////////////////////////////////////////////
00096 INLINE bool DocumentSpec::
00097 operator == (const DocumentSpec &other) const {
00098   return compare_to(other) == 0;
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function: DocumentSpec::operator !=
00103 //       Access: Published
00104 //  Description:
00105 ////////////////////////////////////////////////////////////////////
00106 INLINE bool DocumentSpec::
00107 operator != (const DocumentSpec &other) const {
00108   return compare_to(other) != 0;
00109 }
00110 
00111 ////////////////////////////////////////////////////////////////////
00112 //     Function: DocumentSpec::operator <
00113 //       Access: Published
00114 //  Description:
00115 ////////////////////////////////////////////////////////////////////
00116 INLINE bool DocumentSpec::
00117 operator < (const DocumentSpec &other) const {
00118   return compare_to(other) < 0;
00119 }
00120 
00121 ////////////////////////////////////////////////////////////////////
00122 //     Function: DocumentSpec::set_url
00123 //       Access: Published
00124 //  Description: Changes the URL of the DocumentSpec without modifying
00125 //               its other properties.  Normally this would be a
00126 //               strange thing to do, because the tag and date are
00127 //               usually strongly associated with the URL.  To get a
00128 //               DocumentSpec pointing to a new URL, you would
00129 //               normally create a new DocumentSpec object.
00130 ////////////////////////////////////////////////////////////////////
00131 INLINE void DocumentSpec::
00132 set_url(const URLSpec &url) {
00133   _url = url;
00134 }
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: DocumentSpec::get_url
00138 //       Access: Published
00139 //  Description: Retrieves the URL of the DocumentSpec.
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE const URLSpec &DocumentSpec::
00142 get_url() const {
00143   return _url;
00144 }
00145 
00146 ////////////////////////////////////////////////////////////////////
00147 //     Function: DocumentSpec::set_tag
00148 //       Access: Published
00149 //  Description: Changes the identity tag associated with the
00150 //               DocumentSpec.
00151 ////////////////////////////////////////////////////////////////////
00152 INLINE void DocumentSpec::
00153 set_tag(const HTTPEntityTag &tag) {
00154   _tag = tag;
00155   _flags |= F_has_tag;
00156 }
00157 
00158 ////////////////////////////////////////////////////////////////////
00159 //     Function: DocumentSpec::has_tag
00160 //       Access: Published
00161 //  Description: Returns true if an identity tag is associated with
00162 //               the DocumentSpec.
00163 ////////////////////////////////////////////////////////////////////
00164 INLINE bool DocumentSpec::
00165 has_tag() const {
00166   return (_flags & F_has_tag) != 0;
00167 }
00168 
00169 ////////////////////////////////////////////////////////////////////
00170 //     Function: DocumentSpec::get_tag
00171 //       Access: Published
00172 //  Description: Returns the identity tag associated with the
00173 //               DocumentSpec, if there is one.  It is an error to
00174 //               call this if has_tag() returns false.
00175 //
00176 //               The identity tag is set by the HTTP server to
00177 //               uniquely refer to a particular version of a document.
00178 ////////////////////////////////////////////////////////////////////
00179 INLINE const HTTPEntityTag &DocumentSpec::
00180 get_tag() const {
00181   nassertr(has_tag(), _tag);
00182   return _tag;
00183 }
00184 
00185 ////////////////////////////////////////////////////////////////////
00186 //     Function: DocumentSpec::clear_tag
00187 //       Access: Published
00188 //  Description: Removes the identity tag associated with the
00189 //               DocumentSpec, if there is one.
00190 ////////////////////////////////////////////////////////////////////
00191 INLINE void DocumentSpec::
00192 clear_tag() {
00193   _flags &= ~F_has_tag;
00194 }
00195 
00196 ////////////////////////////////////////////////////////////////////
00197 //     Function: DocumentSpec::set_date
00198 //       Access: Published
00199 //  Description: Changes the last-modified date associated with the
00200 //               DocumentSpec.
00201 ////////////////////////////////////////////////////////////////////
00202 INLINE void DocumentSpec::
00203 set_date(const HTTPDate &date) {
00204   _date = date;
00205   _flags |= F_has_date;
00206 }
00207 
00208 ////////////////////////////////////////////////////////////////////
00209 //     Function: DocumentSpec::has_date
00210 //       Access: Published
00211 //  Description: Returns true if a last-modified date is associated
00212 //               with the DocumentSpec.
00213 ////////////////////////////////////////////////////////////////////
00214 INLINE bool DocumentSpec::
00215 has_date() const {
00216   return (_flags & F_has_date) != 0;
00217 }
00218 
00219 ////////////////////////////////////////////////////////////////////
00220 //     Function: DocumentSpec::get_date
00221 //       Access: Published
00222 //  Description: Returns the last-modified date associated with the
00223 //               DocumentSpec, if there is one.  It is an error to
00224 //               call this if has_date() returns false.
00225 ////////////////////////////////////////////////////////////////////
00226 INLINE const HTTPDate &DocumentSpec::
00227 get_date() const {
00228   nassertr(has_date(), _date);
00229   return _date;
00230 }
00231 
00232 ////////////////////////////////////////////////////////////////////
00233 //     Function: DocumentSpec::clear_date
00234 //       Access: Published
00235 //  Description: Removes the last-modified date associated with the
00236 //               DocumentSpec, if there is one.
00237 ////////////////////////////////////////////////////////////////////
00238 INLINE void DocumentSpec::
00239 clear_date() {
00240   _flags &= ~F_has_date;
00241 }
00242 
00243 ////////////////////////////////////////////////////////////////////
00244 //     Function: DocumentSpec::set_request_mode
00245 //       Access: Published
00246 //  Description: Sets the request mode of this DocumentSpec.  This is
00247 //               only relevant when using the DocumentSpec to generate
00248 //               a request (for instance, in HTTPChannel).  This
00249 //               specifies whether the document request will ask the
00250 //               server for a newer version than the indicated
00251 //               version, or the exact version, neither, or either.
00252 //
00253 //               The possible values are:
00254 //
00255 //                 RM_any: ignore date and tag (if specified), and
00256 //                 retrieve any document that matches the URL.  For a
00257 //                 subrange request, if the document matches the
00258 //                 version indicated exactly, retrieve the subrange
00259 //                 only; otherwise, retrieve the entire document.
00260 //
00261 //                 RM_equal: request only the precise version of the
00262 //                 document that matches the particular date and/or
00263 //                 tag exactly, if specified; fail if this version is
00264 //                 not available.
00265 //
00266 //                 RM_newer: request any document that is newer than
00267 //                 the version indicated by the particular date and/or
00268 //                 tag; fail if only that version (or older versions)
00269 //                 are available.
00270 //
00271 //                 RM_newer_or_equal: request any document that
00272 //                 matches the version indicated by the particular
00273 //                 date and/or tag, or is a newer version; fail if
00274 //                 only older versions are available.
00275 //
00276 //               In any of the above, you may specify either or both
00277 //               of the last-modified date and the identity tag,
00278 //               whichever is known to the client.
00279 //
00280 //               The default mode is RM_any.
00281 ////////////////////////////////////////////////////////////////////
00282 INLINE void DocumentSpec::
00283 set_request_mode(DocumentSpec::RequestMode request_mode) {
00284   _request_mode = request_mode;
00285 }
00286 
00287 ////////////////////////////////////////////////////////////////////
00288 //     Function: DocumentSpec::get_request_mode
00289 //       Access: Published
00290 //  Description: Returns the request mode of this DocumentSpec.  See
00291 //               set_request_mode().
00292 ////////////////////////////////////////////////////////////////////
00293 INLINE DocumentSpec::RequestMode DocumentSpec::
00294 get_request_mode() const {
00295   return _request_mode;
00296 }
00297 
00298 ////////////////////////////////////////////////////////////////////
00299 //     Function: DocumentSpec::set_cache_control
00300 //       Access: Published
00301 //  Description: Specifies what kind of cached value is acceptable for
00302 //               this document.  Warning: some HTTP proxies may not
00303 //               respect this setting and may return a cached result
00304 //               anyway.
00305 //
00306 //                 CC_allow_cache: the normal HTTP behavior; the
00307 //                 server may return a cached value if it believes it
00308 //                 is valid.
00309 //
00310 //                 CC_revalidate: a proxy is forced to contact the
00311 //                 origin server and verify that is cached value is in
00312 //                 fact still valid before it returns it.
00313 //
00314 //                 CC_no_cache: a proxy must not return its cached
00315 //                 value at all, but is forced to go all the way back
00316 //                 to the origin server for the official document.
00317 //
00318 //               The default mode is CC_allow_cache.
00319 ////////////////////////////////////////////////////////////////////
00320 INLINE void DocumentSpec::
00321 set_cache_control(DocumentSpec::CacheControl cache_control) {
00322   _cache_control = cache_control;
00323 }
00324 
00325 ////////////////////////////////////////////////////////////////////
00326 //     Function: DocumentSpec::get_cache_control
00327 //       Access: Published
00328 //  Description: Returns the request mode of this DocumentSpec.  See
00329 //               set_cache_control().
00330 ////////////////////////////////////////////////////////////////////
00331 INLINE DocumentSpec::CacheControl DocumentSpec::
00332 get_cache_control() const {
00333   return _cache_control;
00334 }
00335 
00336 INLINE istream &
00337 operator >> (istream &in, DocumentSpec &doc) {
00338   if (!doc.input(in)) {
00339     in.clear(ios::failbit | in.rdstate());
00340   }
00341   return in;
00342 }
00343 
00344 INLINE ostream &
00345 operator << (ostream &out, const DocumentSpec &doc) {
00346   doc.output(out);
00347   return out;
00348 }

Generated on Fri May 2 00:36:44 2003 for Panda by doxygen1.3