dispatch automation
<p>I myself am not exactly sure what I am asking for here, so please bear with me for a second.</p>

<p>Basically, I have an application that has to, amongst other things, be able to process commands that are received from some external source, let's say a socket.</p>

<p>Every command uses two data structures specific to this command - one structure holds a set of arguments relevant to the processing of this command, the other one receives some resulting data.</p>

<p>Naturally, data transfer handler class knows nothing about which command uses which structures, so the first thing that is invoked after command is received looks like this:</p>

<pre><code>CSocketHandler::ReceiveCommand(int CommandCode, const TBuffer&amp; Args, TBuffer&amp; Result);
</code></pre>

<p>And the last one looks like this:</p>

<pre><code>CClassBar::ProcessCommandFoo(const TFooArgs&amp; Args, TFooResult&amp; Result);
</code></pre>

<p>Now, all that's missing is the part that converts TBuffer to TFooArgs, invokes a correct method, then converts TFooResult back to TBuffer (A conversion is trivial).</p>

<p>The amount of different handler classes and commands promises to be quite large, so what I am looking at here is a method three miles long that does the same thing to different data types then calls different functions over and over again.</p>

<p>So my question - is it possible to automate this tedious and error prone task? Preferably to the point where just defining a new message handling method would be enough, but I am willing to compromise.</p>
