haiku-website/static/legacy-docs/bebook/BArchivable.html

61 lines
12 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Classes And Methods - The Support Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheSupportKit.html" title="The Support Kit" /><link rel="prev" href="TheSupportKit.html" title="The Support Kit" /><link rel="next" href="BAutolock.html" title="BAutolock" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BAutolock.html" title="BAutolock"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Classes And Methods - The Support Kit</div></div><div id="headerB">Prev: <a href="TheSupportKit.html">The Support Kit</a>  Up: <a href="TheSupportKit.html">The Support Kit</a>  Next: <a href="BAutolock.html">BAutolock</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BArchivable"></a>BArchivable</h2></div></div></div><a id="id1267269" class="indexterm"></a><div class="classheader"><table border="0"><colgroup><col /><col /></colgroup><tbody><tr><td><table width="100%" border="0"><colgroup><col /><col /></colgroup><tbody><tr><td>Derived From:</td><td></td></tr><tr><td>Mix-in Classes:</td><td></td></tr><tr><td>Declared In:</td><td><code class="filename">support/Archivable.h</code></td></tr><tr><td>Library:</td><td><code class="filename">libbe.so</code></td></tr><tr><td>Allocation:</td><td></td></tr></tbody></table></td><td>
<a class="link overview" href="BArchivable_Overview.html" title="BArchivable">Class Overview</a>
<div class="toc"><ul><li><span class="section"><a href="BArchivable.html#BArchivable_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BArchivable.html#BArchivable_MemberFunctions">Member Functions</a></span></li><li><span class="section"><a href="BArchivable.html#BArchivable_StaticFunctions">Static Functions</a></span></li></ul></div>
</td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BArchivable_ConstructorDestructor"></a>Constructor and Destructor</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BArchivable_Constructor"></a>BArchivable()</h4></div></div></div><div class="synopsisgroup">
<code class="constructorsynopsis cpp"><span class="methodname">BArchivable</span>();</code>
<code class="constructorsynopsis cpp"><span class="methodname">BArchivable</span>(<span class="methodparam"><span class="type"><a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* </span><span class="parameter">archive</span></span>);</code>
</div><p>
Does nothing.
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BArchivable_Destructor"></a>~BArchivable()</h4></div></div></div><code class="destructorsynopsis cpp"><span class="modifier">virtual </span><span class="methodname">~BArchivable</span>();</code><p>
Does nothing.
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BArchivable_MemberFunctions"></a>Member Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BArchivable_Archive"></a>Archive()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">Archive</span>(<span class="methodparam"><span class="type"><a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* </span><span class="parameter">archive</span></span>,<br />                         <span class="methodparam"><span class="type">bool </span><span class="parameter">deep</span><span class="initializer"> = true</span></span>) <span class="modifier">const</span>;</code><p>
The default implementation adds the name of the object's class to
archive's <code class="varname">class</code> field. Derived classes
must override <code class="methodname">Archive()</code> to
augment this implementation by adding, to the
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>, data that
describes the current state of the object. Each implementation of this
function should begin by incorporating the inherited version:
</p><pre class="programlisting example cpp"><span class="comment">/* We'll assume that MyView inherits from <a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>. */</span>
<span class="type">status_t</span> <code class="classname">MyView</code>::<code class="methodname">Archive</code>(<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* <code class="parameter">archive</code>, <span class="type">bool</span> <code class="parameter">deep</code>)
{
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>::<code class="methodname">Archive</code>(<code class="parameter">archive</code>, <code class="parameter">deep</code>);
. . .
}</pre><p>
If the class can be instantiated directly from a derived class, it should
also add its name to the "class" array:
</p><pre class="programlisting example cpp"><code class="varname">archive</code>-&gt;<code class="methodname">AddString</code>("class", "MyView");</pre><p>
The <code class="parameter">deep</code> flag declares whether <code class="methodname">Archive()</code>
should include objects that "belong" to the archiving object. For example, a
deep <a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a> archive would
include archived forms of the view's children.
</p><p>
<code class="methodname">Archive()</code> should return <code class="constant">B_OK</code> if
it's successful; otherwise, it should
return <code class="constant">B_ERROR</code> or a more descriptive error code.
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BArchivable_StaticFunctions"></a>Static Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BArchivable_Instantiate"></a>Instantiate()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">static </span><span class="type">BArchivable* </span><span class="methodname">Instantiate</span>(<span class="methodparam"><span class="type"><a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* </span><span class="parameter">archive</span></span>);</code><p>
Derived classes should implement <code class="methodname">Instantiate()</code> to return a new
<code class="classname">BArchivable</code> object that was constructed from the
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a> archive. For
example:
</p><pre class="programlisting example cpp"><code class="classname">BArchivable</code>* <code class="classname">TheClass</code>::<code class="methodname">Instantiate</code>(<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* <code class="parameter">archive</code>)
{
if ( !<code class="function">validate_instantiation</code>(<code class="parameter">archive</code>, "TheClass") )
return <code class="constant">NULL</code>;
return new <code class="classname">TheClass</code>(<code class="parameter">archive</code>);}
</pre><div class="admonition warning"><div class="title">Warning</div><div class="graphic"><img class="icon" alt="Warning" width="32" src="./images/admonitions/Stop_32.png" /><div class="text"><p><code class="methodname">Instantiate()</code> must return a <code class="classname">BArchivable*</code>,
regardless of the actual class in which it's implemented.</p></div></div></div><p>
This function depends on a constructor that can initialize the new object
from the <code class="parameter">archive</code> <a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>.
See "Instantiability" <span class="bold"><strong>TODO</strong></span> for more information.
</p><p>
The default implementation returns <code class="constant">NULL</code>.
</p></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="TheSupportKit.html">The Support Kit</a>  Up: <a href="TheSupportKit.html">The Support Kit</a>  Next: <a href="BAutolock.html">BAutolock</a> </div><div id="footerB"><div id="footerBL"><a href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BAutolock.html" title="BAutolock"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>