<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>GNU Radio 3.2.2 C++ API: mblock.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">GNU Radio 3.2.2 C++ API</div> </td> </tr> </tbody> </table> </div> </div> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> initNavTree('mblock_8h.html',''); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <h1>mblock.h</h1> </div> </div> <div class="contents"> <a href="mblock_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- c++ -*- */</span> <a name="l00002"></a>00002 <span class="comment">/*</span> <a name="l00003"></a>00003 <span class="comment"> * Copyright 2006,2008 Free Software Foundation, Inc.</span> <a name="l00004"></a>00004 <span class="comment"> * </span> <a name="l00005"></a>00005 <span class="comment"> * This file is part of GNU Radio</span> <a name="l00006"></a>00006 <span class="comment"> * </span> <a name="l00007"></a>00007 <span class="comment"> * GNU Radio is free software; you can redistribute it and/or modify</span> <a name="l00008"></a>00008 <span class="comment"> * it under the terms of the GNU General Public License as published by</span> <a name="l00009"></a>00009 <span class="comment"> * the Free Software Foundation; either version 3, or (at your option)</span> <a name="l00010"></a>00010 <span class="comment"> * any later version.</span> <a name="l00011"></a>00011 <span class="comment"> * </span> <a name="l00012"></a>00012 <span class="comment"> * GNU Radio is distributed in the hope that it will be useful,</span> <a name="l00013"></a>00013 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00014"></a>00014 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00015"></a>00015 <span class="comment"> * GNU General Public License for more details.</span> <a name="l00016"></a>00016 <span class="comment"> * </span> <a name="l00017"></a>00017 <span class="comment"> * You should have received a copy of the GNU General Public License along</span> <a name="l00018"></a>00018 <span class="comment"> * with this program; if not, write to the Free Software Foundation, Inc.,</span> <a name="l00019"></a>00019 <span class="comment"> * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.</span> <a name="l00020"></a>00020 <span class="comment"> */</span> <a name="l00021"></a>00021 <span class="preprocessor">#ifndef INCLUDED_MB_MBLOCK_H</span> <a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define INCLUDED_MB_MBLOCK_H</span> <a name="l00023"></a>00023 <span class="preprocessor"></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <mblock/common.h></span> <a name="l00025"></a>00025 <span class="preprocessor">#include <mblock/message.h></span> <a name="l00026"></a>00026 <span class="preprocessor">#include <mblock/port.h></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <mblock/time.h></span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="comment"></span> <a name="l00030"></a>00030 <span class="comment">/*!</span> <a name="l00031"></a>00031 <span class="comment"> * Abstract class implementing visitor pattern</span> <a name="l00032"></a>00032 <span class="comment"> * \ingroup internal</span> <a name="l00033"></a>00033 <span class="comment"> */</span> <a name="l00034"></a><a class="code" href="classmb__visitor.html">00034</a> <span class="keyword">class </span><a class="code" href="classmb__visitor.html">mb_visitor</a> <a name="l00035"></a>00035 { <a name="l00036"></a>00036 <span class="keyword">public</span>: <a name="l00037"></a>00037 <span class="keyword">virtual</span> <a class="code" href="classmb__visitor.html#a7db9db2a6458ecf661e4c67956e4466a">~mb_visitor</a>(); <a name="l00038"></a>00038 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classmb__visitor.html#a7b724bd07acaa4b500a2a72e02d9a731">operator()</a>(<a class="code" href="classmb__mblock.html" title="Parent class for all message passing blocks.">mb_mblock</a> *mblock) = 0; <a name="l00039"></a>00039 }; <a name="l00040"></a>00040 <a name="l00041"></a>00041 <span class="comment">// ----------------------------------------------------------------------</span> <a name="l00042"></a>00042 <span class="comment"></span> <a name="l00043"></a>00043 <span class="comment">/*!</span> <a name="l00044"></a>00044 <span class="comment"> * \brief Parent class for all message passing blocks</span> <a name="l00045"></a>00045 <span class="comment"> *</span> <a name="l00046"></a>00046 <span class="comment"> * Subclass this to define your mblocks.</span> <a name="l00047"></a>00047 <span class="comment"> */</span> <a name="l00048"></a><a class="code" href="classmb__mblock.html">00048</a> <span class="keyword">class </span><a class="code" href="classmb__mblock.html" title="Parent class for all message passing blocks.">mb_mblock</a> : boost::noncopyable, <a name="l00049"></a>00049 <span class="keyword">public</span> boost::enable_shared_from_this<mb_mblock> <a name="l00050"></a>00050 { <a name="l00051"></a>00051 <span class="keyword">private</span>: <a name="l00052"></a>00052 <a class="code" href="classboost_1_1shared__ptr.html">mb_mblock_impl_sptr</a> d_impl; <span class="comment">// implementation details</span> <a name="l00053"></a>00053 <a name="l00054"></a><a class="code" href="classmb__mblock.html#aad09a593a1585ff8851fe55811bf88fe">00054</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classmb__runtime.html" title="Abstract runtime support for m-blocks.">mb_runtime</a>; <a name="l00055"></a><a class="code" href="classmb__mblock.html#ac7e9d347deac80b4fe67cc2ddf33d707">00055</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classmb__mblock__impl.html" title="The private implementation details of the mblock system.">mb_mblock_impl</a>; <a name="l00056"></a><a class="code" href="classmb__mblock.html#a639baa2ef8eae99412296b2dbbef71a9">00056</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classmb__worker.html" title="Worker thread for thread_per_block runtime.">mb_worker</a>; <a name="l00057"></a>00057 <a name="l00058"></a>00058 <span class="keyword">protected</span>:<span class="comment"></span> <a name="l00059"></a>00059 <span class="comment"> /*!</span> <a name="l00060"></a>00060 <span class="comment"> * \brief mblock constructor.</span> <a name="l00061"></a>00061 <span class="comment"> *</span> <a name="l00062"></a>00062 <span class="comment"> * Initializing all mblocks in the system is a 3 step procedure.</span> <a name="l00063"></a>00063 <span class="comment"> *</span> <a name="l00064"></a>00064 <span class="comment"> * The top level mblock's constructor is run. That constructor </span> <a name="l00065"></a>00065 <span class="comment"> * (a) registers all of its ports using define_port, (b) registers any</span> <a name="l00066"></a>00066 <span class="comment"> * subcomponents it may have via the define_component method, and</span> <a name="l00067"></a>00067 <span class="comment"> * then (c) issues connect calls to wire its subcomponents together.</span> <a name="l00068"></a>00068 <span class="comment"> *</span> <a name="l00069"></a>00069 <span class="comment"> * \param runtime the runtime associated with this mblock</span> <a name="l00070"></a>00070 <span class="comment"> * \param instance_name specify the name of this instance</span> <a name="l00071"></a>00071 <span class="comment"> * (for debugging, NUMA mapping, etc)</span> <a name="l00072"></a>00072 <span class="comment"> * \param user_arg argument passed by user to constructor</span> <a name="l00073"></a>00073 <span class="comment"> * (ignored by the mb_mblock base class)</span> <a name="l00074"></a>00074 <span class="comment"> */</span> <a name="l00075"></a>00075 <a class="code" href="classmb__mblock.html#a83c87a06b23082a4d076eaf8f437434c" title="mblock constructor.">mb_mblock</a>(<a class="code" href="classmb__runtime.html" title="Abstract runtime support for m-blocks.">mb_runtime</a> *runtime, <span class="keyword">const</span> std::string &<a class="code" href="classmb__mblock.html#a62019844e24c535f0803318b1c1d7005" title="Return instance name of this block.">instance_name</a>, <a class="code" href="classboost_1_1shared__ptr.html">pmt_t</a> user_arg); <a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="keyword">public</span>:<span class="comment"></span> <a name="l00078"></a>00078 <span class="comment"> /*!</span> <a name="l00079"></a>00079 <span class="comment"> * \brief Called by the runtime system to execute the initial</span> <a name="l00080"></a>00080 <span class="comment"> * transition of the finite state machine.</span> <a name="l00081"></a>00081 <span class="comment"> *</span> <a name="l00082"></a>00082 <span class="comment"> * This method is called by the runtime after all blocks are</span> <a name="l00083"></a>00083 <span class="comment"> * constructed and before the first message is delivered. Override</span> <a name="l00084"></a>00084 <span class="comment"> * this to initialize your finite state machine.</span> <a name="l00085"></a>00085 <span class="comment"> */</span> <a name="l00086"></a>00086 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmb__mblock.html#acabcfc92899739d510f65755fcebbf87" title="Called by the runtime system to execute the initial transition of the finite state machine...">initial_transition</a>(); <a name="l00087"></a>00087 <a name="l00088"></a>00088 <span class="keyword">protected</span>:<span class="comment"></span> <a name="l00089"></a>00089 <span class="comment"> /*!</span> <a name="l00090"></a>00090 <span class="comment"> * \brief Called by the runtime system when there's a message to handle.</span> <a name="l00091"></a>00091 <span class="comment"> *</span> <a name="l00092"></a>00092 <span class="comment"> * Override this to define your behavior.</span> <a name="l00093"></a>00093 <span class="comment"> *</span> <a name="l00094"></a>00094 <span class="comment"> * Do not issue any potentially blocking calls in this method. This</span> <a name="l00095"></a>00095 <span class="comment"> * includes things such reads or writes on sockets, pipes or slow</span> <a name="l00096"></a>00096 <span class="comment"> * i/o devices.</span> <a name="l00097"></a>00097 <span class="comment"> */</span> <a name="l00098"></a>00098 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmb__mblock.html#a5f96d36f950607b82a12b1b1b8d82a87" title="Called by the runtime system when there&#39;s a message to handle.">handle_message</a>(<a class="code" href="classboost_1_1shared__ptr.html">mb_message_sptr</a> msg); <a name="l00099"></a>00099 <span class="comment"></span> <a name="l00100"></a>00100 <span class="comment"> /*!</span> <a name="l00101"></a>00101 <span class="comment"> * \brief Define a port.</span> <a name="l00102"></a>00102 <span class="comment"> *</span> <a name="l00103"></a>00103 <span class="comment"> * EXTERNAL and RELAY ports are part of our peer interface.</span> <a name="l00104"></a>00104 <span class="comment"> * INTERNAL ports are used to talk to sub-components.</span> <a name="l00105"></a>00105 <span class="comment"> *</span> <a name="l00106"></a>00106 <span class="comment"> * \param port_name The name of the port (must be unique within this mblock).</span> <a name="l00107"></a>00107 <span class="comment"> * \param protocol_class_name The name of the protocol class associated with</span> <a name="l00108"></a>00108 <span class="comment"> * this port. It must already be defined.</span> <a name="l00109"></a>00109 <span class="comment"> * \param conjugated Are the incoming and outgoing message sets swapped?</span> <a name="l00110"></a>00110 <span class="comment"> * \param port_type INTERNAL, EXTERNAL or RELAY.</span> <a name="l00111"></a>00111 <span class="comment"> */</span> <a name="l00112"></a>00112 <a class="code" href="classboost_1_1shared__ptr.html">mb_port_sptr</a> <a name="l00113"></a>00113 <a class="code" href="classmb__mblock.html#a47b1aa472fa25822b169a1a780706cc9" title="Define a port.">define_port</a>(<span class="keyword">const</span> std::string &port_name, <a name="l00114"></a>00114 <span class="keyword">const</span> std::string &protocol_class_name, <a name="l00115"></a>00115 <span class="keywordtype">bool</span> conjugated, <a name="l00116"></a>00116 <a class="code" href="classmb__port.html#ab7f3f63c496d0de66461f09320bbaaa7" title="port classification">mb_port::port_type_t</a> port_type); <a name="l00117"></a>00117 <span class="comment"></span> <a name="l00118"></a>00118 <span class="comment"> /*!</span> <a name="l00119"></a>00119 <span class="comment"> * \brief Define a subcomponent by name.</span> <a name="l00120"></a>00120 <span class="comment"> *</span> <a name="l00121"></a>00121 <span class="comment"> * Called within the constructor to tell the system the</span> <a name="l00122"></a>00122 <span class="comment"> * names and identities of our sub-component mblocks.</span> <a name="l00123"></a>00123 <span class="comment"> *</span> <a name="l00124"></a>00124 <span class="comment"> * \param component_name The name of the sub-component (must be unique with this mblock).</span> <a name="l00125"></a>00125 <span class="comment"> * \param class_name The class of the instance that is to be created.</span> <a name="l00126"></a>00126 <span class="comment"> * \param user_arg The argument to pass to the constructor of the component.</span> <a name="l00127"></a>00127 <span class="comment"> */</span> <a name="l00128"></a>00128 <span class="keywordtype">void</span> <a name="l00129"></a>00129 <a class="code" href="classmb__mblock.html#ac560e9e981bc13874c57fe753870e3a1" title="Define a subcomponent by name.">define_component</a>(<span class="keyword">const</span> std::string &component_name, <a name="l00130"></a>00130 <span class="keyword">const</span> std::string &<a class="code" href="classmb__mblock.html#a1344b9a214c84b1e968f77ee098046ef" title="Return the class name of this block.">class_name</a>, <a name="l00131"></a>00131 <a class="code" href="classboost_1_1shared__ptr.html">pmt_t</a> user_arg = PMT_NIL); <a name="l00132"></a>00132 <span class="comment"></span> <a name="l00133"></a>00133 <span class="comment"> /*!</span> <a name="l00134"></a>00134 <span class="comment"> * \brief connect endpoint_1 to endpoint_2</span> <a name="l00135"></a>00135 <span class="comment"> *</span> <a name="l00136"></a>00136 <span class="comment"> * \param comp_name1 component on one end of the connection</span> <a name="l00137"></a>00137 <span class="comment"> * \param port_name1 the name of the port on comp1</span> <a name="l00138"></a>00138 <span class="comment"> * \param comp_name2 component on the other end of the connection</span> <a name="l00139"></a>00139 <span class="comment"> * \param port_name2 the name of the port on comp2</span> <a name="l00140"></a>00140 <span class="comment"> *</span> <a name="l00141"></a>00141 <span class="comment"> * An endpoint is specified by the component's local name (given as</span> <a name="l00142"></a>00142 <span class="comment"> * component_name in the call to register_component) and the name of</span> <a name="l00143"></a>00143 <span class="comment"> * the port on that component.</span> <a name="l00144"></a>00144 <span class="comment"> *</span> <a name="l00145"></a>00145 <span class="comment"> * To connect an internal or relay port, use "self" as the component name.</span> <a name="l00146"></a>00146 <span class="comment"> */</span> <a name="l00147"></a>00147 <span class="keywordtype">void</span> <a name="l00148"></a>00148 <a class="code" href="classmb__mblock.html#a0800477701715dd006d87f3d807f55c1" title="connect endpoint_1 to endpoint_2">connect</a>(<span class="keyword">const</span> std::string &comp_name1, <span class="keyword">const</span> std::string &port_name1, <a name="l00149"></a>00149 <span class="keyword">const</span> std::string &comp_name2, <span class="keyword">const</span> std::string &port_name2); <a name="l00150"></a>00150 <span class="comment"></span> <a name="l00151"></a>00151 <span class="comment"> /*!</span> <a name="l00152"></a>00152 <span class="comment"> * \brief disconnect endpoint_1 from endpoint_2</span> <a name="l00153"></a>00153 <span class="comment"> *</span> <a name="l00154"></a>00154 <span class="comment"> * \param comp_name1 component on one end of the connection</span> <a name="l00155"></a>00155 <span class="comment"> * \param port_name1 the name of the port on comp1</span> <a name="l00156"></a>00156 <span class="comment"> * \param comp_name2 component on the other end of the connection</span> <a name="l00157"></a>00157 <span class="comment"> * \param port_name2 the name of the port on comp2</span> <a name="l00158"></a>00158 <span class="comment"> *</span> <a name="l00159"></a>00159 <span class="comment"> * An endpoint is specified by the component's local name (given as</span> <a name="l00160"></a>00160 <span class="comment"> * component_name in the call to register_component) and the name of</span> <a name="l00161"></a>00161 <span class="comment"> * the port on that component.</span> <a name="l00162"></a>00162 <span class="comment"> *</span> <a name="l00163"></a>00163 <span class="comment"> * To disconnect an internal or relay port, use "self" as the component name.</span> <a name="l00164"></a>00164 <span class="comment"> */</span> <a name="l00165"></a>00165 <span class="keywordtype">void</span> <a name="l00166"></a>00166 <a class="code" href="classmb__mblock.html#a500f577145bd9a5afc33203ba0a61cd6" title="disconnect endpoint_1 from endpoint_2">disconnect</a>(<span class="keyword">const</span> std::string &comp_name1, <span class="keyword">const</span> std::string &port_name1, <a name="l00167"></a>00167 <span class="keyword">const</span> std::string &comp_name2, <span class="keyword">const</span> std::string &port_name2); <a name="l00168"></a>00168 <span class="comment"></span> <a name="l00169"></a>00169 <span class="comment"> /*!</span> <a name="l00170"></a>00170 <span class="comment"> * \brief disconnect all connections to specified component</span> <a name="l00171"></a>00171 <span class="comment"> * \param component_name component to disconnect</span> <a name="l00172"></a>00172 <span class="comment"> */</span> <a name="l00173"></a>00173 <span class="keywordtype">void</span> <a name="l00174"></a>00174 <a class="code" href="classmb__mblock.html#a2f4ca20b58c89386d6f6ac2c276646d0" title="disconnect all connections to specified component">disconnect_component</a>(<span class="keyword">const</span> std::string &component_name); <a name="l00175"></a>00175 <span class="comment"></span> <a name="l00176"></a>00176 <span class="comment"> /*!</span> <a name="l00177"></a>00177 <span class="comment"> * \brief disconnect all connections to all components</span> <a name="l00178"></a>00178 <span class="comment"> */</span> <a name="l00179"></a>00179 <span class="keywordtype">void</span> <a name="l00180"></a>00180 <a class="code" href="classmb__mblock.html#afbfe3e2601f9a92823690ce0a013ef9d" title="disconnect all connections to all components">disconnect_all</a>(); <a name="l00181"></a>00181 <span class="comment"></span> <a name="l00182"></a>00182 <span class="comment"> /*!</span> <a name="l00183"></a>00183 <span class="comment"> * \brief Return number of connections (QA mostly)</span> <a name="l00184"></a>00184 <span class="comment"> */</span> <a name="l00185"></a>00185 <span class="keywordtype">int</span> <a name="l00186"></a>00186 <a class="code" href="classmb__mblock.html#aeb61577b8eab6672f87cf66a88814e26" title="Return number of connections (QA mostly)">nconnections</a>() <span class="keyword">const</span>; <a name="l00187"></a>00187 <span class="comment"></span> <a name="l00188"></a>00188 <span class="comment"> //! Set the class name</span> <a name="l00189"></a>00189 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classmb__mblock.html#a10653b3e3b5f39272d028f54b96878ca" title="Set the class name.">set_class_name</a>(<span class="keyword">const</span> std::string &name); <a name="l00190"></a>00190 <span class="comment"></span> <a name="l00191"></a>00191 <span class="comment"> /*!</span> <a name="l00192"></a>00192 <span class="comment"> * \brief Tell runtime that we are done.</span> <a name="l00193"></a>00193 <span class="comment"> *</span> <a name="l00194"></a>00194 <span class="comment"> * This method does not return.</span> <a name="l00195"></a>00195 <span class="comment"> */</span> <a name="l00196"></a>00196 <span class="keywordtype">void</span> <a class="code" href="classmb__mblock.html#a6be918a924c59e55996d9e9ce1e6b4ec" title="Tell runtime that we are done.">exit</a>(); <a name="l00197"></a>00197 <span class="comment"></span> <a name="l00198"></a>00198 <span class="comment"> /*!</span> <a name="l00199"></a>00199 <span class="comment"> * \brief Ask runtime to execute the shutdown procedure for all blocks.</span> <a name="l00200"></a>00200 <span class="comment"> * </span> <a name="l00201"></a>00201 <span class="comment"> * \param result sets value of \p result output argument of runtime->run(...)</span> <a name="l00202"></a>00202 <span class="comment"> *</span> <a name="l00203"></a>00203 <span class="comment"> * The runtime first sends a maximum priority %shutdown message to</span> <a name="l00204"></a>00204 <span class="comment"> * all blocks. All blocks should handle the %shutdown message,</span> <a name="l00205"></a>00205 <span class="comment"> * perform whatever clean up is required, and call this->exit();</span> <a name="l00206"></a>00206 <span class="comment"> *</span> <a name="l00207"></a>00207 <span class="comment"> * After a period of time (~100ms), any blocks which haven't yet</span> <a name="l00208"></a>00208 <span class="comment"> * called this->exit() are sent a maximum priority %halt message.</span> <a name="l00209"></a>00209 <span class="comment"> * %halt is detected in main_loop, and this->exit() is called.</span> <a name="l00210"></a>00210 <span class="comment"> *</span> <a name="l00211"></a>00211 <span class="comment"> * After an additional period of time (~100ms), any blocks which</span> <a name="l00212"></a>00212 <span class="comment"> * still haven't yet called this->exit() are sent a SIG<FOO> (TBD)</span> <a name="l00213"></a>00213 <span class="comment"> * signal, which will blow them out of any blocking system calls and</span> <a name="l00214"></a>00214 <span class="comment"> * raise an mbe_terminate exception. The default top-level</span> <a name="l00215"></a>00215 <span class="comment"> * runtime-provided exception handler will call this->exit() to</span> <a name="l00216"></a>00216 <span class="comment"> * finish the process.</span> <a name="l00217"></a>00217 <span class="comment"> *</span> <a name="l00218"></a>00218 <span class="comment"> * runtime->run(...) returns when all blocks have called exit.</span> <a name="l00219"></a>00219 <span class="comment"> */</span> <a name="l00220"></a>00220 <span class="keywordtype">void</span> <a class="code" href="classmb__mblock.html#a1d9ccf70a91a04e23580408053f2fa2c" title="Ask runtime to execute the shutdown procedure for all blocks.">shutdown_all</a>(<a class="code" href="classboost_1_1shared__ptr.html">pmt_t</a> result); <a name="l00221"></a>00221 <span class="comment"></span> <a name="l00222"></a>00222 <span class="comment"> /*!</span> <a name="l00223"></a>00223 <span class="comment"> * \brief main event dispatching loop</span> <a name="l00224"></a>00224 <span class="comment"> *</span> <a name="l00225"></a>00225 <span class="comment"> * Although it is possible to override this, the default implementation</span> <a name="l00226"></a>00226 <span class="comment"> * should work for virtually all cases.</span> <a name="l00227"></a>00227 <span class="comment"> */</span> <a name="l00228"></a>00228 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmb__mblock.html#aa9d454e5c35e31613d44dd75505064a3" title="main event dispatching loop">main_loop</a>(); <a name="l00229"></a>00229 <a name="l00230"></a>00230 <span class="keyword">public</span>: <a name="l00231"></a>00231 <span class="keyword">virtual</span> <a class="code" href="classmb__mblock.html#a6f2b3e251032173579d5138b72290abc">~mb_mblock</a>(); <a name="l00232"></a>00232 <span class="comment"></span> <a name="l00233"></a>00233 <span class="comment"> //! Return instance name of this block</span> <a name="l00234"></a>00234 <span class="comment"></span> std::string <a class="code" href="classmb__mblock.html#a62019844e24c535f0803318b1c1d7005" title="Return instance name of this block.">instance_name</a>() <span class="keyword">const</span>; <a name="l00235"></a>00235 <span class="comment"></span> <a name="l00236"></a>00236 <span class="comment"> //! Return the class name of this block</span> <a name="l00237"></a>00237 <span class="comment"></span> std::string <a class="code" href="classmb__mblock.html#a1344b9a214c84b1e968f77ee098046ef" title="Return the class name of this block.">class_name</a>() <span class="keyword">const</span>; <a name="l00238"></a>00238 <span class="comment"></span> <a name="l00239"></a>00239 <span class="comment"> //! Set the instance name of this block.</span> <a name="l00240"></a>00240 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classmb__mblock.html#affe51c6b003e08eb672934ff687daaca" title="Set the instance name of this block.">set_instance_name</a>(<span class="keyword">const</span> std::string &name); <a name="l00241"></a>00241 <span class="comment"></span> <a name="l00242"></a>00242 <span class="comment"> //! Return the parent of this mblock, or 0 if we're the top-level block.</span> <a name="l00243"></a>00243 <span class="comment"></span> <a class="code" href="classmb__mblock.html" title="Parent class for all message passing blocks.">mb_mblock</a> *<a class="code" href="classmb__mblock.html#aee14050f3be0aaf4c844702b0e6e294c" title="Return the parent of this mblock, or 0 if we&#39;re the top-level block.">parent</a>() <span class="keyword">const</span>; <a name="l00244"></a>00244 <span class="comment"></span> <a name="l00245"></a>00245 <span class="comment"> /*!</span> <a name="l00246"></a>00246 <span class="comment"> * \brief Schedule a "one shot" timeout.</span> <a name="l00247"></a>00247 <span class="comment"> *</span> <a name="l00248"></a>00248 <span class="comment"> * \param abs_time the absolute time at which the timeout should fire</span> <a name="l00249"></a>00249 <span class="comment"> * \param user_data the data passed in the %timeout message.</span> <a name="l00250"></a>00250 <span class="comment"> *</span> <a name="l00251"></a>00251 <span class="comment"> * When the timeout fires, a message will be sent to the mblock.</span> <a name="l00252"></a>00252 <span class="comment"> *</span> <a name="l00253"></a>00253 <span class="comment"> * The message will have port_id = %sys-port, signal = %timeout,</span> <a name="l00254"></a>00254 <span class="comment"> * data = user_data, metadata = the handle returned from</span> <a name="l00255"></a>00255 <span class="comment"> * schedule_one_shot_timeout, pri = MB_PRI_BEST.</span> <a name="l00256"></a>00256 <span class="comment"> *</span> <a name="l00257"></a>00257 <span class="comment"> * \returns a handle that can be used in cancel_timeout, and is passed</span> <a name="l00258"></a>00258 <span class="comment"> * as the metadata field of the generated %timeout message.</span> <a name="l00259"></a>00259 <span class="comment"> *</span> <a name="l00260"></a>00260 <span class="comment"> * To cancel a pending timeout, call cancel_timeout.</span> <a name="l00261"></a>00261 <span class="comment"> */</span> <a name="l00262"></a>00262 <a class="code" href="classboost_1_1shared__ptr.html">pmt_t</a> <a name="l00263"></a>00263 <a class="code" href="classmb__mblock.html#a5a39284aefb6c9216968bc1e057a504e" title="Schedule a &quot;one shot&quot; timeout.">schedule_one_shot_timeout</a>(<span class="keyword">const</span> <a class="code" href="structomni__time.html">mb_time</a> &abs_time, <a class="code" href="classboost_1_1shared__ptr.html">pmt_t</a> user_data); <a name="l00264"></a>00264 <span class="comment"></span> <a name="l00265"></a>00265 <span class="comment"> /*!</span> <a name="l00266"></a>00266 <span class="comment"> * \brief Schedule a periodic timeout.</span> <a name="l00267"></a>00267 <span class="comment"> *</span> <a name="l00268"></a>00268 <span class="comment"> * \param first_abs_time The absolute time at which the first timeout should fire.</span> <a name="l00269"></a>00269 <span class="comment"> * \param delta_time The relative delay between the first and successive timeouts.</span> <a name="l00270"></a>00270 <span class="comment"> * \param user_data the data passed in the %timeout message.</span> <a name="l00271"></a>00271 <span class="comment"> *</span> <a name="l00272"></a>00272 <span class="comment"> * When the timeout fires, a message will be sent to the mblock, and a</span> <a name="l00273"></a>00273 <span class="comment"> * new timeout will be scheduled for previous absolute time + delta_time.</span> <a name="l00274"></a>00274 <span class="comment"> *</span> <a name="l00275"></a>00275 <span class="comment"> * The message will have port_id = %sys-port, signal = %timeout,</span> <a name="l00276"></a>00276 <span class="comment"> * data = user_data, metadata = the handle returned from</span> <a name="l00277"></a>00277 <span class="comment"> * schedule_one_shot_timeout, pri = MB_PRI_BEST.</span> <a name="l00278"></a>00278 <span class="comment"> *</span> <a name="l00279"></a>00279 <span class="comment"> * \returns a handle that can be used in cancel_timeout, and is passed</span> <a name="l00280"></a>00280 <span class="comment"> * as the metadata field of the generated %timeout message.</span> <a name="l00281"></a>00281 <span class="comment"> *</span> <a name="l00282"></a>00282 <span class="comment"> * To cancel a pending timeout, call cancel_timeout.</span> <a name="l00283"></a>00283 <span class="comment"> */</span> <a name="l00284"></a>00284 <a class="code" href="classboost_1_1shared__ptr.html">pmt_t</a> <a name="l00285"></a>00285 <a class="code" href="classmb__mblock.html#a2a025f508180403844eb3a4e6a122fc9" title="Schedule a periodic timeout.">schedule_periodic_timeout</a>(<span class="keyword">const</span> <a class="code" href="structomni__time.html">mb_time</a> &first_abs_time, <a name="l00286"></a>00286 <span class="keyword">const</span> <a class="code" href="structomni__time.html">mb_time</a> &delta_time, <a name="l00287"></a>00287 <a class="code" href="classboost_1_1shared__ptr.html">pmt_t</a> user_data); <a name="l00288"></a>00288 <span class="comment"></span> <a name="l00289"></a>00289 <span class="comment"> /*!</span> <a name="l00290"></a>00290 <span class="comment"> * \brief Attempt to cancel a pending timeout.</span> <a name="l00291"></a>00291 <span class="comment"> *</span> <a name="l00292"></a>00292 <span class="comment"> * Note that this only stops a future timeout from firing. It is</span> <a name="l00293"></a>00293 <span class="comment"> * possible that a timeout may have already fired and enqueued a</span> <a name="l00294"></a>00294 <span class="comment"> * %timeout message, but that that message has not yet been seen by</span> <a name="l00295"></a>00295 <span class="comment"> * handle_message.</span> <a name="l00296"></a>00296 <span class="comment"> *</span> <a name="l00297"></a>00297 <span class="comment"> * \param handle returned from schedule_one_shot_timeout or schedule_periodic_timeout.</span> <a name="l00298"></a>00298 <span class="comment"> */</span> <a name="l00299"></a>00299 <span class="keywordtype">void</span> <a class="code" href="classmb__mblock.html#a70031b0b32a186763187892987f1798e" title="Attempt to cancel a pending timeout.">cancel_timeout</a>(<a class="code" href="classboost_1_1shared__ptr.html">pmt_t</a> handle); <a name="l00300"></a>00300 <span class="comment"></span> <a name="l00301"></a>00301 <span class="comment"> /*!</span> <a name="l00302"></a>00302 <span class="comment"> * \brief Perform a pre-order depth-first traversal of the hierarchy.</span> <a name="l00303"></a>00303 <span class="comment"> *</span> <a name="l00304"></a>00304 <span class="comment"> * The traversal stops and returns false if any call to visitor returns false.</span> <a name="l00305"></a>00305 <span class="comment"> */</span> <a name="l00306"></a>00306 <span class="keywordtype">bool</span> <a name="l00307"></a>00307 <a class="code" href="classmb__mblock.html#ad6b767c539ecd52fd843e01638c75379" title="Perform a pre-order depth-first traversal of the hierarchy.">walk_tree</a>(<a class="code" href="classmb__visitor.html">mb_visitor</a> *visitor); <a name="l00308"></a>00308 <a name="l00309"></a>00309 <span class="comment"></span> <a name="l00310"></a>00310 <span class="comment"> //! \internal</span> <a name="l00311"></a>00311 <span class="comment"></span> <span class="comment">// internal use only</span> <a name="l00312"></a>00312 <a class="code" href="classboost_1_1shared__ptr.html">mb_mblock_impl_sptr</a> <a name="l00313"></a><a class="code" href="classmb__mblock.html#a6db8b3246c9d2d862bd20876ffe9a16d">00313</a> <a class="code" href="classmb__mblock.html#a6db8b3246c9d2d862bd20876ffe9a16d">impl</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d_impl; } <a name="l00314"></a>00314 <a name="l00315"></a>00315 }; <a name="l00316"></a>00316 <a name="l00317"></a>00317 <a name="l00318"></a>00318 <span class="preprocessor">#endif </span><span class="comment">/* INCLUDED_MB_MBLOCK_H */</span> </pre></div></div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="mblock_8h.html">mblock.h</a> </li> <li class="footer">Generated on Thu Feb 17 2011 for GNU Radio 3.2.2 C++ API by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li> </ul> </div> </body> </html>