Hola,<br><br>Leyendo un poco de codigo me he encontrado con un template que no consigo entender, a ver si podeis echarme una mano:<br><span style="font-family: "Courier New";" lang="EN-GB"><</span><span style="font-family: "Courier New";" lang="EN-GB">pre></span><b><span style="font-family: "Courier New";" lang="EN-GB"><br>
<</span></b><span style="font-family: "Courier New";" lang="EN-GB">code><br></span><b><span style="font-family: "Courier New";" lang="EN-GB">template< class</span></b><span style="font-family: "Courier New";" lang="EN-GB"> T <b>></b></span>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB">class</span></b><span style="font-family: "Courier New";" lang="EN-GB"> MessageMappingOscPacketListener <b>: public</b> OscPacketListener<b>{</b></span></p>


<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB">public:</span></b></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span><b>typedef</b> <b>void</b> <b>(</b>T<b>::*</b>function_type<b>)(const
</b>osc<b>::</b>ReceivedMessage<b>&, const</b> IpEndpointName<b>&);</b></span></p>

<p class="MsoNormal" style="margin: 0cm -2cm 0.0001pt 0cm;"><span style="font-family: "Courier New";" lang="EN-GB"> </span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB">protected:</span></b></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span>void</span></b><span style="font-family: "Courier New";" lang="EN-GB"> RegisterMessageFunction<b>( const char *</b>addressPattern<b>,</b>
function_type f <b>)</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span></span></b><b><span style="font-family: "Courier New";">{</span></b></p>


<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">        </span>functions_.insert<b>( </b>std::make_pair<b>(</b>
addressPattern<b>,</b> f <b>) );</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span>}</span></b></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"> </span></b></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span>virtual void</span></b><span style="font-family: "Courier New";" lang="EN-GB"> ProcessMessage<b>( const</b> osc<b>::</b>ReceivedMessage<b>&</b> m, <b>const</b>
IpEndpointName<b>&</b> remoteEndpoint <b>)</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span><b>{</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">        </span><b>typename </b>function_map_type<b>::</b>iterator
i <b>=</b> functions_<b>.</b>find<b>( </b>m.AddressPattern<b>() );</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">        </span><b>if(</b> i <b>!=</b> functions_.end<b>()
)</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">            </span><b>(dynamic_cast<</b>T<b>*>(this)->*(</b>i<b>-></b>second<b>))(</b>
m<b>,</b> remoteEndpoint <b>);</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span>}</span></b></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB">private:</span></b></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span>struct</span></b><span style="font-family: "Courier New";" lang="EN-GB"> cstr_compare<b>{</b></span></p>


<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span><span style="">        </span>bool
operator()( const char *</span></b><span style="font-family: "Courier New";" lang="EN-GB">lhs<b>, const char *</b>rhs <b>)
const</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">            </span>{ return </span></b><span style="font-family: "Courier New";" lang="EN-GB">strcmp<b>(</b> lhs<b>,</b> rhs <b>) <</b> 0<b>; }</b></span></p>


<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span>};</span></b></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"> </span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span><b>typedef </b>std<b>::</b>map<b><const
char*,</b> function_type<b>,</b> cstr_compare<b>></b> function_map_type<b>;</b></span></p>

<p class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New";" lang="EN-GB"><span style="">    </span></span><span style="font-family: "Courier New";">function_map_type functions_<b>;</b></span></p>


<p class="MsoNormal"><b><span style="font-family: "Courier New";">};</span></b></p><p class="MsoNormal"></code></p><p class="MsoNormal"></pre></p>Entiendo que se define una clase <span style="font-family: "Courier New";" lang="EN-GB">MessageMappingOscPacketListener </span>que deriva de <span style="font-family: "Courier New";" lang="EN-GB">OscPacketListener y que usa una clase generica T.<br>
<br>Define como publico un tipo: function_type que es una operacion de la clase T que devuelve void y acepta como parametros 2 referencias constantes, (</span><span style="font-family: "Courier New";" lang="EN-GB">osc<b>::</b>ReceivedMessage<b> y </b>IpEndpointName<b>). (No se como poner esto en UML)<br>
<br></b>Define como protegido una funcion </span><span style="font-family: "Courier New";" lang="EN-GB"><b>UML</b> -> #RegisterMessageFunction(char*, function_type) : void <br>y otra: <b>UML </b>-><i> #</i></span><span style="font-family: "Courier New";" lang="EN-GB"><i>ProcessMessage<b>( </b>osc<b>::</b>ReceivedMessage<b>&</b> , <b></b>IpEndpointName<b>&</b> <b>):</b> void<br>
<br></i>Define como privado un struct cstr_compare cuyo unico miembro es una funcion que sobrecarga el operador () para aceptar dos punteros a char constantes y devolver un bool: (Porque hace esto? como se usaria ese struct?)<br>
<br>Y luego define otro tipo que ya no tengo ni idea de que hace.<br><br>A ver si podeis echar un poco de luz, gracias.<br><br>pd: He intentado formatear el codigo lo mejor posible, si sabeis alguna manera de formatearlo para facilitar su lectura estaria encantado de usarla.<br>
<b></b></span><p class="MsoNormal"><br></p><p class="MsoNormal"><br><b><span style="font-family: "Courier New";"></span></b></p>

<br>