173 lines
31 KiB
HTML
173 lines
31 KiB
HTML
<?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 Application 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="TheApplicationKit.html" title="The Application Kit" /><link rel="prev" href="BHandler.html" title="BHandler" /><link rel="next" href="BLooper.html" title="BLooper" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BHandler.html" title="BHandler"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheApplicationKit.html" title="The Application Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BLooper.html" title="BLooper"><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 Application Kit</div></div><div id="headerB">Prev: <a href="BHandler.html">BHandler</a> Up: <a href="TheApplicationKit.html">The Application Kit</a> Next: <a href="BLooper.html">BLooper</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="BInvoker"></a>BInvoker</h2></div></div></div><a id="id682914" 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">app/Invoker.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="BInvoker_Overview.html" title="BInvoker">Class Overview</a>
|
||
<div class="toc"><ul><li><span class="section"><a href="BInvoker.html#BInvoker_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BInvoker.html#BInvoker_MemberFunctions">Member 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="BInvoker_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="BInvoker_Constructor"></a>BInvoker()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="constructorsynopsis cpp"><span class="methodname">BInvoker</span>(<span class="methodparam"><span class="type">BMessage* </span><span class="parameter">message</span></span>,<br /> <span class="methodparam"><span class="type">BMessenger </span><span class="parameter">messenger</span></span>);</code>
|
||
|
||
<code class="constructorsynopsis cpp"><span class="methodname">BInvoker</span>(<span class="methodparam"><span class="type">BMessage* </span><span class="parameter">message</span></span>,<br /> <span class="methodparam"><span class="modifier">const </span><span class="type">BHandler* </span><span class="parameter">handler</span></span>,<br /> <span class="methodparam"><span class="modifier">const </span><span class="type">BLooper* </span><span class="parameter">looper</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code>
|
||
|
||
<code class="constructorsynopsis cpp"><span class="methodname">BInvoker</span>();</code>
|
||
</div><p>Initializes the <code class="classname">BInvoker</code> by setting its message and its messenger.</p><ul class="itemizedlist"><li><p>The object's
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a> is taken
|
||
directly as <code class="parameter">message</code>—the object is
|
||
<span class="emphasis"><em>not</em></span> copied. The <code class="classname">BInvoker</code> takes
|
||
over ownership of the <a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>
|
||
that you pass in.</p></li><li><p>The object's <a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a>
|
||
is copied from <code class="parameter">messenger</code>, or initialized with
|
||
<code class="parameter">looper</code> and <code class="parameter">handler</code>. See the
|
||
<a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a> class for
|
||
details on how a <a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a>
|
||
identifies a target.</p></li></ul><p>If you want a reply handler, you have to call
|
||
<a class="link" href="BInvoker.html#BInvoker_SetHandlerForReply" title="SetHandlerForReply(), HandlerForReply()"><code class="methodname">SetHandlerForReply()</code></a>
|
||
after the constructor returns. You can reset the message and messenger through
|
||
<a class="link" href="BInvoker.html#BInvoker_SetMessage" title="SetMessage(), Message(), Command()"><code class="methodname">SetMessage()</code></a> and
|
||
<a class="link" href="BInvoker.html#BInvoker_SetTarget" title="SetTarget(), Target(), IsTargetLocal(), Messenger()"><code class="methodname">SetTarget()</code></a>.</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="BInvoker_Destructor"></a>~BInvoker()</h4></div></div></div><code class="destructorsynopsis cpp"><span class="modifier">virtual </span><span class="methodname">~BInvoker</span>();</code><p>Deletes the object's
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>.</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="BInvoker_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="BInvoker_BeginInvokeNotify"></a><a id="BInvoker_EndInvokeNotify"></a>
|
||
BeginInvokeNotify(), EndInvokeNotify()</h4></div></div></div><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">BeginInvokeNotify</span>(<span class="methodparam"><span class="type">uint32 </span><span class="parameter">kind</span><span class="initializer"> = <span class="constant">B_CONTROL_INVOKED</span></span></span>);</code><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">EndInvokeNotify</span>();</code><p>If for some reason you need to implement a method that emulates an <a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">InvokeNotify()</code></a>
|
||
call inside an <a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">Invoke()</code></a>
|
||
implementation, you should wrap the invocation code in these functions.
|
||
They set up and tear down an <a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">InvokeNotify()</code></a>
|
||
context.</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="BInvoker_Invoke"></a><a id="BInvoker_InvokeNotify"></a>
|
||
Invoke(), InvokeNotify()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">Invoke</span>(<span class="methodparam"><span class="type">BMessage* </span><span class="parameter">message</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">InvokeNotify</span>(<span class="methodparam"><span class="type">BMessage* </span><span class="parameter">message</span></span>,<br /> <span class="methodparam"><span class="type">uint32 </span><span class="parameter">kind</span><span class="initializer"> = <span class="constant">B_CONTROL_INVOKED</span></span></span>);</code><p><code class="methodname">Invoke()</code> tells the
|
||
<code class="classname">BInvoker</code>'s messenger to send a message. If
|
||
<code class="parameter">message</code> is non-<code class="constant">NULL</code>, that
|
||
message is sent, otherwise the object sends its default message (i.e. the
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a> that was
|
||
passed in the constructor or in
|
||
<a class="link" href="BInvoker.html#BInvoker_SetMessage" title="SetMessage(), Message(), Command()"><code class="methodname">SetMessage()</code></a>).
|
||
The message is sent asynchronously with no time limit on the reply.</p><div class="admonition note"><div class="title">Note</div><div class="graphic"><img class="icon" alt="Note" width="32" src="./images/admonitions/Info_32.png" /><div class="text"><p>Regarding the use of the default message <span class="foreignphrase"><em class="foreignphrase">vs</em></span>
|
||
the argument, a common practice is to reserve the default message as a
|
||
template, and pass a fine-tuned copy to <code class="methodname">Invoke()</code></p><pre class="programlisting example cpp"><span class="comment">/* Add the current system time to a copy of
|
||
the default message. */</span>
|
||
<code class="classname">BMessage</code> <code class="varname">copy</code>(<code class="varname">invoker</code>.<code class="methodname">Message</code>());
|
||
<code class="varname">copy</code>.<code class="methodname">AddInt64</code>("when", <code class="function">system_time</code>());
|
||
<code class="varname">invoker</code>.<code class="methodname">Invoke</code>(<code class="varname">copy</code>);</pre></div></div></div><p>The <code class="methodname">InvokeNotify()</code> function sends the
|
||
<code class="parameter">message</code> to the target, using the notification change
|
||
code specified by <code class="parameter">kind</code>. If
|
||
<code class="parameter">message</code> is <code class="constant">NULL</code>, nothing gets
|
||
sent to the target, but any watchers of the invoker's handler will receive
|
||
their expected notifications. By default, the <code class="parameter">kind</code>
|
||
is <code class="constant">B_CONTROL_INVOKED</code>, the same kind sent by a straight
|
||
<code class="methodname">Invoke()</code>.</p><p><code class="methodname">Invoke()</code> doesn't call
|
||
<a class="link" href="BHandler.html#BHandler_SendNotices" title="SendNotices()"><code class="methodname">SendNotices()</code></a>
|
||
by default; you'll have to implement code to do it yourself. Here's how:</p><pre class="programlisting example cpp"><span class="type">status_t</span> <code class="classname">BControl</code>::<code class="methodname">Invoke</code>(<span class="type">BMessage*</span> <code class="parameter">msg</code>) {
|
||
<span class="type">bool</span> <code class="varname">notify</code> = <code class="constant">false</code>;
|
||
<span class="type">uint32</span> <code class="varname">kind</code> = <code class="methodname">InvokeKind</code>(<code class="varname">notify</code>);
|
||
|
||
<code class="classname">BMessage</code> <code class="varname">clone</code>(<code class="varname">kind</code>);
|
||
<span class="type">status_t</span> <code class="varname">err</code> = <code class="constant">B_BAD_VALUE</code>;
|
||
|
||
if (!<code class="parameter">msg</code> && !<code class="varname">notify</code>) {
|
||
<span class="comment">// If no message is supplied, pull it from the BInvoker.</span>
|
||
<span class="comment">// However, ONLY do so if this is not an InvokeNotify()</span>
|
||
<span class="comment">// context -- otherwise, this is not the default invocation</span>
|
||
<span class="comment">// message, so we don't want it to get in the way here.</span>
|
||
<span class="comment">// For example, a control may call InvokeNotify() with their</span>
|
||
<span class="comment">// "modification" message... if that message isn't set,</span>
|
||
<span class="comment">// we still want to send notification to any watchers, but</span>
|
||
<span class="comment">// -don't- want to send a message through the invoker.</span>
|
||
<code class="parameter">msg</code> = <code class="methodname">Message</code>();
|
||
}
|
||
|
||
if (!<code class="parameter">msg</code>) {
|
||
<span class="comment">// If not being watched, there is nothing to do.</span>
|
||
if( !<code class="methodname">IsWatched</code>() ) return <code class="varname">err</code>;
|
||
} else {
|
||
<code class="varname">clone</code> = *<code class="parameter">msg</code>;
|
||
}
|
||
|
||
<code class="varname">clone</code>.<code class="methodname">AddInt64</code>("when", <code class="function">system_time</code>());
|
||
<code class="varname">clone</code>.<code class="methodname">AddPointer</code>("source", <code class="varname">this</code>);
|
||
<code class="varname">clone</code>.<code class="methodname">AddInt32</code>("be:value",<code class="varname">fValue</code>);
|
||
<code class="varname">clone</code>.<code class="methodname">AddMessenger</code>(<code class="constant">B_NOTIFICATION_SENDER</code>, <code class="classname">BMessenger</code>(<code class="varname">this</code>));
|
||
|
||
if( <code class="parameter">msg</code> ) <code class="varname">err</code> = <code class="classname">BInvoker</code>::<code class="methodname">Invoke</code>(&<code class="varname">clone</code>);
|
||
|
||
<span class="comment">// Also send invocation to any observers of this handler.</span>
|
||
<code class="methodname">SendNotices</code>(<code class="varname">kind</code>, <code class="varname">clone</code>);
|
||
|
||
return <code class="varname">err</code>;
|
||
}</pre><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code>.</span></p></td><td><p>The message was sent.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_BAD_VALUE</code>.</span></p></td><td><p>No default message, and no message argument.</p></td></tr><tr><td><p><span class="term">Other errors.</span></p></td><td><p>Forwarded from <a class="link" href="BMessenger.html#BMessenger_SendMessage" title="SendMessage()"><code class="methodname">BMessenger::SendMessage()</code></a>.</p></td></tr></tbody></table></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="BInvoker_InvokeKind"></a>InvokeKind()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">uint32 </span><span class="methodname">InvokeKind</span>(<span class="methodparam"><span class="type">bool* </span><span class="parameter">notify</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code><p>Returns the kind passed to
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">InvokeNotify()</code></a>.
|
||
This should be called from within your implementation of
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">Invoke()</code></a>
|
||
if you need to determine what kind was specified when
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">InvokeNotify()</code></a>
|
||
was called. If you care whether
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">Invoke()</code></a> or
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">InvokeNotify()</code></a>
|
||
was originally called, you can specify a pointer to a <span class="type">bool</span>,
|
||
<code class="parameter">notify</code>, which is set to <code class="constant">true</code> if
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">InvokeNotify()</code></a>
|
||
was called, or <code class="constant">false</code> if
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">Invoke()</code></a> was called.
|
||
This lets you fetch the
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">InvokeNotify()</code></a>
|
||
arguments from your
|
||
<a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">Invoke()</code></a>
|
||
code without breaking compatibility with older applications by adding arguments
|
||
to <a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">Invoke()</code></a>.</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="BInvoker_SetHandlerForReply"></a><a id="BInvoker_HandlerForReply"></a>
|
||
SetHandlerForReply(), HandlerForReply()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">SetHandlerForReply</span>(<span class="methodparam"><span class="type">BHandler* </span><span class="parameter">replyHandler</span></span>);</code><code class="methodsynopsis cpp"><span class="type">BHandler* </span><span class="methodname">HandlerForReply</span>() <span class="modifier">const</span>;</code><p><code class="methodname">SetHandlerForReply()</code> sets the <a class="link" href="BHandler.html" title="BHandler"><code class="classname">BHandler</code></a> object that
|
||
handles replies that are sent back by the target. By default (or if
|
||
<code class="parameter">replyHandler</code> is <code class="constant">NULL</code>), replies
|
||
are sent to the <a class="link" href="BApplication.html" title="BApplication"><code class="classname">BApplication</code></a> object.</p><p><code class="methodname">HandlerForReply()</code> returns the object set through
|
||
<code class="methodname">SetHandlerForReply()</code>. If the reply handler isn't
|
||
set, this function returns <code class="constant">NULL</code>, it doesn't return
|
||
<a class="link" href="BApplication.html#BApplication_be_app" title="be_app"><code class="varname">be_app</code></a> (even
|
||
though <a class="link" href="BApplication.html#BApplication_be_app" title="be_app"><code class="varname">be_app</code></a>
|
||
will be handling the reply).</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p><code class="methodname">SetHandlerForReply()</code> always returns
|
||
<code class="constant">B_OK</code> it doesn't check for validity.</p></td></tr></tbody></table></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="BInvoker_SetMessage"></a><a id="BInvoker_Message"></a>
|
||
<a id="BInvoker_Command"></a>
|
||
SetMessage(), Message(), Command()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">SetMessage</span>(<span class="methodparam"><span class="type">BMessage* </span><span class="parameter">message</span></span>);</code><code class="methodsynopsis cpp"><span class="type">BMessage* </span><span class="methodname">Message</span>() <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="type">uint32 </span><span class="methodname">Command</span>() <span class="modifier">const</span>;</code><p><code class="methodname">SetMessage()</code> sets the
|
||
<code class="classname">BInvoker</code>'s default message to point to
|
||
<code class="parameter">message</code> (the message is <span class="emphasis"><em>not</em></span>
|
||
copied). The previous default message (if any) is deleted; a
|
||
<code class="constant">NULL</code> <code class="parameter">message</code> deletes the
|
||
previous message without setting a new one. The
|
||
<code class="classname">BInvoker</code> owns the <a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a> that you pass in;
|
||
you mustn't delete it yourself.</p><p><code class="methodname">Message()</code> returns a pointer to the default
|
||
message, and <code class="methodname">Command()</code> returns its
|
||
<code class="varname">what</code> data member. Lacking a default message, the
|
||
functions return <code class="constant">NULL</code>.</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p><code class="methodname">SetMessage()</code> always returns
|
||
<code class="constant">B_OK</code>.</p></td></tr></tbody></table></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="BInvoker_SetTarget"></a><a id="BInvoker_Target"></a>
|
||
<a id="BInvoker_IsTargetLocal"></a>
|
||
<a id="BInvoker_Messenger"></a>
|
||
SetTarget(), Target(), IsTargetLocal(), Messenger()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">SetTarget</span>(<span class="methodparam"><span class="type">BMessenger </span><span class="parameter">messenger</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">SetTarget</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">BHandler* </span><span class="parameter">handler</span></span>,<br /> <span class="methodparam"><span class="modifier">const </span><span class="type">BLooper* </span><span class="parameter">looper</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code>
|
||
</div><code class="methodsynopsis cpp"><span class="type">BHandler* </span><span class="methodname">Target</span>(<span class="methodparam"><span class="type">BLooper** </span><span class="parameter">looper</span><span class="initializer"> = <span class="constant">NULL</span></span></span>) <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">IsTargetLocal</span>() <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="type">BMessenger </span><span class="methodname">Messenger</span>() <span class="modifier">const</span>;</code><p>These functions set and query the <code class="classname">BInvoker</code>'s target.
|
||
This is the <a class="link" href="BHandler.html" title="BHandler"><code class="classname">BHandler</code></a>
|
||
to which the object sends a message when <a class="link" href="BInvoker.html#BInvoker_Invoke" title="Invoke(), InvokeNotify()"><code class="methodname">Invoke()</code></a> is
|
||
called. The target is represented by a <a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a> object; you
|
||
can set the <a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a> as a copy of
|
||
<code class="parameter">messenger</code>, or initialize it with
|
||
<code class="parameter">looper</code> and <code class="parameter">handler</code>. See the
|
||
<a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a> class
|
||
for details on how a <a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a> identifies a
|
||
target.</p><p><code class="methodname">Target()</code> returns the <a class="link" href="BHandler.html" title="BHandler"><code class="classname">BHandler</code></a> that's targeted
|
||
by the object's messenger. If <code class="parameter">looper</code> is
|
||
non-<code class="constant">NULL</code>, the <a class="link" href="BLooper.html" title="BLooper"><code class="classname">BLooper</code></a> that owns the <a class="link" href="BHandler.html" title="BHandler"><code class="classname">BHandler</code></a> is returned by
|
||
reference. If the target was set as a looper's preferred handler (i.e.
|
||
<span class="code">SetTarget(<code class="constant">NULL</code>, looper)</span>), or if the target hasn't been set yet,
|
||
<code class="methodname">Target()</code> returns <code class="constant">NULL</code>. The
|
||
function returns <code class="constant">NULL</code> for both objects if the target
|
||
is remote.</p><p><code class="methodname">IsTargetLocal()</code> returns <code class="constant">true</code>
|
||
if the target lives within the <code class="classname">BInvoker</code>'s
|
||
application, and <code class="constant">false</code> if it belongs to some other
|
||
application.</p><p><code class="methodname">Messenger()</code> returns a copy of the <a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a> object the
|
||
<code class="classname">BInvoker</code> uses to send messages. If a target hasn't
|
||
been set yet, the return will be invalid.</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code>.</span></p></td><td><p>The target was successfully set.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_BAD_VALUE</code>.</span></p></td><td><p>The proposed
|
||
<code class="parameter">handler</code> doesn't belong to a <a class="link" href="BLooper.html" title="BLooper"><code class="classname">BLooper</code></a>.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_MISMATCHED_VALUES</code>.</span></p></td><td><p><code class="parameter">handler</code>
|
||
doesn't belong to <code class="parameter">looper</code>.</p></td></tr></tbody></table><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">SetTarget()</code> doesn't detect invalid
|
||
<a class="link" href="BLooper.html" title="BLooper"><code class="classname">BLooper</code></a>s and
|
||
<a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a>s.</p></div></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="BInvoker_SetTimeout"></a>SetTimeout(), Timeout()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">SetTimeout</span>(<span class="methodparam"><span class="type">bigtime_t </span><span class="parameter">timeout</span></span>);</code><code class="methodsynopsis cpp"><span class="type">bigtime_t </span><span class="methodname">Timeout</span>() <span class="modifier">const</span>;</code><p><code class="methodname">SetTimeout()</code> sets the timeout that will be used
|
||
when sending the invocation message to the invoker's target. By default
|
||
this is <code class="constant">B_INFINITE_TIMEOUT</code>.</p><p><code class="methodname">Timeout()</code> returns the current setting for this value.</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code>.</span></p></td><td><p>No error.</p></td></tr></tbody></table></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BHandler.html">BHandler</a> Up: <a href="TheApplicationKit.html">The Application Kit</a> Next: <a href="BLooper.html">BLooper</a> </div><div id="footerB"><div id="footerBL"><a href="BHandler.html" title="BHandler"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheApplicationKit.html" title="The Application Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BLooper.html" title="BLooper"><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>
|