root/doc/html/signals__slots_8h-source.html @ 353

Revision 353, 54.7 kB (checked in by smidl, 16 years ago)

doc

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: signals_slots.h Source File</title>
4<link href="tabs.css" rel="stylesheet" type="text/css">
5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.8 -->
8<script type="text/javascript">
9<!--
10function changeDisplayState (e){
11  var num=this.id.replace(/[^[0-9]/g,'');
12  var button=this.firstChild;
13  var sectionDiv=document.getElementById('dynsection'+num);
14  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
15    sectionDiv.style.display='block';
16    button.src='open.gif';
17  }else{
18    sectionDiv.style.display='none';
19    button.src='closed.gif';
20  }
21}
22function initDynSections(){
23  var divs=document.getElementsByTagName('div');
24  var sectionCounter=1;
25  for(var i=0;i<divs.length-1;i++){
26    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
27      var header=divs[i];
28      var section=divs[i+1];
29      var button=header.firstChild;
30      if (button!='IMG'){
31        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
32        button=document.createElement('img');
33        divs[i].insertBefore(button,divs[i].firstChild);
34      }
35      header.style.cursor='pointer';
36      header.onclick=changeDisplayState;
37      header.id='dynheader'+sectionCounter;
38      button.src='closed.gif';
39      section.id='dynsection'+sectionCounter;
40      section.style.display='none';
41      section.style.marginLeft='14px';
42      sectionCounter++;
43    }
44  }
45}
46window.onload = initDynSections;
47-->
48</script>
49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
53      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
54      <li><a href="modules.html"><span>Modules</span></a></li>
55      <li><a href="annotated.html"><span>Classes</span></a></li>
56      <li class="current"><a href="files.html"><span>Files</span></a></li>
57    </ul>
58  </div>
59  <div class="tabs">
60    <ul>
61      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
62      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
63    </ul>
64  </div>
65<h1>signals_slots.h</h1><a href="signals__slots_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
66<a name="l00029"></a>00029 <span class="preprocessor">#ifndef SIGNAL_SLOT_H</span>
67<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define SIGNAL_SLOT_H</span>
68<a name="l00031"></a>00031 <span class="preprocessor"></span>
69<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="events_8h.html" title="Definitions of an event-based simulation class.">itpp/protocol/events.h</a>&gt;</span>
70<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;list&gt;</span>
71<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;iostream&gt;</span>
72<a name="l00035"></a>00035
73<a name="l00036"></a>00036
74<a name="l00037"></a>00037 <span class="keyword">namespace </span>itpp
75<a name="l00038"></a>00038 {
76<a name="l00039"></a>00039
77<a name="l00041"></a>00041
78<a name="l00042"></a>00042
79<a name="l00043"></a>00043 <span class="keyword">class </span>Base_Signal;
80<a name="l00044"></a>00044 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt; <span class="keyword">class </span>Signal;
81<a name="l00045"></a>00045 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt; <span class="keyword">class </span>Base_Slot;
82<a name="l00046"></a>00046 <span class="keyword">template</span>&lt;<span class="keyword">class</span> ObjectType, <span class="keyword">class</span> DataType&gt; <span class="keyword">class </span>Slot;
83<a name="l00047"></a>00047
84<a name="l00048"></a>00048
85<a name="l00112"></a>00112 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
86<a name="l00113"></a><a class="code" href="classitpp_1_1Signal.html">00113</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal</a>
87<a name="l00114"></a>00114 {
88<a name="l00115"></a>00115 <span class="keyword">public</span>:
89<a name="l00116"></a>00116   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classitpp_1_1Base__Slot.html" title="Base Slot class.">Base_Slot</a>&lt;DataType&gt;;
90<a name="l00117"></a>00117
91<a name="l00119"></a>00119   <a class="code" href="group__protocol.html#g74aeb8837f321e75c9de837909b94b9d" title="Default constructor.">Signal</a>(<span class="keyword">const</span> std::string signal_name = <span class="stringliteral">"Unamed Signal"</span>, <span class="keyword">const</span> <span class="keywordtype">bool</span> single_shot = <span class="keyword">false</span>, <span class="keyword">const</span> <span class="keywordtype">bool</span> enable_debug = <span class="keyword">false</span>);
92<a name="l00120"></a>00120
93<a name="l00121"></a>00121   <span class="comment">//  Signal(const std::string signal_name = "Unamed Signal", const bool single_shot = false, const bool enable_debug = true);</span>
94<a name="l00122"></a>00122
95<a name="l00124"></a>00124   <a class="code" href="group__protocol.html#g78e4c0bc2d93c8e4e7f21580414602ff" title="Destructor.">~Signal</a>();
96<a name="l00125"></a>00125
97<a name="l00127"></a>00127   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g5d7f0451e79dbbf5392acba0446fc2dc" title="Connect a slot to the signal.">connect</a>(<a class="code" href="classitpp_1_1Base__Slot.html">Base_Slot&lt;DataType&gt;</a>* slot);
98<a name="l00128"></a>00128
99<a name="l00130"></a>00130   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gc3c035d4b8565d1bafc58a8092ced7d7" title="Disconnect the slot from the signal.">disconnect</a>(<a class="code" href="classitpp_1_1Base__Slot.html">Base_Slot&lt;DataType&gt;</a>* slot = NULL);
100<a name="l00131"></a>00131
101<a name="l00132"></a>00132   <span class="comment">//  Base_Event* arm(const Ttype delta_time, DataType signal); // Signal will trigger in 'delta_time' time units carrying data signal.</span>
102<a name="l00133"></a>00133
103<a name="l00134"></a>00134
104<a name="l00136"></a>00136   <a class="code" href="classitpp_1_1Base__Event.html" title="Base Event Class.">Base_Event</a>* <a class="code" href="group__protocol.html#g7a6e9d6da75436c16add44847e98e32a" title="Issue a signal.">operator()</a>(DataType signal, <span class="keyword">const</span> <a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a> delta_time = 0);
105<a name="l00137"></a>00137
106<a name="l00139"></a>00139   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079" title="cancel signal">cancel</a>();
107<a name="l00140"></a>00140
108<a name="l00142"></a>00142   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g02061d18d1b74311f2fc3b6bc0005b22" title="set name of signal">set_name</a>(<span class="keyword">const</span> std::string &amp;signal_name);
109<a name="l00143"></a>00143
110<a name="l00145"></a>00145   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g7726292b50426ec743036cfaceb85229" title="Set debug mode. If true all signals are printed to stdout.">set_debug</a>(<span class="keyword">const</span> <span class="keywordtype">bool</span> enable_debug = <span class="keyword">true</span>);
111<a name="l00146"></a>00146
112<a name="l00148"></a>00148   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gebfcb689c9e4f2597fd798ff9876f1ba" title="ADD DOCUMENTATION HERE.">trigger</a>(DataType u);
113<a name="l00149"></a>00149
114<a name="l00150"></a>00150 <span class="keyword">protected</span>:
115<a name="l00152"></a><a class="code" href="classitpp_1_1Signal.html#d6dd6fc22d262c94754a0220faf66d91">00152</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> std::list&lt;Base_Slot&lt;DataType&gt;*, std::allocator&lt; Base_Slot&lt;DataType&gt;* &gt; &gt;::iterator <a class="code" href="classitpp_1_1Signal.html#d6dd6fc22d262c94754a0220faf66d91" title="ADD DOCUMENTATION HERE.">Base_Slot_Iterator</a>;
116<a name="l00154"></a>00154   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gd1c35f96a708ce45dac3cd6fd109c038" title="ADD DOCUMENTATION HERE.">_disconnect</a>(<a class="code" href="classitpp_1_1Base__Slot.html">Base_Slot&lt;DataType&gt;</a>* slot);
117<a name="l00156"></a><a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b">00156</a>   std::list&lt;Base_Slot&lt;DataType&gt;*, std::allocator&lt;Base_Slot&lt;DataType&gt;* &gt; &gt; <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>;
118<a name="l00158"></a><a class="code" href="classitpp_1_1Signal.html#4f819ce01841304aa5de4042020f28a1">00158</a>   std::string <a class="code" href="classitpp_1_1Signal.html#4f819ce01841304aa5de4042020f28a1" title="ADD DOCUMENTATION HERE.">name</a>;
119<a name="l00159"></a>00159
120<a name="l00160"></a>00160 <span class="keyword">private</span>:
121<a name="l00161"></a>00161   <span class="keywordtype">bool</span> armed;
122<a name="l00162"></a>00162   <span class="keywordtype">bool</span> debug;
123<a name="l00163"></a>00163   <span class="keywordtype">bool</span> single;
124<a name="l00164"></a>00164   <a class="code" href="classitpp_1_1Data__Event.html">Data_Event&lt;Signal, DataType&gt;</a> *e;
125<a name="l00165"></a>00165 };
126<a name="l00166"></a>00166
127<a name="l00167"></a>00167
128<a name="l00172"></a>00172 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
129<a name="l00173"></a><a class="code" href="classitpp_1_1Base__Slot.html">00173</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Base__Slot.html" title="Base Slot class.">Base_Slot</a>
130<a name="l00174"></a>00174 {
131<a name="l00175"></a>00175 <span class="keyword">public</span>:
132<a name="l00176"></a>00176   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal</a>&lt;DataType&gt;;
133<a name="l00177"></a>00177
134<a name="l00179"></a>00179   <a class="code" href="group__protocol.html#g667618d8f9f96a1746676a9f19a46cb7" title="Default Constructor.">Base_Slot</a>(<span class="keyword">const</span> std::string slot_name = <span class="stringliteral">"Unamed Base_Slot"</span>);
135<a name="l00180"></a>00180
136<a name="l00182"></a>00182   <span class="keyword">virtual</span> <a class="code" href="group__protocol.html#gadaa18df05a4e4b1fe7f5bd33f1c1f8c" title="Desctuctor.">~Base_Slot</a>();
137<a name="l00183"></a>00183
138<a name="l00185"></a>00185   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gb7ab2e7102400aaddc25b4d2391a362c" title="set slot name">set_name</a>(<span class="keyword">const</span> std::string &amp;slot_name);
139<a name="l00186"></a>00186
140<a name="l00188"></a>00188   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Base__Slot.html#65be29b402190b432a3f6de8dc3eaecb" title="ADD DOCUMENTATION HERE.">operator()</a>(DataType signal) = 0;
141<a name="l00189"></a>00189
142<a name="l00190"></a>00190 <span class="keyword">protected</span>:
143<a name="l00191"></a>00191   <span class="comment">//   virtual void exec(DataType signal) = 0;</span>
144<a name="l00193"></a><a class="code" href="classitpp_1_1Base__Slot.html#e5a52d4322d97ec903a7df48c501eaa6">00193</a> <span class="comment"></span>  <span class="keyword">typedef</span> <span class="keyword">typename</span> std::list&lt;Signal&lt;DataType&gt;*, std::allocator&lt; Signal&lt;DataType&gt;* &gt; &gt;::iterator <a class="code" href="classitpp_1_1Base__Slot.html#e5a52d4322d97ec903a7df48c501eaa6" title="ADD DOCUMENTATION HERE.">Signal_Iterator</a>;
145<a name="l00195"></a><a class="code" href="classitpp_1_1Base__Slot.html#a5d915f5e558e9bb4bd0a7ba29a9b4bb">00195</a>   std::string <a class="code" href="classitpp_1_1Base__Slot.html#a5d915f5e558e9bb4bd0a7ba29a9b4bb" title="ADD DOCUMENTATION HERE.">name</a>;
146<a name="l00197"></a>00197   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g31624456935b5358663f149a2ce17cc3" title="ADD DOCUMENTATION HERE.">_connect</a>(<a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal&lt;DataType&gt;</a>* signal);
147<a name="l00199"></a>00199   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gd4c19805d68186dc424bdf254fc76ff7" title="ADD DOCUMENTATION HERE.">_disconnect</a>(<a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal&lt;DataType&gt;</a>* signal);
148<a name="l00201"></a><a class="code" href="classitpp_1_1Base__Slot.html#666a416de59acb28ed0928cd56c679ae">00201</a>   std::list&lt;Signal&lt;DataType&gt;*, std::allocator&lt;Signal&lt;DataType&gt;* &gt; &gt; <a class="code" href="classitpp_1_1Base__Slot.html#666a416de59acb28ed0928cd56c679ae" title="ADD DOCUMENTATION HERE.">connected_signals</a>;
149<a name="l00202"></a>00202 };
150<a name="l00203"></a>00203
151<a name="l00208"></a>00208 <span class="keyword">template</span>&lt;<span class="keyword">class</span> ObjectType, <span class="keyword">class</span> DataType&gt;
152<a name="l00209"></a><a class="code" href="classitpp_1_1Slot.html">00209</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Slot.html" title="Slot Class.">Slot</a> : <span class="keyword">public</span> <a class="code" href="classitpp_1_1Base__Slot.html" title="Base Slot class.">Base_Slot</a>&lt;DataType&gt;
153<a name="l00210"></a>00210 {
154<a name="l00211"></a>00211 <span class="keyword">public</span>:
155<a name="l00213"></a>00213   <a class="code" href="group__protocol.html#geccd572d05e2bed561de07fc97afa505" title="Default constructor.">Slot</a>(<span class="keyword">const</span> std::string _name = <span class="stringliteral">"Unamed Slot"</span>);
156<a name="l00214"></a>00214
157<a name="l00216"></a>00216   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gd1dc9e2216a8e4f623efa1201781200e" title="ADD DOCUMENTATION HERE.">forward</a>(ObjectType *object_pointer, <span class="keywordtype">void</span>(ObjectType::*object_function_pointer)(DataType u));
158<a name="l00217"></a>00217
159<a name="l00219"></a>00219   <a class="code" href="group__protocol.html#g6141c6ab7124f18bb3cf72cf55b846da" title="Destructor.">~Slot</a>();
160<a name="l00220"></a>00220
161<a name="l00222"></a>00222   <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g66cdc4cc386c1fa9bb1f3697e6d35c71" title="ADD DOCUMENTATION HERE.">operator()</a>(DataType u);
162<a name="l00223"></a>00223
163<a name="l00224"></a>00224   <span class="comment">//void exec(DataType signal);</span>
164<a name="l00225"></a>00225
165<a name="l00226"></a>00226 <span class="keyword">private</span>:
166<a name="l00227"></a>00227   ObjectType *po;
167<a name="l00228"></a>00228   void(ObjectType::*pm)(DataType signal);
168<a name="l00229"></a>00229 };
169<a name="l00230"></a>00230
170<a name="l00231"></a>00231
171<a name="l00235"></a>00235 <span class="keyword">template</span>&lt;<span class="keyword">class</span> ObjectType, <span class="keyword">class</span> DataType&gt;
172<a name="l00236"></a>00236 <span class="keyword">class </span>ATimer
173<a name="l00237"></a>00237 {
174<a name="l00238"></a>00238 <span class="keyword">public</span>:
175<a name="l00240"></a>00240   ATimer(<span class="keyword">const</span> std::string <a class="code" href="classitpp_1_1Name.html" title="Automatic naming when savingAn easy way to give a variable a name and optionally...">Name</a> = <span class="stringliteral">"Unamed ATimer"</span>) {
176<a name="l00241"></a>00241     time_out_signal = <span class="keyword">new</span> <a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal&lt;DataType&gt;</a>(<a class="code" href="classitpp_1_1Name.html" title="Automatic naming when savingAn easy way to give a variable a name and optionally...">Name</a>, <span class="keyword">true</span>);
177<a name="l00242"></a>00242     time_out_slot = <span class="keyword">new</span> <a class="code" href="classitpp_1_1Slot.html" title="Slot Class.">Slot&lt;ObjectType, DataType&gt;</a>(Name);
178<a name="l00243"></a>00243     time_out_signal-&gt;connect(time_out_slot);
179<a name="l00244"></a>00244     set_name(Name);
180<a name="l00245"></a>00245   }
181<a name="l00246"></a>00246
182<a name="l00248"></a>00248   <span class="keywordtype">void</span> forward(ObjectType *po, <span class="keywordtype">void</span>(ObjectType::*pm)(DataType u)) { time_out_slot-&gt;forward(po, pm); }
183<a name="l00249"></a>00249
184<a name="l00251"></a>00251   <span class="keywordtype">void</span> <span class="keyword">set</span>(DataType u, <span class="keyword">const</span> <a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a> delta_t) {
185<a name="l00252"></a>00252     time_out_signal-&gt;operator()(u, delta_t);
186<a name="l00253"></a>00253   }
187<a name="l00254"></a>00254
188<a name="l00256"></a>00256   <span class="keywordtype">void</span> cancel() { time_out_signal-&gt;<a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079" title="cancel signal">cancel</a>(); }
189<a name="l00257"></a>00257
190<a name="l00259"></a>00259   <span class="keywordtype">void</span> set_name(<span class="keyword">const</span> std::string Name) {
191<a name="l00260"></a>00260     name = Name;
192<a name="l00261"></a>00261     time_out_signal-&gt;set_name(name);
193<a name="l00262"></a>00262     time_out_slot-&gt;<a class="code" href="group__protocol.html#g02061d18d1b74311f2fc3b6bc0005b22" title="set name of signal">set_name</a>(name);
194<a name="l00263"></a>00263   }
195<a name="l00264"></a>00264
196<a name="l00265"></a>00265 <span class="keyword">protected</span>:
197<a name="l00267"></a>00267   std::string name;
198<a name="l00268"></a>00268
199<a name="l00269"></a>00269 <span class="keyword">private</span>:
200<a name="l00270"></a>00270   Signal&lt;DataType&gt; *time_out_signal;
201<a name="l00271"></a>00271   Slot&lt;ObjectType, DataType&gt; *time_out_slot;
202<a name="l00272"></a>00272 };
203<a name="l00273"></a>00273
204<a name="l00274"></a>00274
205<a name="l00275"></a>00275
206<a name="l00284"></a>00284 <span class="keyword">template</span> &lt;<span class="keyword">class</span> THandler&gt;
207<a name="l00285"></a><a class="code" href="classitpp_1_1TTimer.html">00285</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1TTimer.html">TTimer</a>
208<a name="l00286"></a>00286 {
209<a name="l00287"></a>00287 <span class="keyword">public</span>:
210<a name="l00289"></a><a class="code" href="classitpp_1_1TTimer.html#b52b5b2319fc9014efb5a882617dd23e">00289</a>   <a class="code" href="classitpp_1_1TTimer.html#b52b5b2319fc9014efb5a882617dd23e" title="Default constructor.">TTimer</a>(THandler &amp; handler, <span class="keywordtype">void</span> (THandler::*handlerFunction)(<a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a> time)) :
211<a name="l00290"></a>00290       signal(<span class="stringliteral">"timer_signal"</span>, true) {
212<a name="l00291"></a>00291     <a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a> = <span class="keyword">false</span>;
213<a name="l00292"></a>00292     <a class="code" href="classitpp_1_1TTimer.html#12e6f66dd9333656113328edb9e0af04" title="ADD DOCUMENTATION HERE.">fExpirationTime</a> = 0;
214<a name="l00293"></a>00293
215<a name="l00294"></a>00294     registered_handler = &amp;handler;
216<a name="l00295"></a>00295     registered_handler_function = handlerFunction;
217<a name="l00296"></a>00296
218<a name="l00297"></a>00297     slot.<a class="code" href="group__protocol.html#gd1dc9e2216a8e4f623efa1201781200e" title="ADD DOCUMENTATION HERE.">forward</a>(<span class="keyword">this</span>, &amp;<a class="code" href="classitpp_1_1TTimer.html">TTimer&lt;THandler&gt;::HandleProcessEvent</a>);
219<a name="l00298"></a>00298     slot.<a class="code" href="group__protocol.html#gb7ab2e7102400aaddc25b4d2391a362c" title="set slot name">set_name</a>(<span class="stringliteral">"timer_slot"</span>);
220<a name="l00299"></a>00299     signal.<a class="code" href="group__protocol.html#g7726292b50426ec743036cfaceb85229" title="Set debug mode. If true all signals are printed to stdout.">set_debug</a>(<span class="keyword">false</span>);
221<a name="l00300"></a>00300     signal.<a class="code" href="group__protocol.html#g5d7f0451e79dbbf5392acba0446fc2dc" title="Connect a slot to the signal.">connect</a>(&amp;slot);
222<a name="l00301"></a>00301   }
223<a name="l00302"></a>00302
224<a name="l00304"></a><a class="code" href="classitpp_1_1TTimer.html#3af3b027878117513f83ac32a2cb35a1">00304</a>   <span class="keyword">virtual</span> <a class="code" href="classitpp_1_1TTimer.html#3af3b027878117513f83ac32a2cb35a1" title="Destructor.">~TTimer</a>() {
225<a name="l00305"></a>00305     <span class="keywordflow">if</span> (<a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a>)
226<a name="l00306"></a>00306       signal.<a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079" title="cancel signal">cancel</a>();
227<a name="l00307"></a>00307   }
228<a name="l00308"></a>00308
229<a name="l00310"></a><a class="code" href="classitpp_1_1TTimer.html#7fcbf2f530a950efb0af502bed8abce2">00310</a>   <span class="keywordtype">void</span>  <a class="code" href="classitpp_1_1TTimer.html#7fcbf2f530a950efb0af502bed8abce2" title="ADD DOCUMENTATION HERE.">Set</a>(<a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a> time, <span class="keywordtype">bool</span> relative = <span class="keyword">true</span>) {
230<a name="l00311"></a>00311     <span class="keywordflow">if</span> (<a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a>)
231<a name="l00312"></a>00312       signal.<a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079" title="cancel signal">cancel</a>();
232<a name="l00313"></a>00313
233<a name="l00314"></a>00314     <a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a> = <span class="keyword">true</span>;
234<a name="l00315"></a>00315     <span class="keywordtype">double</span> current_time = <a class="code" href="classitpp_1_1Event__Queue.html#ac4b417979ddc31b7588602a3c1438e6" title="Return current time.">Event_Queue::now</a>();
235<a name="l00316"></a>00316     <span class="keywordtype">double</span> delta_time;
236<a name="l00317"></a>00317     <span class="keywordflow">if</span> (relative) {
237<a name="l00318"></a>00318       <a class="code" href="classitpp_1_1TTimer.html#12e6f66dd9333656113328edb9e0af04" title="ADD DOCUMENTATION HERE.">fExpirationTime</a> = current_time + time;
238<a name="l00319"></a>00319       delta_time = time;
239<a name="l00320"></a>00320     }
240<a name="l00321"></a>00321     <span class="keywordflow">else</span> {
241<a name="l00322"></a>00322       <a class="code" href="classitpp_1_1TTimer.html#12e6f66dd9333656113328edb9e0af04" title="ADD DOCUMENTATION HERE.">fExpirationTime</a> = time;
242<a name="l00323"></a>00323       delta_time = time - current_time;
243<a name="l00324"></a>00324     }
244<a name="l00325"></a>00325     signal(<a class="code" href="classitpp_1_1TTimer.html#12e6f66dd9333656113328edb9e0af04" title="ADD DOCUMENTATION HERE.">fExpirationTime</a>, delta_time);
245<a name="l00326"></a>00326   }
246<a name="l00327"></a>00327
247<a name="l00329"></a><a class="code" href="classitpp_1_1TTimer.html#bc25e24ceb85a2832850a49e401c5435">00329</a>   <span class="keywordtype">void</span>  <a class="code" href="classitpp_1_1TTimer.html#bc25e24ceb85a2832850a49e401c5435" title="ADD DOCUMENTATION HERE.">Reset</a>() {
248<a name="l00330"></a>00330     <span class="keywordflow">if</span> (<a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a>) {
249<a name="l00331"></a>00331       signal.<a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079" title="cancel signal">cancel</a>();
250<a name="l00332"></a>00332       <a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a> = <span class="keyword">false</span>; <span class="comment">// TODO: Added this myself. Didn't work otherwise.</span>
251<a name="l00333"></a>00333     }
252<a name="l00334"></a>00334   }
253<a name="l00335"></a>00335
254<a name="l00337"></a><a class="code" href="classitpp_1_1TTimer.html#db22a58e770b0381ac024b801ea17ce5">00337</a>   <a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a>  <a class="code" href="classitpp_1_1TTimer.html#db22a58e770b0381ac024b801ea17ce5" title="ADD DOCUMENTATION HERE.">ExpirationTime</a>()<span class="keyword"> const </span>{
255<a name="l00338"></a>00338     <a class="code" href="group__errorhandlingfunc.html#gd5c34b291e5018534fd2344486e2b5a1" title="Abort if t is not true.">it_assert</a>(<a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a>, <span class="stringliteral">"TTimer&lt;&gt;::ExpirationTime: timer not set"</span>);
256<a name="l00339"></a>00339     <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1TTimer.html#12e6f66dd9333656113328edb9e0af04" title="ADD DOCUMENTATION HERE.">fExpirationTime</a>;
257<a name="l00340"></a>00340   }
258<a name="l00341"></a>00341
259<a name="l00343"></a><a class="code" href="classitpp_1_1TTimer.html#b82a771e98eeeb14c4d9b7b9067915f9">00343</a>   <span class="keywordtype">bool</span>  <a class="code" href="classitpp_1_1TTimer.html#b82a771e98eeeb14c4d9b7b9067915f9" title="ADD DOCUMENTATION HERE.">IsPending</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a>; }
260<a name="l00344"></a>00344
261<a name="l00345"></a>00345 <span class="keyword">protected</span>:
262<a name="l00347"></a><a class="code" href="classitpp_1_1TTimer.html#dc8dab5a5a7fa6e559aa0b25960cb164">00347</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1TTimer.html#dc8dab5a5a7fa6e559aa0b25960cb164" title="ADD DOCUMENTATION HERE.">HandleProcessEvent</a>(<a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a> currentTime) {
263<a name="l00348"></a>00348     <a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a> = <span class="keyword">false</span>;
264<a name="l00349"></a>00349     (*registered_handler.*registered_handler_function)(currentTime);
265<a name="l00350"></a>00350   }
266<a name="l00351"></a>00351
267<a name="l00353"></a><a class="code" href="classitpp_1_1TTimer.html#fc88d99905440868e14eaf79afd8497b">00353</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1TTimer.html#fc88d99905440868e14eaf79afd8497b" title="ADD DOCUMENTATION HERE.">HandleCancelEvent</a>(<a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a>) {
268<a name="l00354"></a>00354     <span class="keywordflow">if</span> (<a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a>)
269<a name="l00355"></a>00355       signal.<a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079" title="cancel signal">cancel</a>();
270<a name="l00356"></a>00356
271<a name="l00357"></a>00357     <a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a> = <span class="keyword">false</span>;
272<a name="l00358"></a>00358   }
273<a name="l00359"></a>00359
274<a name="l00361"></a><a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d">00361</a>   <span class="keywordtype">bool</span>  <a class="code" href="classitpp_1_1TTimer.html#c5c73915dfdaa191722958214bf9844d" title="Flag denoting if timer is set.">fPending</a>;
275<a name="l00363"></a><a class="code" href="classitpp_1_1TTimer.html#12e6f66dd9333656113328edb9e0af04">00363</a>   <a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a>  <a class="code" href="classitpp_1_1TTimer.html#12e6f66dd9333656113328edb9e0af04" title="ADD DOCUMENTATION HERE.">fExpirationTime</a>;
276<a name="l00364"></a>00364
277<a name="l00365"></a>00365 <span class="keyword">private</span>:
278<a name="l00366"></a>00366   THandler *registered_handler;
279<a name="l00367"></a>00367   void(THandler::*registered_handler_function)(<a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a> expiry_time);
280<a name="l00368"></a>00368
281<a name="l00369"></a>00369   <a class="code" href="classitpp_1_1Signal.html">Signal&lt;double&gt;</a> signal;     <span class="comment">// Used internally</span>
282<a name="l00370"></a>00370   <a class="code" href="classitpp_1_1Slot.html">Slot&lt;TTimer, double&gt;</a> slot; <span class="comment">// Used internally</span>
283<a name="l00371"></a>00371 };
284<a name="l00372"></a>00372
285<a name="l00373"></a>00373
286<a name="l00374"></a>00374
287<a name="l00375"></a>00375
288<a name="l00376"></a>00376
289<a name="l00377"></a>00377
290<a name="l00378"></a>00378 <span class="comment">// -----------------------------------------------------------------------------------------------</span>
291<a name="l00379"></a>00379
292<a name="l00380"></a>00380 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
293<a name="l00381"></a><a class="code" href="group__protocol.html#g74aeb8837f321e75c9de837909b94b9d">00381</a> <a class="code" href="group__protocol.html#g74aeb8837f321e75c9de837909b94b9d" title="Default constructor.">Signal&lt;DataType&gt;::Signal</a>(<span class="keyword">const</span> std::string signal_name, <span class="keyword">const</span> <span class="keywordtype">bool</span> single_shot, <span class="keyword">const</span> <span class="keywordtype">bool</span> enable_debug)
294<a name="l00382"></a>00382 {
295<a name="l00383"></a>00383   armed = <span class="keyword">false</span>;
296<a name="l00384"></a>00384   e = NULL;
297<a name="l00385"></a>00385   single = single_shot;
298<a name="l00386"></a>00386   <a class="code" href="group__protocol.html#g02061d18d1b74311f2fc3b6bc0005b22" title="set name of signal">set_name</a>(signal_name);
299<a name="l00387"></a>00387   <a class="code" href="group__protocol.html#g7726292b50426ec743036cfaceb85229" title="Set debug mode. If true all signals are printed to stdout.">set_debug</a>(enable_debug);
300<a name="l00388"></a>00388 }
301<a name="l00389"></a>00389
302<a name="l00390"></a>00390 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
303<a name="l00391"></a><a class="code" href="group__protocol.html#g78e4c0bc2d93c8e4e7f21580414602ff">00391</a> <a class="code" href="group__protocol.html#g78e4c0bc2d93c8e4e7f21580414602ff" title="Destructor.">Signal&lt;DataType&gt;::~Signal</a>()
304<a name="l00392"></a>00392 {
305<a name="l00393"></a>00393   <a class="code" href="classitpp_1_1Signal.html#d6dd6fc22d262c94754a0220faf66d91" title="ADD DOCUMENTATION HERE.">Base_Slot_Iterator</a>
306<a name="l00394"></a>00394   begin = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.begin(),
307<a name="l00395"></a>00395           end   = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.end(),
308<a name="l00396"></a>00396                   i;
309<a name="l00397"></a>00397
310<a name="l00398"></a>00398   <span class="keywordflow">for</span> (i = begin; i != end; i++)
311<a name="l00399"></a>00399     (*i)-&gt;_disconnect(<span class="keyword">this</span>);
312<a name="l00400"></a>00400
313<a name="l00401"></a>00401   <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.clear();
314<a name="l00402"></a>00402
315<a name="l00403"></a>00403   <span class="keywordflow">if</span> (e != NULL) <span class="comment">// Cancel a possibly pending event since we are about to die!</span>
316<a name="l00404"></a>00404     e-&gt;<a class="code" href="classitpp_1_1Base__Event.html#4d007ec59181c639a4677d95d4011b70" title="Cancel an event.">cancel</a>();
317<a name="l00405"></a>00405 }
318<a name="l00406"></a>00406
319<a name="l00407"></a>00407 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
320<a name="l00408"></a><a class="code" href="group__protocol.html#g02061d18d1b74311f2fc3b6bc0005b22">00408</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g02061d18d1b74311f2fc3b6bc0005b22" title="set name of signal">Signal&lt;DataType&gt;::set_name</a>(<span class="keyword">const</span> std::string &amp;signal_name)
321<a name="l00409"></a>00409 {
322<a name="l00410"></a>00410   <a class="code" href="classitpp_1_1Signal.html#4f819ce01841304aa5de4042020f28a1" title="ADD DOCUMENTATION HERE.">name</a> = signal_name;
323<a name="l00411"></a>00411 }
324<a name="l00412"></a>00412
325<a name="l00413"></a>00413 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
326<a name="l00414"></a><a class="code" href="group__protocol.html#g7726292b50426ec743036cfaceb85229">00414</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g7726292b50426ec743036cfaceb85229" title="Set debug mode. If true all signals are printed to stdout.">Signal&lt;DataType&gt;::set_debug</a>(<span class="keyword">const</span> <span class="keywordtype">bool</span> enable_debug)
327<a name="l00415"></a>00415 {
328<a name="l00416"></a>00416   debug = enable_debug;
329<a name="l00417"></a>00417 }
330<a name="l00418"></a>00418
331<a name="l00419"></a>00419 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
332<a name="l00420"></a><a class="code" href="group__protocol.html#g5d7f0451e79dbbf5392acba0446fc2dc">00420</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g5d7f0451e79dbbf5392acba0446fc2dc" title="Connect a slot to the signal.">Signal&lt;DataType&gt;::connect</a>(<a class="code" href="classitpp_1_1Base__Slot.html">Base_Slot&lt;DataType&gt;</a>* slot)
333<a name="l00421"></a>00421 {
334<a name="l00422"></a>00422   <a class="code" href="classitpp_1_1Signal.html#d6dd6fc22d262c94754a0220faf66d91" title="ADD DOCUMENTATION HERE.">Base_Slot_Iterator</a>
335<a name="l00423"></a>00423   begin = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.begin(),
336<a name="l00424"></a>00424           end   = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.end(),
337<a name="l00425"></a>00425                   i;
338<a name="l00426"></a>00426
339<a name="l00427"></a>00427   <span class="keywordtype">bool</span> is_already_connected = <span class="keyword">false</span>;
340<a name="l00428"></a>00428
341<a name="l00429"></a>00429   <span class="keywordflow">for</span> (i = begin; i != end; i++)
342<a name="l00430"></a>00430     <span class="keywordflow">if</span> ((*i) == slot)
343<a name="l00431"></a>00431       is_already_connected = <span class="keyword">true</span>;
344<a name="l00432"></a>00432
345<a name="l00433"></a>00433   <span class="keywordflow">if</span> (!is_already_connected) { <span class="comment">// Multiple connections is meaningless.</span>
346<a name="l00434"></a>00434     <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.push_back(slot);
347<a name="l00435"></a>00435     slot-&gt;<a class="code" href="group__protocol.html#g31624456935b5358663f149a2ce17cc3" title="ADD DOCUMENTATION HERE.">_connect</a>(<span class="keyword">this</span>); <span class="comment">// Needed if a connected slot is deleted during run time.</span>
348<a name="l00436"></a>00436   }
349<a name="l00437"></a>00437   <span class="keywordflow">else</span> {
350<a name="l00438"></a>00438     std::cout &lt;&lt; <span class="stringliteral">"Signal '"</span> &lt;&lt; <a class="code" href="classitpp_1_1Signal.html#4f819ce01841304aa5de4042020f28a1" title="ADD DOCUMENTATION HERE.">name</a> &lt;&lt; <span class="stringliteral">"' and Slot '"</span> &lt;&lt; slot-&gt;<a class="code" href="classitpp_1_1Base__Slot.html#a5d915f5e558e9bb4bd0a7ba29a9b4bb" title="ADD DOCUMENTATION HERE.">name</a> &lt;&lt; <span class="stringliteral">"' are already connected. Multiple connections have no effect!"</span> &lt;&lt; std::endl;
351<a name="l00439"></a>00439   }
352<a name="l00440"></a>00440 }
353<a name="l00441"></a>00441
354<a name="l00442"></a>00442 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
355<a name="l00443"></a><a class="code" href="group__protocol.html#gc3c035d4b8565d1bafc58a8092ced7d7">00443</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gc3c035d4b8565d1bafc58a8092ced7d7" title="Disconnect the slot from the signal.">Signal&lt;DataType&gt;::disconnect</a>(<a class="code" href="classitpp_1_1Base__Slot.html">Base_Slot&lt;DataType&gt;</a>* slot)
356<a name="l00444"></a>00444 {
357<a name="l00445"></a>00445   <a class="code" href="classitpp_1_1Signal.html#d6dd6fc22d262c94754a0220faf66d91" title="ADD DOCUMENTATION HERE.">Base_Slot_Iterator</a>
358<a name="l00446"></a>00446   begin = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.begin(),
359<a name="l00447"></a>00447           end   = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.end(),
360<a name="l00448"></a>00448                   i;
361<a name="l00449"></a>00449
362<a name="l00450"></a>00450   <span class="keywordflow">for</span> (i = begin; i != end; i++)
363<a name="l00451"></a>00451     <span class="keywordflow">if</span> ((*i) == slot) {
364<a name="l00452"></a>00452       (*i)-&gt;_disconnect(<span class="keyword">this</span>);
365<a name="l00453"></a>00453       <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.erase(i);
366<a name="l00454"></a>00454       <span class="keywordflow">break</span>;
367<a name="l00455"></a>00455     }
368<a name="l00456"></a>00456 }
369<a name="l00457"></a>00457
370<a name="l00458"></a>00458 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
371<a name="l00459"></a><a class="code" href="group__protocol.html#g7a6e9d6da75436c16add44847e98e32a">00459</a> <a class="code" href="classitpp_1_1Base__Event.html" title="Base Event Class.">Base_Event</a>* <a class="code" href="group__protocol.html#g7a6e9d6da75436c16add44847e98e32a" title="Issue a signal.">Signal&lt;DataType&gt;::operator()</a>(DataType signal, <span class="keyword">const</span> <a class="code" href="group__protocol.html#g33cb6c41273f24dbf05adf6e7cdb1a04" title="64-bit floating point time">Ttype</a> delta_time)
372<a name="l00460"></a>00460 {
373<a name="l00461"></a>00461   <span class="comment">// Signal will trigger in 'delta_time' time units.</span>
374<a name="l00462"></a>00462   <span class="keywordflow">if</span> (single) { <span class="comment">// We are operating in single-shot mode.</span>
375<a name="l00463"></a>00463     <span class="keywordflow">if</span> (armed) { <span class="comment">// Cancel and schedule again with the new 'delta_time'.</span>
376<a name="l00464"></a>00464       <span class="keywordflow">if</span> (debug)
377<a name="l00465"></a>00465         std::cout &lt;&lt; <span class="stringliteral">"Warning: Changing time for Signal '"</span> &lt;&lt; <a class="code" href="classitpp_1_1Signal.html#4f819ce01841304aa5de4042020f28a1" title="ADD DOCUMENTATION HERE.">name</a> &lt;&lt; <span class="stringliteral">"'."</span> &lt;&lt; std::endl;
378<a name="l00466"></a>00466       <a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079" title="cancel signal">cancel</a>();
379<a name="l00467"></a>00467       <a class="code" href="group__protocol.html#g7a6e9d6da75436c16add44847e98e32a" title="Issue a signal.">operator()</a>(signal, delta_time);
380<a name="l00468"></a>00468     }
381<a name="l00469"></a>00469     <span class="keywordflow">else</span> {
382<a name="l00470"></a>00470       e = <span class="keyword">new</span> <a class="code" href="classitpp_1_1Data__Event.html">Data_Event&lt;Signal, DataType&gt;</a>(<span class="keyword">this</span>, &amp;<a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal&lt;DataType&gt;::trigger</a>, signal, delta_time);
383<a name="l00471"></a>00471       armed = <span class="keyword">true</span>;
384<a name="l00472"></a>00472       <a class="code" href="classitpp_1_1Event__Queue.html#9d01b44e3979d76865d1fee69733a97e" title="Add event to Queue.">Event_Queue::add</a>(e);
385<a name="l00473"></a>00473     }
386<a name="l00474"></a>00474   }
387<a name="l00475"></a>00475   <span class="keywordflow">else</span> { <span class="comment">// Continious mode (cancel() has no effect).</span>
388<a name="l00476"></a>00476     e = <span class="keyword">new</span> <a class="code" href="classitpp_1_1Data__Event.html">Data_Event&lt;Signal, DataType&gt;</a>(<span class="keyword">this</span>, &amp;<a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal&lt;DataType&gt;::trigger</a>, signal, delta_time);
389<a name="l00477"></a>00477     armed = <span class="keyword">true</span>;
390<a name="l00478"></a>00478     <a class="code" href="classitpp_1_1Event__Queue.html#9d01b44e3979d76865d1fee69733a97e" title="Add event to Queue.">Event_Queue::add</a>(e);
391<a name="l00479"></a>00479   }
392<a name="l00480"></a>00480   <span class="keywordflow">return</span> e;
393<a name="l00481"></a>00481 }
394<a name="l00482"></a>00482
395<a name="l00483"></a>00483 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
396<a name="l00484"></a><a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079">00484</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g6e72db614ae271b9a81eea6f2de11079" title="cancel signal">Signal&lt;DataType&gt;::cancel</a>()
397<a name="l00485"></a>00485 {
398<a name="l00486"></a>00486   <span class="keywordflow">if</span> (armed &amp;&amp; single) {
399<a name="l00487"></a>00487     e-&gt;<a class="code" href="classitpp_1_1Base__Event.html#4d007ec59181c639a4677d95d4011b70" title="Cancel an event.">cancel</a>();
400<a name="l00488"></a>00488     e = NULL;
401<a name="l00489"></a>00489     armed = <span class="keyword">false</span>;
402<a name="l00490"></a>00490   }
403<a name="l00491"></a>00491 }
404<a name="l00492"></a>00492
405<a name="l00493"></a>00493
406<a name="l00494"></a>00494 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
407<a name="l00495"></a><a class="code" href="group__protocol.html#gebfcb689c9e4f2597fd798ff9876f1ba">00495</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gebfcb689c9e4f2597fd798ff9876f1ba" title="ADD DOCUMENTATION HERE.">Signal&lt;DataType&gt;::trigger</a>(DataType u)
408<a name="l00496"></a>00496 {
409<a name="l00497"></a>00497   armed = <span class="keyword">false</span>;
410<a name="l00498"></a>00498   e = NULL;
411<a name="l00499"></a>00499   <a class="code" href="classitpp_1_1Signal.html#d6dd6fc22d262c94754a0220faf66d91" title="ADD DOCUMENTATION HERE.">Base_Slot_Iterator</a>
412<a name="l00500"></a>00500   begin = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.begin(),
413<a name="l00501"></a>00501           end   = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.end(),
414<a name="l00502"></a>00502                   i;
415<a name="l00503"></a>00503
416<a name="l00504"></a>00504   <span class="keywordflow">for</span> (i = begin; i != end; i++) { <span class="comment">// Execute all the functions of the connected slots.</span>
417<a name="l00505"></a>00505     <span class="keywordflow">if</span> (debug)
418<a name="l00506"></a>00506       std::cout &lt;&lt; <span class="stringliteral">"Time = "</span> &lt;&lt; <a class="code" href="classitpp_1_1Event__Queue.html#ac4b417979ddc31b7588602a3c1438e6" title="Return current time.">Event_Queue::now</a>() &lt;&lt; <span class="stringliteral">". Signal '"</span> &lt;&lt; <a class="code" href="classitpp_1_1Signal.html#4f819ce01841304aa5de4042020f28a1" title="ADD DOCUMENTATION HERE.">name</a> &lt;&lt; <span class="stringliteral">"' was sent to Slot '"</span> &lt;&lt; (*i)-&gt;name &lt;&lt; <span class="stringliteral">"'."</span> &lt;&lt; std::endl;
419<a name="l00507"></a>00507     (*i)-&gt;operator()(u);
420<a name="l00508"></a>00508   }
421<a name="l00509"></a>00509 }
422<a name="l00510"></a>00510
423<a name="l00511"></a>00511 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
424<a name="l00512"></a><a class="code" href="group__protocol.html#gd1c35f96a708ce45dac3cd6fd109c038">00512</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gd1c35f96a708ce45dac3cd6fd109c038" title="ADD DOCUMENTATION HERE.">Signal&lt;DataType&gt;::_disconnect</a>(<a class="code" href="classitpp_1_1Base__Slot.html">Base_Slot&lt;DataType&gt;</a>* slot)
425<a name="l00513"></a>00513 {
426<a name="l00514"></a>00514   <a class="code" href="classitpp_1_1Signal.html#d6dd6fc22d262c94754a0220faf66d91" title="ADD DOCUMENTATION HERE.">Base_Slot_Iterator</a>
427<a name="l00515"></a>00515   begin = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.begin(),
428<a name="l00516"></a>00516           end   = <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.end(),
429<a name="l00517"></a>00517                   i;
430<a name="l00518"></a>00518
431<a name="l00519"></a>00519   <span class="keywordflow">for</span> (i = begin; i != end; i++)
432<a name="l00520"></a>00520     <span class="keywordflow">if</span> ((*i) == slot) {
433<a name="l00521"></a>00521       <a class="code" href="classitpp_1_1Signal.html#599f5aa5eb0d834d09363ffa7cdaad3b" title="ADD DOCUMENTATION HERE.">connected_slots</a>.erase(i);
434<a name="l00522"></a>00522       <span class="keywordflow">break</span>;
435<a name="l00523"></a>00523     }
436<a name="l00524"></a>00524 }
437<a name="l00525"></a>00525
438<a name="l00526"></a>00526
439<a name="l00527"></a>00527 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
440<a name="l00528"></a><a class="code" href="group__protocol.html#g667618d8f9f96a1746676a9f19a46cb7">00528</a> <a class="code" href="group__protocol.html#g667618d8f9f96a1746676a9f19a46cb7" title="Default Constructor.">Base_Slot&lt;DataType&gt;::Base_Slot</a>(<span class="keyword">const</span> std::string slot_name)
441<a name="l00529"></a>00529 {
442<a name="l00530"></a>00530   set_name(slot_name);
443<a name="l00531"></a>00531 }
444<a name="l00532"></a>00532
445<a name="l00533"></a>00533 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
446<a name="l00534"></a><a class="code" href="group__protocol.html#gb7ab2e7102400aaddc25b4d2391a362c">00534</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Base__Slot.html" title="Base Slot class.">Base_Slot&lt;DataType&gt;::set_name</a>(<span class="keyword">const</span> std::string &amp;slot_name)
447<a name="l00535"></a>00535 {
448<a name="l00536"></a>00536   <a class="code" href="classitpp_1_1Base__Slot.html#a5d915f5e558e9bb4bd0a7ba29a9b4bb" title="ADD DOCUMENTATION HERE.">name</a> = slot_name;
449<a name="l00537"></a>00537 }
450<a name="l00538"></a>00538
451<a name="l00539"></a>00539 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
452<a name="l00540"></a><a class="code" href="group__protocol.html#gadaa18df05a4e4b1fe7f5bd33f1c1f8c">00540</a> <a class="code" href="group__protocol.html#gadaa18df05a4e4b1fe7f5bd33f1c1f8c" title="Desctuctor.">Base_Slot&lt;DataType&gt;::~Base_Slot</a>()
453<a name="l00541"></a>00541 { <span class="comment">// Notify all signals connect that we are being deleted ...</span>
454<a name="l00542"></a>00542
455<a name="l00543"></a>00543   Signal_Iterator
456<a name="l00544"></a>00544   begin = connected_signals.begin(),
457<a name="l00545"></a>00545           end   = connected_signals.end(),
458<a name="l00546"></a>00546                   i;
459<a name="l00547"></a>00547
460<a name="l00548"></a>00548   <span class="keywordflow">for</span> (i = begin; i != end; i++)
461<a name="l00549"></a>00549     (*i)-&gt;_disconnect(<span class="keyword">this</span>);
462<a name="l00550"></a>00550
463<a name="l00551"></a>00551   connected_signals.clear();
464<a name="l00552"></a>00552 }
465<a name="l00553"></a>00553
466<a name="l00554"></a>00554 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
467<a name="l00555"></a><a class="code" href="group__protocol.html#g31624456935b5358663f149a2ce17cc3">00555</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Base__Slot.html" title="Base Slot class.">Base_Slot&lt;DataType&gt;::_connect</a>(<a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal&lt;DataType&gt;</a>* signal)
468<a name="l00556"></a>00556 { <span class="comment">// A signal is being connected to us.</span>
469<a name="l00557"></a>00557   <a class="code" href="classitpp_1_1Base__Slot.html#666a416de59acb28ed0928cd56c679ae" title="ADD DOCUMENTATION HERE.">connected_signals</a>.push_back(signal);
470<a name="l00558"></a>00558 }
471<a name="l00559"></a>00559
472<a name="l00560"></a>00560 <span class="keyword">template</span>&lt;<span class="keyword">class</span> DataType&gt;
473<a name="l00561"></a><a class="code" href="group__protocol.html#gd4c19805d68186dc424bdf254fc76ff7">00561</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gd4c19805d68186dc424bdf254fc76ff7" title="ADD DOCUMENTATION HERE.">Base_Slot&lt;DataType&gt;::_disconnect</a>(<a class="code" href="classitpp_1_1Signal.html" title="Signals and slots.">Signal&lt;DataType&gt;</a>* signal)
474<a name="l00562"></a>00562 { <span class="comment">// A signal is being disconnected from us.</span>
475<a name="l00563"></a>00563
476<a name="l00564"></a>00564   Signal_Iterator
477<a name="l00565"></a>00565   begin = connected_signals.begin(),
478<a name="l00566"></a>00566           end   = connected_signals.end(),
479<a name="l00567"></a>00567                   i;
480<a name="l00568"></a>00568
481<a name="l00569"></a>00569   <span class="keywordflow">for</span> (i = begin; i != end; i++)
482<a name="l00570"></a>00570     <span class="keywordflow">if</span> ((*i) == signal) {
483<a name="l00571"></a>00571       connected_signals.erase(i);
484<a name="l00572"></a>00572       <span class="keywordflow">break</span>;
485<a name="l00573"></a>00573     }
486<a name="l00574"></a>00574 }
487<a name="l00575"></a>00575
488<a name="l00576"></a>00576 <span class="keyword">template</span>&lt;<span class="keyword">class</span> ObjectType, <span class="keyword">class</span> DataType&gt;
489<a name="l00577"></a><a class="code" href="group__protocol.html#geccd572d05e2bed561de07fc97afa505">00577</a> <a class="code" href="classitpp_1_1Slot.html" title="Slot Class.">Slot&lt;ObjectType, DataType&gt;::Slot</a>(<span class="keyword">const</span> std::string slot_name) : <a class="code" href="classitpp_1_1Base__Slot.html" title="Base Slot class.">Base_Slot</a>&lt;DataType&gt;(slot_name)
490<a name="l00578"></a>00578 {
491<a name="l00579"></a>00579   pm = NULL;
492<a name="l00580"></a>00580   po = NULL;
493<a name="l00581"></a>00581 }
494<a name="l00582"></a>00582
495<a name="l00583"></a>00583 <span class="keyword">template</span>&lt;<span class="keyword">class</span> ObjectType, <span class="keyword">class</span> DataType&gt;
496<a name="l00584"></a><a class="code" href="group__protocol.html#g6141c6ab7124f18bb3cf72cf55b846da">00584</a> <a class="code" href="group__protocol.html#g6141c6ab7124f18bb3cf72cf55b846da" title="Destructor.">Slot&lt;ObjectType, DataType&gt;::~Slot</a>() {}
497<a name="l00585"></a>00585
498<a name="l00586"></a>00586 <span class="keyword">template</span>&lt;<span class="keyword">class</span> ObjectType, <span class="keyword">class</span> DataType&gt;
499<a name="l00587"></a><a class="code" href="group__protocol.html#gd1dc9e2216a8e4f623efa1201781200e">00587</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#gd1dc9e2216a8e4f623efa1201781200e" title="ADD DOCUMENTATION HERE.">Slot&lt;ObjectType, DataType&gt;::forward</a>(ObjectType *object_pointer, <span class="keywordtype">void</span>(ObjectType::*object_function_pointer)(DataType u))
500<a name="l00588"></a>00588 {
501<a name="l00589"></a>00589   pm = object_function_pointer;
502<a name="l00590"></a>00590   po = object_pointer;
503<a name="l00591"></a>00591 }
504<a name="l00592"></a>00592
505<a name="l00593"></a>00593 <span class="comment">// template&lt;class ObjectType, class DataType&gt;</span>
506<a name="l00594"></a>00594 <span class="comment">// void Slot&lt;ObjectType, DataType&gt;::exec(DataType signal){</span>
507<a name="l00595"></a>00595 <span class="comment">//   if(pm&amp;&amp;po)</span>
508<a name="l00596"></a>00596 <span class="comment">//     (*po.*pm)(signal);</span>
509<a name="l00597"></a>00597 <span class="comment">// }</span>
510<a name="l00598"></a>00598
511<a name="l00599"></a>00599 <span class="keyword">template</span>&lt;<span class="keyword">class</span> ObjectType, <span class="keyword">class</span> DataType&gt;
512<a name="l00600"></a><a class="code" href="group__protocol.html#g66cdc4cc386c1fa9bb1f3697e6d35c71">00600</a> <span class="keywordtype">void</span> <a class="code" href="group__protocol.html#g66cdc4cc386c1fa9bb1f3697e6d35c71" title="ADD DOCUMENTATION HERE.">Slot&lt;ObjectType, DataType&gt;::operator()</a>(DataType signal)
513<a name="l00601"></a>00601 {
514<a name="l00602"></a>00602   <span class="keywordflow">if</span> (pm&amp;&amp;po)
515<a name="l00603"></a>00603     (*po.*pm)(signal);
516<a name="l00604"></a>00604 }
517<a name="l00605"></a>00605
518<a name="l00607"></a>00607
519<a name="l00608"></a>00608 } <span class="comment">// namespace itpp</span>
520<a name="l00609"></a>00609
521<a name="l00610"></a>00610 <span class="preprocessor">#endif // #ifndef SIGNAL_SLOT_H</span>
522<a name="l00611"></a>00611 <span class="preprocessor"></span>
523</pre></div></div>
524<hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:02:12 2009 for mixpp by&nbsp;
525<a href="http://www.doxygen.org/index.html">
526<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
527</body>
528</html>
Note: See TracBrowser for help on using the browser.