Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > c9cfbd1355daacaf3b34517a6d7b18cc > files > 211

libdap-doc-3.11.0-2.fc15.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>libdap++: HTTPCacheTable.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libdap++&#160;<span id="projectnumber">Updated for version 3.8.2</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('HTTPCacheTable_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<h1>HTTPCacheTable.h</h1>  </div>
</div>
<div class="contents">
<a href="HTTPCacheTable_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">// -*- mode: c++; c-basic-offset:4 -*-</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="comment">// This file is part of libdap, A C++ implementation of the OPeNDAP Data</span>
<a name="l00005"></a>00005 <span class="comment">// Access Protocol.</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="comment">// Copyright (c) 2008 OPeNDAP, Inc.</span>
<a name="l00008"></a>00008 <span class="comment">// Author: James Gallagher &lt;jgallagher@opendap.org&gt;</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// This library is free software; you can redistribute it and/or</span>
<a name="l00011"></a>00011 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span>
<a name="l00012"></a>00012 <span class="comment">// License as published by the Free Software Foundation; either</span>
<a name="l00013"></a>00013 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// This library is distributed in the hope that it will be useful,</span>
<a name="l00016"></a>00016 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00017"></a>00017 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00018"></a>00018 <span class="comment">// Lesser General Public License for more details.</span>
<a name="l00019"></a>00019 <span class="comment">//</span>
<a name="l00020"></a>00020 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span>
<a name="l00021"></a>00021 <span class="comment">// License along with this library; if not, write to the Free Software</span>
<a name="l00022"></a>00022 <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<a name="l00023"></a>00023 <span class="comment">//</span>
<a name="l00024"></a>00024 <span class="comment">// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#ifndef _http_cache_table_h</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#define _http_cache_table_h</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span>
<a name="l00029"></a>00029 <span class="comment">//#define DODS_DEBUG</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;pthread.h&gt;</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="preprocessor">#ifdef WIN32</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span><span class="preprocessor">#include &lt;io.h&gt;</span>   <span class="comment">// stat for win32? 09/05/02 jhrg</span>
<a name="l00035"></a>00035 <span class="preprocessor">#endif</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="preprocessor">#ifndef _error_h</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="Error_8h.html">Error.h</a>&quot;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#endif</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>
<a name="l00045"></a>00045 <span class="preprocessor">#ifndef _internalerr_h</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="InternalErr_8h.html">InternalErr.h</a>&quot;</span>
<a name="l00047"></a>00047 <span class="preprocessor">#endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a>00049 <span class="preprocessor">#ifndef _debug_h</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="debug_8h.html">debug.h</a>&quot;</span>
<a name="l00051"></a>00051 <span class="preprocessor">#endif</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span>
<a name="l00053"></a><a class="code" href="HTTPCacheTable_8h.html#a16e4e2643dc8f8b07b8be8bebd189ad5">00053</a> <span class="preprocessor">#define LOCK(m) pthread_mutex_lock((m))</span>
<a name="l00054"></a><a class="code" href="HTTPCacheTable_8h.html#aea719fb108b1d8bb9214dc49204ad0f0">00054</a> <span class="preprocessor"></span><span class="preprocessor">#define TRYLOCK(m) pthread_mutex_trylock((m))</span>
<a name="l00055"></a><a class="code" href="HTTPCacheTable_8h.html#af2aa2fe13863361670b63de7e6df0fdd">00055</a> <span class="preprocessor"></span><span class="preprocessor">#define UNLOCK(m) pthread_mutex_unlock((m))</span>
<a name="l00056"></a><a class="code" href="HTTPCacheTable_8h.html#a80412ba526b7b04f6784d1f992be57e9">00056</a> <span class="preprocessor"></span><span class="preprocessor">#define INIT(m) pthread_mutex_init((m), 0)</span>
<a name="l00057"></a><a class="code" href="HTTPCacheTable_8h.html#aa713a380e0f57370ec8380acf82b951c">00057</a> <span class="preprocessor"></span><span class="preprocessor">#define DESTROY(m) pthread_mutex_destroy((m))</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span>
<a name="l00059"></a>00059 <span class="keyword">using namespace </span>std;
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 <span class="keyword">namespace </span>libdap
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 <span class="keywordtype">int</span> <a class="code" href="namespacelibdap.html#a68a16ef70e29c367dabd3cb5165c386a">get_hash</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;url);
<a name="l00065"></a>00065 
<a name="l00081"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html">00081</a> <span class="keyword">class </span><a class="code" href="classlibdap_1_1HTTPCacheTable.html">HTTPCacheTable</a> {
<a name="l00082"></a>00082 <span class="keyword">public</span>:
<a name="l00094"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html">00094</a>         <span class="keyword">struct </span><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html">CacheEntry</a>
<a name="l00095"></a>00095         {
<a name="l00096"></a>00096         <span class="keyword">private</span>:
<a name="l00097"></a>00097                 <span class="keywordtype">string</span> url;  <span class="comment">// Location</span>
<a name="l00098"></a>00098             <span class="keywordtype">int</span> hash;
<a name="l00099"></a>00099             <span class="keywordtype">int</span> hits;  <span class="comment">// Hit counts</span>
<a name="l00100"></a>00100             <span class="keywordtype">string</span> cachename;
<a name="l00101"></a>00101 
<a name="l00102"></a>00102             <span class="keywordtype">string</span> etag;
<a name="l00103"></a>00103             time_t lm;  <span class="comment">// Last modified</span>
<a name="l00104"></a>00104             time_t expires;
<a name="l00105"></a>00105             time_t date;  <span class="comment">// From the response header.</span>
<a name="l00106"></a>00106             time_t age;
<a name="l00107"></a>00107             time_t max_age;  <span class="comment">// From Cache-Control</span>
<a name="l00108"></a>00108 
<a name="l00109"></a>00109             <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> size; <span class="comment">// Size of cached entity body</span>
<a name="l00110"></a>00110             <span class="keywordtype">bool</span> range;  <span class="comment">// Range is not currently supported. 10/02/02 jhrg</span>
<a name="l00111"></a>00111 
<a name="l00112"></a>00112             time_t freshness_lifetime;
<a name="l00113"></a>00113             time_t response_time;
<a name="l00114"></a>00114             time_t corrected_initial_age;
<a name="l00115"></a>00115 
<a name="l00116"></a>00116             <span class="keywordtype">bool</span> must_revalidate;
<a name="l00117"></a>00117             <span class="keywordtype">bool</span> no_cache;  <span class="comment">// This field is not saved in the index.</span>
<a name="l00118"></a>00118 
<a name="l00119"></a>00119             <span class="keywordtype">int</span> readers;
<a name="l00120"></a>00120             pthread_mutex_t d_response_lock;            <span class="comment">// set if being read</span>
<a name="l00121"></a>00121             pthread_mutex_t d_response_write_lock;      <span class="comment">// set if being written</span>
<a name="l00122"></a>00122 
<a name="l00123"></a>00123             <span class="comment">// Allow HTTPCacheTable methods access and the test class, too</span>
<a name="l00124"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a10b3dd04aa2ab3de230f8102d4293d17">00124</a>             <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classlibdap_1_1HTTPCacheTable.html">HTTPCacheTable</a>;
<a name="l00125"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a76bd6ce419aad54c8c87e993f5bd11c9">00125</a>                 <span class="keyword">friend</span> <span class="keyword">class </span>HTTPCacheTest;
<a name="l00126"></a>00126             
<a name="l00127"></a>00127                 <span class="comment">// Allow access by the fucntors used in HTTPCacheTable</span>
<a name="l00128"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a7ed7618e87371b669cb062d8315022b6">00128</a>                 <span class="keyword">friend</span> <span class="keyword">class </span>DeleteCacheEntry;
<a name="l00129"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ac86f22df4e25865ad192898454e22534">00129</a>             <span class="keyword">friend</span> <span class="keyword">class </span>WriteOneCacheEntry;
<a name="l00130"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a2084b474fcedc349564e2ad51420c464">00130</a>             <span class="keyword">friend</span> <span class="keyword">class </span>DeleteExpired;
<a name="l00131"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ac472190ef1064a54cdd7ce172a30c57d">00131</a>             <span class="keyword">friend</span> <span class="keyword">class </span>DeleteByHits;
<a name="l00132"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ae50b4ed6c2560ac5bce0f837c1c29f8a">00132</a>             <span class="keyword">friend</span> <span class="keyword">class </span>DeleteBySize;
<a name="l00133"></a>00133 
<a name="l00134"></a>00134         <span class="keyword">public</span>:
<a name="l00135"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a78b388e7b644a3548a7d548550603fd9">00135</a>                 <span class="keywordtype">string</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a78b388e7b644a3548a7d548550603fd9">get_cachename</a>() {
<a name="l00136"></a>00136                         <span class="keywordflow">return</span> cachename;
<a name="l00137"></a>00137                 }
<a name="l00138"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a6c442bb2e75458b0221fdc0e33a1b987">00138</a>                 <span class="keywordtype">string</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a6c442bb2e75458b0221fdc0e33a1b987">get_etag</a>() {
<a name="l00139"></a>00139                         <span class="keywordflow">return</span> etag;
<a name="l00140"></a>00140                 }
<a name="l00141"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a45a937fc7a01fe7b9eff6ed71234ae90">00141</a>                 time_t <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a45a937fc7a01fe7b9eff6ed71234ae90">get_lm</a>() {
<a name="l00142"></a>00142                         <span class="keywordflow">return</span> lm;
<a name="l00143"></a>00143                 }
<a name="l00144"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ad6c75b405f431deafaba0ce949e514bc">00144</a>                 time_t <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ad6c75b405f431deafaba0ce949e514bc">get_expires</a>() {
<a name="l00145"></a>00145                         <span class="keywordflow">return</span> expires;
<a name="l00146"></a>00146                 }
<a name="l00147"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a15c27c48f367f79bded48569b4d12351">00147</a>                 time_t <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a15c27c48f367f79bded48569b4d12351">get_max_age</a>() {
<a name="l00148"></a>00148                         <span class="keywordflow">return</span> max_age;
<a name="l00149"></a>00149                 }
<a name="l00150"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a6711b2f4b3ebc87f2f6b87da87d0f44b">00150</a>                 <span class="keywordtype">void</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a6711b2f4b3ebc87f2f6b87da87d0f44b">set_size</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> sz) {
<a name="l00151"></a>00151                         size = sz;
<a name="l00152"></a>00152                 }
<a name="l00153"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a59da6c588993d40d2829a90cc0c67f1a">00153</a>                 time_t <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a59da6c588993d40d2829a90cc0c67f1a">get_freshness_lifetime</a>() {
<a name="l00154"></a>00154                         <span class="keywordflow">return</span> freshness_lifetime;
<a name="l00155"></a>00155                 }
<a name="l00156"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a7002294360aa52d1dd86dedca57c7e6d">00156</a>                 time_t <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a7002294360aa52d1dd86dedca57c7e6d">get_response_time</a>() {
<a name="l00157"></a>00157                         <span class="keywordflow">return</span> response_time;
<a name="l00158"></a>00158                 }
<a name="l00159"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a83412eeb15ec59d73b2407943d0a4a04">00159</a>                 time_t <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a83412eeb15ec59d73b2407943d0a4a04">get_corrected_initial_age</a>() {
<a name="l00160"></a>00160                         <span class="keywordflow">return</span> corrected_initial_age;
<a name="l00161"></a>00161                 }
<a name="l00162"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ad654840f637bcaf7232ccf851469daba">00162</a>                 <span class="keywordtype">bool</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ad654840f637bcaf7232ccf851469daba">get_must_revalidate</a>() {
<a name="l00163"></a>00163                         <span class="keywordflow">return</span> must_revalidate;
<a name="l00164"></a>00164                 }
<a name="l00165"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a112b8ac8aa541ca9a06af7de4d80fc03">00165</a>                 <span class="keywordtype">void</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a112b8ac8aa541ca9a06af7de4d80fc03">set_no_cache</a>(<span class="keywordtype">bool</span> state) {
<a name="l00166"></a>00166                         no_cache = state;
<a name="l00167"></a>00167                 }
<a name="l00168"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ac58af16f8cfb31f08020d64ca1914407">00168</a>             <span class="keywordtype">bool</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ac58af16f8cfb31f08020d64ca1914407">is_no_cache</a>() { <span class="keywordflow">return</span> no_cache; }
<a name="l00169"></a>00169 
<a name="l00170"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a95089334635e3f0116257bb62c329395">00170</a>             <span class="keywordtype">void</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a95089334635e3f0116257bb62c329395">lock_read_response</a>() {
<a name="l00171"></a>00171                 <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;Try locking read response... (&quot;</span> &lt;&lt; hex &lt;&lt; &amp;d_response_lock &lt;&lt; dec &lt;&lt; <span class="stringliteral">&quot;) &quot;</span>);
<a name="l00172"></a>00172                 <span class="keywordtype">int</span> status = <a class="code" href="HTTPCacheTable_8h.html#aea719fb108b1d8bb9214dc49204ad0f0">TRYLOCK</a>(&amp;d_response_lock);
<a name="l00173"></a>00173                 <span class="keywordflow">if</span> (status != 0 <span class="comment">/*&amp;&amp; status == EBUSY*/</span>) {
<a name="l00174"></a>00174                         <span class="comment">// If locked, wait for any writers</span>
<a name="l00175"></a>00175                         <a class="code" href="HTTPCacheTable_8h.html#a16e4e2643dc8f8b07b8be8bebd189ad5">LOCK</a>(&amp;d_response_write_lock);
<a name="l00176"></a>00176                         <a class="code" href="HTTPCacheTable_8h.html#af2aa2fe13863361670b63de7e6df0fdd">UNLOCK</a>(&amp;d_response_write_lock);
<a name="l00177"></a>00177                 }
<a name="l00178"></a>00178                 <a class="code" href="debug_8h.html#a0d28d57d1228cf13a4c1288cc4758344">DBGN</a>(cerr &lt;&lt; <span class="stringliteral">&quot;Done&quot;</span> &lt;&lt; endl);
<a name="l00179"></a>00179                 readers++;                      <span class="comment">// REcord number of readers</span>
<a name="l00180"></a>00180             }
<a name="l00181"></a>00181             
<a name="l00182"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ae2db6d25b27dd657dd0a2ef553e28246">00182</a>             <span class="keywordtype">void</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#ae2db6d25b27dd657dd0a2ef553e28246">unlock_read_response</a>() {
<a name="l00183"></a>00183                         readers--;
<a name="l00184"></a>00184                         <span class="keywordflow">if</span> (readers == 0) {
<a name="l00185"></a>00185                                 <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;Unlocking read response... (&quot;</span> &lt;&lt; hex &lt;&lt; &amp;d_response_lock &lt;&lt; dec &lt;&lt; <span class="stringliteral">&quot;) &quot;</span>);
<a name="l00186"></a>00186                                 <a class="code" href="HTTPCacheTable_8h.html#af2aa2fe13863361670b63de7e6df0fdd">UNLOCK</a>(&amp;d_response_lock);
<a name="l00187"></a>00187                                 <a class="code" href="debug_8h.html#a0d28d57d1228cf13a4c1288cc4758344">DBGN</a>(cerr &lt;&lt; <span class="stringliteral">&quot;Done&quot;</span> &lt;&lt; endl);
<a name="l00188"></a>00188                         }
<a name="l00189"></a>00189                 }
<a name="l00190"></a>00190             
<a name="l00191"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a127f19c06a5f0d2da8b55e4d0d175ae2">00191</a>             <span class="keywordtype">void</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a127f19c06a5f0d2da8b55e4d0d175ae2">lock_write_response</a>() {
<a name="l00192"></a>00192                 <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;locking write response... (&quot;</span> &lt;&lt; hex &lt;&lt; &amp;d_response_lock &lt;&lt; dec &lt;&lt; <span class="stringliteral">&quot;) &quot;</span>);
<a name="l00193"></a>00193                 <a class="code" href="HTTPCacheTable_8h.html#a16e4e2643dc8f8b07b8be8bebd189ad5">LOCK</a>(&amp;d_response_lock);
<a name="l00194"></a>00194                 <a class="code" href="HTTPCacheTable_8h.html#a16e4e2643dc8f8b07b8be8bebd189ad5">LOCK</a>(&amp;d_response_write_lock);
<a name="l00195"></a>00195                 <a class="code" href="debug_8h.html#a0d28d57d1228cf13a4c1288cc4758344">DBGN</a>(cerr &lt;&lt; <span class="stringliteral">&quot;Done&quot;</span> &lt;&lt; endl);
<a name="l00196"></a>00196             }
<a name="l00197"></a>00197             
<a name="l00198"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a0cddc0fbf4569c5e323e79c5ec098c22">00198</a>             <span class="keywordtype">void</span> <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a0cddc0fbf4569c5e323e79c5ec098c22">unlock_write_response</a>() {
<a name="l00199"></a>00199                 <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;Unlocking write response... (&quot;</span> &lt;&lt; hex &lt;&lt; &amp;d_response_lock &lt;&lt; dec &lt;&lt; <span class="stringliteral">&quot;) &quot;</span>);
<a name="l00200"></a>00200                 <a class="code" href="HTTPCacheTable_8h.html#af2aa2fe13863361670b63de7e6df0fdd">UNLOCK</a>(&amp;d_response_write_lock);
<a name="l00201"></a>00201                 <a class="code" href="HTTPCacheTable_8h.html#af2aa2fe13863361670b63de7e6df0fdd">UNLOCK</a>(&amp;d_response_lock);
<a name="l00202"></a>00202                 <a class="code" href="debug_8h.html#a0d28d57d1228cf13a4c1288cc4758344">DBGN</a>(cerr &lt;&lt; <span class="stringliteral">&quot;Done&quot;</span> &lt;&lt; endl);
<a name="l00203"></a>00203             }
<a name="l00204"></a>00204             
<a name="l00205"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#afde4845d8168a3f81dd039439882014d">00205</a>             <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html">CacheEntry</a>() :
<a name="l00206"></a>00206                         url(<span class="stringliteral">&quot;&quot;</span>), hash(-1), hits(0), cachename(<span class="stringliteral">&quot;&quot;</span>), etag(<span class="stringliteral">&quot;&quot;</span>), lm(-1),
<a name="l00207"></a>00207                                         expires(-1), date(-1), age(-1), max_age(-1), size(0),
<a name="l00208"></a>00208                                         range(false), freshness_lifetime(0), response_time(0),
<a name="l00209"></a>00209                                         corrected_initial_age(0), must_revalidate(false),
<a name="l00210"></a>00210                                         no_cache(false), readers(0) {
<a name="l00211"></a>00211                 <a class="code" href="HTTPCacheTable_8h.html#a80412ba526b7b04f6784d1f992be57e9">INIT</a>(&amp;d_response_lock);
<a name="l00212"></a>00212                 <a class="code" href="HTTPCacheTable_8h.html#a80412ba526b7b04f6784d1f992be57e9">INIT</a>(&amp;d_response_write_lock);
<a name="l00213"></a>00213             }
<a name="l00214"></a><a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html#a7beadf359df8d7abae1660f24ab3c92e">00214</a>                 <a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html">CacheEntry</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;u) :
<a name="l00215"></a>00215                         url(u), hash(-1), hits(0), cachename(<span class="stringliteral">&quot;&quot;</span>), etag(<span class="stringliteral">&quot;&quot;</span>), lm(-1),
<a name="l00216"></a>00216                                         expires(-1), date(-1), age(-1), max_age(-1), size(0),
<a name="l00217"></a>00217                                         range(false), freshness_lifetime(0), response_time(0),
<a name="l00218"></a>00218                                         corrected_initial_age(0), must_revalidate(false),
<a name="l00219"></a>00219                                         no_cache(false), readers(0) {
<a name="l00220"></a>00220                 <a class="code" href="HTTPCacheTable_8h.html#a80412ba526b7b04f6784d1f992be57e9">INIT</a>(&amp;d_response_lock);
<a name="l00221"></a>00221                 <a class="code" href="HTTPCacheTable_8h.html#a80412ba526b7b04f6784d1f992be57e9">INIT</a>(&amp;d_response_write_lock);
<a name="l00222"></a>00222                 hash = <a class="code" href="namespacelibdap.html#a68a16ef70e29c367dabd3cb5165c386a">get_hash</a>(url);
<a name="l00223"></a>00223                 }
<a name="l00224"></a>00224         };
<a name="l00225"></a>00225 
<a name="l00226"></a>00226         <span class="comment">// Typedefs for CacheTable. A CacheTable is a vector of vectors of</span>
<a name="l00227"></a>00227         <span class="comment">// CacheEntries. The outer vector is accessed using the hash value.</span>
<a name="l00228"></a>00228         <span class="comment">// Entries with matching hashes occupy successive positions in the inner</span>
<a name="l00229"></a>00229         <span class="comment">// vector (that&#39;s how hash collisions are resolved). Search the inner</span>
<a name="l00230"></a>00230         <span class="comment">// vector for a specific match.</span>
<a name="l00231"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#a36425575bbfac384964ce2f364f15679">00231</a>         <span class="keyword">typedef</span> vector&lt;CacheEntry *&gt; <a class="code" href="classlibdap_1_1HTTPCacheTable.html#a36425575bbfac384964ce2f364f15679">CacheEntries</a>;
<a name="l00232"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#a8527d6a5b1e720e2d500e1ec1eeecf9f">00232</a>         <span class="keyword">typedef</span> CacheEntries::iterator <a class="code" href="classlibdap_1_1HTTPCacheTable.html#a8527d6a5b1e720e2d500e1ec1eeecf9f">CacheEntriesIter</a>;
<a name="l00233"></a>00233 
<a name="l00234"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#aa8e43995c010ac4fae6ca8cc13395930">00234</a>         <span class="keyword">typedef</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#a36425575bbfac384964ce2f364f15679">CacheEntries</a> **<a class="code" href="classlibdap_1_1HTTPCacheTable.html#aa8e43995c010ac4fae6ca8cc13395930">CacheTable</a>;<span class="comment">// Array of pointers to CacheEntries</span>
<a name="l00235"></a>00235 
<a name="l00236"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#a76bd6ce419aad54c8c87e993f5bd11c9">00236</a>         <span class="keyword">friend</span> <span class="keyword">class </span>HTTPCacheTest;
<a name="l00237"></a>00237         
<a name="l00238"></a>00238 <span class="keyword">private</span>:
<a name="l00239"></a>00239         <a class="code" href="classlibdap_1_1HTTPCacheTable.html#aa8e43995c010ac4fae6ca8cc13395930">CacheTable</a> d_cache_table;
<a name="l00240"></a>00240     
<a name="l00241"></a>00241         <span class="keywordtype">string</span> d_cache_root;
<a name="l00242"></a>00242     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> d_block_size; <span class="comment">// File block size.</span>
<a name="l00243"></a>00243     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> d_current_size;
<a name="l00244"></a>00244 
<a name="l00245"></a>00245     <span class="keywordtype">string</span> d_cache_index;
<a name="l00246"></a>00246     <span class="keywordtype">int</span> d_new_entries;
<a name="l00247"></a>00247     
<a name="l00248"></a>00248     map&lt;FILE *, HTTPCacheTable::CacheEntry *&gt; d_locked_entries;
<a name="l00249"></a>00249     
<a name="l00250"></a>00250         <span class="comment">// Make these private to prevent use</span>
<a name="l00251"></a>00251         <a class="code" href="classlibdap_1_1HTTPCacheTable.html">HTTPCacheTable</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html">HTTPCacheTable</a> &amp;) {
<a name="l00252"></a>00252                 <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">&quot;unimplemented&quot;</span>);
<a name="l00253"></a>00253         }
<a name="l00254"></a>00254         
<a name="l00255"></a>00255         <a class="code" href="classlibdap_1_1HTTPCacheTable.html">HTTPCacheTable</a> &amp;operator=(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html">HTTPCacheTable</a> &amp;) {
<a name="l00256"></a>00256                 <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">&quot;unimplemented&quot;</span>);
<a name="l00257"></a>00257         }
<a name="l00258"></a>00258         
<a name="l00259"></a>00259         HTTPCacheTable() {
<a name="l00260"></a>00260                 <span class="keywordflow">throw</span> InternalErr(__FILE__, __LINE__, <span class="stringliteral">&quot;unimplemented&quot;</span>);
<a name="l00261"></a>00261         }
<a name="l00262"></a>00262 
<a name="l00263"></a>00263         CacheTable &amp;get_cache_table() { <span class="keywordflow">return</span> d_cache_table; }
<a name="l00264"></a>00264         CacheEntry *get_locked_entry_from_cache_table(<span class="keywordtype">int</span> hash, <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;url); <span class="comment">/*const*/</span>
<a name="l00265"></a>00265         
<a name="l00266"></a>00266 <span class="keyword">public</span>:
<a name="l00267"></a>00267         HTTPCacheTable(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;cache_root, <span class="keywordtype">int</span> block_size);
<a name="l00268"></a>00268         ~HTTPCacheTable();
<a name="l00269"></a>00269         
<a name="l00271"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#abb0b2349fafffdd13eea562140083485">00271</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#abb0b2349fafffdd13eea562140083485">get_current_size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_current_size; }
<a name="l00272"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#abf4e75cf192355d7c7bfcf9f0e736168">00272</a>         <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#abf4e75cf192355d7c7bfcf9f0e736168">set_current_size</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> sz) { d_current_size = sz; }
<a name="l00273"></a>00273         
<a name="l00274"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#a0c0cd3182608b1ce1f3b930cf16e6779">00274</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#a0c0cd3182608b1ce1f3b930cf16e6779">get_block_size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_block_size; }
<a name="l00275"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#a3ffe278c93c2d3a0dc2f180fefc6ae3c">00275</a>         <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#a3ffe278c93c2d3a0dc2f180fefc6ae3c">set_block_size</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sz) { d_block_size = sz; }
<a name="l00276"></a>00276         
<a name="l00277"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#a7a412fb2155e6bcaab3ce15a2d8121a5">00277</a>         <span class="keywordtype">int</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#a7a412fb2155e6bcaab3ce15a2d8121a5">get_new_entries</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_new_entries; }
<a name="l00278"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#af17bd7a96186412f3ef53caed42db767">00278</a>         <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#af17bd7a96186412f3ef53caed42db767">increment_new_entries</a>() { ++d_new_entries; }
<a name="l00279"></a>00279         
<a name="l00280"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#a86f13e699f533ebdfd4e7ca3ef83401d">00280</a>         <span class="keywordtype">string</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#a86f13e699f533ebdfd4e7ca3ef83401d">get_cache_root</a>() { <span class="keywordflow">return</span> d_cache_root; }
<a name="l00281"></a><a class="code" href="classlibdap_1_1HTTPCacheTable.html#a9e6fada9e04ddcf835160780222e9a43">00281</a>         <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1HTTPCacheTable.html#a9e6fada9e04ddcf835160780222e9a43">set_cache_root</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;cr) { d_cache_root = cr; }
<a name="l00283"></a>00283 
<a name="l00284"></a>00284         <span class="keywordtype">void</span> delete_expired_entries(time_t time = 0);
<a name="l00285"></a>00285         <span class="keywordtype">void</span> delete_by_hits(<span class="keywordtype">int</span> hits);
<a name="l00286"></a>00286         <span class="keywordtype">void</span> delete_by_size(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size);
<a name="l00287"></a>00287         <span class="keywordtype">void</span> delete_all_entries();
<a name="l00288"></a>00288         
<a name="l00289"></a>00289         <span class="keywordtype">bool</span> cache_index_delete();
<a name="l00290"></a>00290         <span class="keywordtype">bool</span> cache_index_read();
<a name="l00291"></a>00291         CacheEntry *cache_index_parse_line(<span class="keyword">const</span> <span class="keywordtype">char</span> *line);
<a name="l00292"></a>00292         <span class="keywordtype">void</span> cache_index_write();
<a name="l00293"></a>00293         
<a name="l00294"></a>00294     <span class="keywordtype">string</span> create_hash_directory(<span class="keywordtype">int</span> hash);
<a name="l00295"></a>00295     <span class="keywordtype">void</span> create_location(CacheEntry *entry);
<a name="l00296"></a>00296 
<a name="l00297"></a>00297         <span class="keywordtype">void</span> add_entry_to_cache_table(CacheEntry *entry);
<a name="l00298"></a>00298         <span class="keywordtype">void</span> remove_cache_entry(<a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html">HTTPCacheTable::CacheEntry</a> *entry);
<a name="l00299"></a>00299 
<a name="l00300"></a>00300         <span class="keywordtype">void</span> remove_entry_from_cache_table(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;url);
<a name="l00301"></a>00301         CacheEntry *get_locked_entry_from_cache_table(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;url);
<a name="l00302"></a>00302         CacheEntry *get_write_locked_entry_from_cache_table(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;url);
<a name="l00303"></a>00303 
<a name="l00304"></a>00304         <span class="keywordtype">void</span> calculate_time(<a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html">HTTPCacheTable::CacheEntry</a> *entry,
<a name="l00305"></a>00305                         <span class="keywordtype">int</span> default_expiration, time_t request_time);
<a name="l00306"></a>00306         <span class="keywordtype">void</span> parse_headers(<a class="code" href="structlibdap_1_1HTTPCacheTable_1_1CacheEntry.html">HTTPCacheTable::CacheEntry</a> *entry, 
<a name="l00307"></a>00307                         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> max_entry_size, <span class="keyword">const</span> vector&lt;string&gt; &amp;headers);
<a name="l00308"></a>00308         
<a name="l00309"></a>00309         <span class="comment">// These should move back to HTTPCache</span>
<a name="l00310"></a>00310         <span class="keywordtype">void</span> bind_entry_to_data(CacheEntry *entry, FILE *body);
<a name="l00311"></a>00311         <span class="keywordtype">void</span> uncouple_entry_from_data(FILE *body);
<a name="l00312"></a>00312         <span class="keywordtype">bool</span> is_locked_read_responses();
<a name="l00313"></a>00313 };
<a name="l00314"></a>00314 
<a name="l00315"></a>00315 } <span class="comment">// namespace libdap</span>
<a name="l00316"></a>00316 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="HTTPCacheTable_8h.html">HTTPCacheTable.h</a>      </li>
      <li class="footer">Generated on Tue Feb 8 2011 for libdap++ by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
    </ul>
  </div>

</body>
</html>