Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 052d79447130ebaf90b2730395954d11 > files > 379

openvrml-doc-0.18.3-1mdv2010.0.i586.rpm

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
               "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>OpenVRML: openvrml::resource_fetcher Class Reference</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<link rel="icon" href="../vrml-16">
<link rel="start" href="http://openvrml.org/index" title="OpenVRML Home">
<link rel="prev" href="http://openvrml.org/discussion" title="Discussion">
<link rel="contents" href="index" title="Documentation Main Page">
<link rel="index" href="functions" title="OpenVRML Compound Members">
<link rel="appendix" href="conformance" title="Conformance Test Results">
<style type="text/css">
@import url("tabs.css");
@import url("http://openvrml.org/openvrml.css");

table {
  width: 100%;
}

h2 {
  border-bottom-style: solid;
  border-bottom-width: 1px;
}

/*
 * Doxygen as of 1.5.4-20071217 uses the class "navpath" instead of "nav".
 * For now, we'll do both.
 */

div.nav,
div.navpath {
  background-color: transparent;
  text-align: left;
  margin-top: 1em;
  margin-bottom: 1em;
  border-color: black;
  border-left: none;
  border-right: none;
  padding-top: 0.5em;
  padding-bottom: 0.5em;
}

div.nav :link, div.nav :visited,
div.navpath :link, div.navpath :visited {
  border-width: 1px;
  border-style: solid;
  border-color: silver;
  padding: 2px;
}

div.nav :link:hover, div.nav :visited:hover,
div.navpath :link:hover, div.navpath :visited:hover {
  border-style: outset;
  border-color: gray;
}

div.nav :active,
div.navpath :active {
  border-style: inset;
  border-color: gray;
}

.body td {
  background-color: transparent;
}

.el {
  text-decoration: inherit;
  font-weight: inherit
}
.elRef {
  font-weight: inherit
}
.code:link, .code:visited {
  text-decoration: inherit;
  font-weight: inherit;
  color: inherit;
}
.codeRef:link {
  font-weight: normal;
  color: inherit;
}
:visited {
  color: silver;
}
:link:hover {
  color: inherit;
  text-decoration: inherit;
  background-color: transparent;
}

h1 {
  line-height: 1.2em;
}

td.memItemLeft, td.memItemRight,
td.memTemplParams, td.memTemplItemLeft, td.memTemplItemRight,
.memtemplate, .memname td {
  font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Lucida Console", LucidaTypewriter, monospace;
}

td.memItemLeft, td.memItemRight, td.mdescLeft, td.mdescRight {
  background-color: rgb(95%, 95%, 95%);
  border-color: rgb(65%, 65%, 65%);
  border-width: 1px;
  font-size: smaller;
}

.memItemLeft {
  margin-top: 0.5em;
  border-top-style: solid;
}
.mdescLeft {
  border-bottom-style: solid;
}
.memItemRight {
  border-top-style: solid;
  margin-top: 0.5em;
}
.mdescRight {
  border-bottom-style: solid;
}

.mdescRight {
  font-style: italic;
}

.mdTable {
  background-color: rgb(95%, 95%, 95%);
}

.memproto td code {
  font-family: inherit;
  font-style: italic;
}

td.pass {
  background-color: rgb(50%, 100%, 50%);
}

td.fail {
  background-color: rgb(100%, 50%, 50%);
}

td.invalid {
  background-color: rgb(75%, 75%, 75%);
}

.memitem {
  padding: 0;
}

.memitem table {
  width: auto;
}

.memproto, .memdoc {
  border-width: 1px;
  border-color: rgb(65%, 65%, 65%);
}

.memproto {
  background-color: rgb(90%, 90%, 90%);
  font-weight: inherit;
  font-size: smaller;
  border-top-style: solid;
  border-left-style: solid;
  border-right-style: solid;
  -webkit-border-top-left-radius: 0.6em;
  -webkit-border-top-right-radius: 0.6em;
  -moz-border-radius-topleft: 0.6em;
  -moz-border-radius-topright: 0.6em;
}

.memdoc {
  background-color: rgb(95%, 95%, 95%);
  padding: 2px 5px;
  border-style: solid;
  -webkit-border-bottom-left-radius: 0.6em;
  -webkit-border-bottom-right-radius: 0.6em;
  -moz-border-radius-bottomleft: 0.6em;
  -moz-border-radius-bottomright: 0.6em;
}

.memname {
  font-weight: inherit;
}

