Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/spirit/phoenix/doc/actors.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 4.3 KB
Line 
1<html>
2<head>
3<!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc -->
4<title>Actors</title>
5<link rel="stylesheet" href="theme/style.css" type="text/css">
6<link rel="prev" href="organization.html">
7<link rel="next" href="primitives.html">
8</head>
9<body>
10<table width="100%" height="48" border="0" background="theme/bkd2.gif" cellspacing="2">
11  <tr>
12    <td width="10">
13    </td>
14    <td width="85%">
15      <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Actors</b></font>
16    </td>
17    <td width="112"><a href="http://spirit.sf.net"><img src="theme/spirit.gif" align="right" border="0"></a></td>
18  </tr>
19</table>
20<br>
21<table border="0">
22  <tr>
23    <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
24    <td width="30"><a href="organization.html"><img src="theme/l_arr.gif" border="0"></a></td>
25    <td width="20"><a href="primitives.html"><img src="theme/r_arr.gif" border="0"></a></td>
26   </tr>
27</table>
28<p>
29Actors are functors. Actors are the main driving force behind the framework. An actor can accept 0 to N arguments (where N is a predefined maximum). In an abstract point of view, an actor is the metaphor of a function declaration. The actor has no function body at all, which means that it does not know how to perform any function at all.</p>
30<table width="80%" border="0" align="center">
31  <tr>
32    <td class="note_box">
33<img src="theme/note.gif"></img> an actor is the metaphor of a function declaration    </td>
34  </tr>
35</table>
36<p>
37The actor is a template class though, and its sole template parameter fills in the missing function body and does the actual function evaluation. The actor class derives from its template argument. Here's the simplified actor class declaration:</p>
38<code><pre>
39    <span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>BaseT</span><span class=special>&gt;
40    </span><span class=keyword>struct </span><span class=identifier>actor </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>BaseT </span><span class=special>{ /*...*/ };
41</span></pre></code>
42<p>
43To avoid being overwhelmed in details, the following is a brief overview of what an actor is. First, imagine an actor as a non- lazy function that accepts 0..N arguments:</p>
44<code><pre>
45    <span class=identifier>actor</span><span class=special>(</span><span class=identifier>a0</span><span class=special>, </span><span class=identifier>a1</span><span class=special>, ... </span><span class=identifier>aN</span><span class=special>)
46</span></pre></code>
47<p>
48Not knowing what to do with the arguments passed in, the actor forwards the arguments received from the client (caller) onto its base class BaseT. It is the base class that does the actual operation, finally returning a result. In essence, the actor's base class is the metaphor of the function body. The sequence of events that transpire is outlined informally as follows:</p>
49<p>
501)  actor is called, passing in N arguments:</p>
51<p>
52client --&gt; actor(a0, a1, ... aN)</p>
53<p>
542)  actor forwards the arguments to its base:</p>
55<p>
56--&gt; actor's base(a0, a1, ... aN)</p>
57<p>
583)  actor's base does some computation and returns a result back to the actor, and finally, the actor returns this back to the client:</p>
59<p>
60actor's base operation --&gt; return result --&gt; actor --&gt; client</p>
61<table width="80%" border="0" align="center">
62  <tr>
63    <td class="note_box">
64<img src="theme/note.gif"></img> In essence, the actor's base class is the metaphor of the function body    </td>
65  </tr>
66</table>
67<p>
68For further details, we shall see more in-depth information later as we move on to the more technical side of the framework.</p>
69<table border="0">
70  <tr>
71    <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
72    <td width="30"><a href="organization.html"><img src="theme/l_arr.gif" border="0"></a></td>
73    <td width="20"><a href="primitives.html"><img src="theme/r_arr.gif" border="0"></a></td>
74   </tr>
75</table>
76<br>
77<hr size="1">
78<p class="copyright">Copyright &copy; 2001-2002 Joel de Guzman<br>
79  <br>
80<font size="2">Use, modification and distribution is subject to the Boost Software
81    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
82    http://www.boost.org/LICENSE_1_0.txt) </font> </p>
83</body>
84</html>
Note: See TracBrowser for help on using the repository browser.