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