div.tabs {
  background-image: url("tab_b-openvrml.png");
}

div.tabs span {
  background-image: url("tab_l-openvrml.png");
}

div.tabs a {
  background-image: url("tab_r-openvrml.png");
  border-bottom: 1px solid #a5a5a5;
}

div.tabs a:link, div.tabs a:visited, div.tabs a:active, div.tabs a:hover {
  color: black;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

.note {
  border: 1px solid rgb(65%, 65%, 65%);
  background-color: rgb(95%, 95%, 95%);
  margin-left: 10%;
  margin-right: 10%;
}
</style>
</head>
<body>
<table class="sitenav">
  <tr>
    <th><a href="http://openvrml.org/index" title="Home">Home</a></th>
    <th><a href="http://openvrml.org/download" title="Download">Download</a></th>
    <th><a href="http://openvrml.org/screenshots/index" title="Screen shots">Screen shots</a></th>
    <th><a href="http://openvrml.org/discussion" title="Mailing lists and IRC">Discussion</a></th>
    <th>Documentation</th>
  </tr>
</table>
<div class="body">
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="namespaceopenvrml.html">openvrml</a>::<a class="el" href="classopenvrml_1_1resource__fetcher.html">resource_fetcher</a>
  </div>
</div>
<div class="contents">
<h1>openvrml::resource_fetcher Class Reference</h1><!-- doxytag: class="openvrml::resource_fetcher" -->An abstract factory for <code><a class="el" href="classopenvrml_1_1resource__istream.html" title="An abstract input stream for network resources.">resource_istream</a>s</code>.  
<a href="#_details">More...</a>
<p>

<p>
<a href="classopenvrml_1_1resource__fetcher-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classopenvrml_1_1resource__fetcher.html#2a2fc133486ec3514d8d07d7beb9d7d1">~resource_fetcher</a> ()=0  throw ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destroy.  <a href="#2a2fc133486ec3514d8d07d7beb9d7d1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">std::auto_ptr&lt; <a class="el" href="classopenvrml_1_1resource__istream.html">resource_istream</a> &gt;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classopenvrml_1_1resource__fetcher.html#6924bd973131808c2c3f258b794aa4dc">get_resource</a> (const std::string &amp;uri)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Fetch a network resource.  <a href="#6924bd973131808c2c3f258b794aa4dc"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual std::auto_ptr<br class="typebreak">
&lt; <a class="el" href="classopenvrml_1_1resource__istream.html">resource_istream</a> &gt;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classopenvrml_1_1resource__fetcher.html#3a79534184e9de4e6405a52c19336ca6">do_get_resource</a> (const std::string &amp;uri)=0</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Fetch a network resource.  <a href="#3a79534184e9de4e6405a52c19336ca6"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
An abstract factory for <code><a class="el" href="classopenvrml_1_1resource__istream.html" title="An abstract input stream for network resources.">resource_istream</a>s</code>. 
<p>
A concrete implementation of this interface must be passed to <code><a class="el" href="classopenvrml_1_1browser.html" title="Encapsulates a VRML browser.">browser</a></code>'s constructor.<p>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classopenvrml_1_1browser.html" title="Encapsulates a VRML browser.">openvrml::browser</a> </dd></dl>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="2a2fc133486ec3514d8d07d7beb9d7d1"></a><!-- doxytag: member="openvrml::resource_fetcher::~resource_fetcher" ref="2a2fc133486ec3514d8d07d7beb9d7d1" args="()=0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">openvrml::resource_fetcher::~resource_fetcher           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td>  throw ()<code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Destroy. 
<p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="6924bd973131808c2c3f258b794aa4dc"></a><!-- doxytag: member="openvrml::resource_fetcher::get_resource" ref="6924bd973131808c2c3f258b794aa4dc" args="(const std::string &amp;uri)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::auto_ptr&lt; <a class="el" href="classopenvrml_1_1resource__istream.html">openvrml::resource_istream</a> &gt; openvrml::resource_fetcher::get_resource           </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&nbsp;</td>
          <td class="paramname"> <em>uri</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Fetch a network resource. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>uri</em>&nbsp;</td><td>a Uniform Resource Identifier.</td></tr>
  </table>
</dl>
This function delegates to <code><a class="el" href="classopenvrml_1_1resource__fetcher.html#3a79534184e9de4e6405a52c19336ca6" title="Fetch a network resource.">resource_fetcher::do_get_resource</a></code>.<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the requested resource as a stream.</dd></dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>std::invalid_argument</em>&nbsp;</td><td>if <code>uri</code> is malformed or in an unsupported format. </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="3a79534184e9de4e6405a52c19336ca6"></a><!-- doxytag: member="openvrml::resource_fetcher::do_get_resource" ref="3a79534184e9de4e6405a52c19336ca6" args="(const std::string &amp;uri)=0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::auto_ptr&lt; <a class="el" href="classopenvrml_1_1resource__istream.html">openvrml::resource_istream</a> &gt; openvrml::resource_fetcher::do_get_resource           </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&nbsp;</td>
          <td class="paramname"> <em>uri</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [private, pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Fetch a network resource. 
<p>
Called by <code><a class="el" href="classopenvrml_1_1resource__fetcher.html#6924bd973131808c2c3f258b794aa4dc" title="Fetch a network resource.">get_resource</a></code>, clients of OpenVRML are required to provide an implementation for this function. OpenVRML depends on the implementation of this function for all of its input needs. As such, what kinds of resources OpenVRML is capable of resolving are entirely dependent on code provided by the application.<p>
Implementations should throw <code>std::invalid_argument</code> if <code>uri</code> is malformed or in an format that is not supported by the implementation.<p>
A trivial implementation designed to handle only <code>file</code> resources can use <code>std::filebuf:</code> <p>
<div class="fragment"><pre class="fragment"> std::auto_ptr&lt;openvrml::resource_istream&gt;
 <a class="code" href="classopenvrml_1_1resource__fetcher.html#3a79534184e9de4e6405a52c19336ca6" title="Fetch a network resource.">my_resource_fetcher::do_get_resource</a>(<span class="keyword">const</span> std::string &amp; uri)
 {
     <span class="keyword">using</span> std::auto_ptr;
     <span class="keyword">using</span> std::invalid_argument;
     <span class="keyword">using</span> std::string;
     <span class="keyword">using</span> <a class="code" href="classopenvrml_1_1resource__istream.html" title="An abstract input stream for network resources.">openvrml::resource_istream</a>;

     <span class="keyword">class </span>file_resource_istream : <span class="keyword">public</span> resource_istream {
         std::string url_;
         std::filebuf buf_;

     <span class="keyword">public</span>:
         <span class="keyword">explicit</span> file_resource_istream(<span class="keyword">const</span> std::string &amp; path):
             resource_istream(&amp;this-&gt;buf_)
         {
             <span class="comment">//</span>
             <span class="comment">// Note that the failbit is set in the constructor if no data</span>
             <span class="comment">// can be read from the stream.  This is important.  If the</span>
             <span class="comment">// failbit is not set on such a stream, OpenVRML will attempt</span>
             <span class="comment">// to read data from a stream that cannot provide it.</span>
             <span class="comment">//</span>
             <span class="keywordflow">if</span> (!this-&gt;buf_.open(path.c_str(),
                                  ios_base::in | ios_base::binary)) {
                 this-&gt;setstate(ios_base::badbit);
             }
         }

         <span class="keywordtype">void</span> url(<span class="keyword">const</span> std::string &amp; str)
         {
             this-&gt;url_ = str;
         }

     <span class="keyword">private</span>:
         <span class="keyword">virtual</span> <span class="keyword">const</span> std::string url()<span class="keyword"> const</span>
<span class="keyword">         </span>{
             <span class="keywordflow">return</span> this-&gt;url_;
         }

         <span class="keyword">virtual</span> <span class="keyword">const</span> std::string type()<span class="keyword"> const</span>
<span class="keyword">         </span>{
             <span class="comment">//</span>
             <span class="comment">// A real application should use OS facilities for this;</span>
             <span class="comment">// however, that is beyond the scope of this example (which</span>
             <span class="comment">// is intended to be portable and stupid).</span>
             <span class="comment">//</span>
             <span class="keyword">using</span> std::find;
             <span class="keyword">using</span> std::string;
             <span class="keyword">using</span> boost::algorithm::iequals;
             <span class="keyword">using</span> boost::next;
             <span class="keywordtype">string</span> media_type = <span class="stringliteral">"application/octet-stream"</span>;
             <span class="keyword">const</span> string::const_reverse_iterator dot_pos =
                 find(this-&gt;url_.rbegin(), this-&gt;url_.rend(), <span class="charliteral">'.'</span>);
             <span class="keywordflow">if</span> (dot_pos == this-&gt;url_.rend()
                 || next(dot_pos.base()) == this-&gt;url_.end()) {
                 <span class="keywordflow">return</span> media_type;
             }
             <span class="keyword">const</span> string::const_iterator hash_pos =
                 find(next(dot_pos.base()), this-&gt;url_.end(), <span class="charliteral">'#'</span>);
             <span class="keyword">const</span> <span class="keywordtype">string</span> ext(dot_pos.base(), hash_pos);
             <span class="keywordflow">if</span> (iequals(ext, <span class="stringliteral">"wrl"</span>)) {
                 media_type = <span class="stringliteral">"model/vrml"</span>;
             } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iequals(ext, <span class="stringliteral">"png"</span>)) {
                 media_type = <span class="stringliteral">"image/png"</span>;
             } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iequals(ext, <span class="stringliteral">"jpg"</span>) || iequals(ext, <span class="stringliteral">"jpeg"</span>)) {
                 media_type = <span class="stringliteral">"image/jpeg"</span>;
             }
             <span class="keywordflow">return</span> media_type;
         }

         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> data_available()<span class="keyword"> const</span>
<span class="keyword">         </span>{
             <span class="keywordflow">return</span> !!(*this);
         }
     };

     <span class="keyword">const</span> <span class="keywordtype">string</span> scheme = uri.substr(0, uri.find_first_of(<span class="charliteral">':'</span>));
     <span class="keywordflow">if</span> (scheme != <span class="stringliteral">"file"</span>) {
         <span class="keywordflow">throw</span> invalid_argument(<span class="charliteral">'\"'</span> + scheme + <span class="stringliteral">"\" URI scheme not "</span>
                                <span class="stringliteral">"supported"</span>);
     }
     <span class="comment">//</span>
     <span class="comment">// file://</span>
     <span class="comment">//        ^</span>
     <span class="comment">// 01234567</span>
     <span class="comment">//</span>
     <span class="keywordtype">string</span> path = uri.substr(uri.find_first_of(<span class="charliteral">'/'</span>, 7));

     auto_ptr&lt;resource_istream&gt; in(<span class="keyword">new</span> file_resource_istream(path));
     <span class="keyword">static_cast&lt;</span>file_resource_istream *<span class="keyword">&gt;</span>(in.get())-&gt;url(uri);

     <span class="keywordflow">return</span> in;
 }
