<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
Attached 2 small patches, one for more constness in the backend and the
second one to remove some duplicate code in the jackbackend.<br>
<br>
Regarding these duplicates, most of them stem from the fact the
operations on in/out (port, file, buffer, xyz) are almost the same (for
example: AudioSource/Sink only differ in the constness of the
float/double buffer (which is a duplicate in itself)).<br>
<br>
However, I am not quite clear on how to approach this. <br>
<br>
One solution could be to use more STL:<br>
<tt><small><br>
template<typename T> struct store : std::unary_function<T,
void><br>
{<br>
  JackConnections& store_;<br>
<br>
  store(C& store) : store_(s) <br>
  {<br>
  }<br>
<br>
  void operator()(T const& t)<br>
  {<br>
    JackConnection connection;<br>
    connection.processingName = t.PortName();<br>
    connection.outsideConnections = jack_port_get_connections (
t.jackPort );<br>
    store_.push_back(</small></tt><tt><small>connection</small></tt><tt><small>)<br>
  }<br>
};<br>
<br>
void JACKNetworkPlayer::StoreConnections()<br>
{<br>
    std::for_each(_sourceJackBindings.begin(),
_sourceJackBindings.end(),
store<SourceJackBinding>(_incomingJackConnections));<br>
    std::for_each(_sinkJackBindings.begin(), _sinkJackBindings.end(), </small></tt><tt><small>store<SinkJackBinding></small></tt><tt><small>(_outgoingJackConnections));<br>
}</small></tt><br>
<br>
But this adds the overhead of having lost of function objects, although
the code now is back to one definition ...<br>
<br>
Another to leave the loop (possibly using a (boost) foreach), but to
factor out the code to one place:<br>
<tt><small><br>
template<typename T>void copy(T const& t)<br>
{<br>
    jack_port_unregister(_jackClient, t.jackPort))<br>
}<br>
 <br>
void JACKNetworkPlayer::UnRegisterPorts()<br>
{<br>
    foreach(sinkJackBinding, </small></tt><tt><small>SinkJackBindings)</small></tt><br>
<tt><small>          copy<SinkJackBinding>(</small></tt><tt><small>sinkJackBinding);</small></tt><br>
<br>
Lastly the argument could be made that as Clam places the emphasis on
In/Out being of different types the proliferation of code should be
accepted - but this kind of violates the 'dont repeat yourself' adagium.<br>
<br>
What would be preferable?<br>
<br>
Dirk<br>
<br>
<br>
<br>
</body>
</html>