</pre></div><p>
The <code>uri</code> parameter is provided by OpenVRML and can be assumed to be an absolute URI. As such, it will always have a scheme through which the client code can choose a resolution mechanism. For more information on URI syntax, see <a href="ftp://ftp.rfc-editor.org/in-notes/std/std66.txt">Internet STD&nbsp;66</a>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>uri</em>&nbsp;</td><td>an absolute Uniform Resource Identifier.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the requested resource as a stream.</dd></dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>std::invalid_argument</em>&nbsp;</td><td>if <code>uri</code> is malformed or in an unsupported format.</td></tr>
  </table>
</dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="ftp://ftp.rfc-editor.org/in-notes/std/std66.txt">ftp://ftp.rfc-editor.org/in-notes/std/std66.txt</a> </dd></dl>

</div>
</div><p>
</div>
</div>
<address class="footer"><span class="images"><a href="http://web3d.org/x3d/"><img src="x3d-white-on-black.png" width="43" height="32" border="0" alt="X3D"></a><a href="http://opengl.org"><img src="OGL_sm_wht.png" width="68" height="32" border="0" alt="OpenGL"></a><a href="http://sourceforge.net/projects/openvrml"><img src="http://sourceforge.net/sflogo.php?group_id=7151&amp;type=11" width="120" height="30" border="0" alt="SourceForge.net"></a></span><a href="https://sourceforge.net/apps/trac/openvrml/newticket">Report error</a><br>Generated Thu Aug 13 02:49:17 2009 by Doxygen 1.5.8</address>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">_uacct = "UA-446379-2"; urchinTracker();</script>
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://sourceforge.net/apps/piwik/openvrml/" : "http://sourceforge.net/apps/piwik/openvrml/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
piwik_action_name = '';
piwik_idsite = 1;
piwik_url = pkBaseURL + "piwik.php";
piwik_log(piwik_action_name, piwik_idsite, piwik_url);
</script>
<object><noscript><p><img src="http://sourceforge.net/apps/piwik/openvrml/piwik.php?idsite=1" alt="piwik"/></p></noscript></object>
<!-- End Piwik Tag -->
</body>
</html>