From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-10-19 13:05:16
On 10/19/07, Marco <mrcekets_at_[hidden]> wrote:
> On Fri, 19 Oct 2007 17:00:35 +0200, Miguel Tadeu <m_tadeu_at_[hidden]> wrote:
> > Ok, a little bit of explanation...
> > Let's follow a real life example that occured to me a while ago. I wrote
> > a
> > piece of software that received a buffer through rs232. I had to
> > interpret
> > that buffer and, depending on the opcode I had to call the right
> > function.
> > Lest's just say there were about 100 different opcodes. Their destination
> > were to several different objects.
> > Solution at that time:
> > - read opcode from the buffer
> > - creat a big switch/case to call the right object::function
> > Switch/case are apopriate if the opcode is not a string, in which case
> > you'll just have 100 if/else if clauses.
> > My solution:
> > - [begining]register each function in a container
> > - [on each communication]pack each parameter in a vector<any>
> > - call get the function by it's opcode(number/string/whatever) and call
> > it
> > Miguel Tadeu
> You should give a look at the dispatcher library
> implemented by Dean Michael Berris.
> I'm not sure that you've the same goals,
> but maybe you could collabarate and merging your efforts. :-)
This definitely seems like we have the same goals. And the described
usage scenario is also similar to what drove me to write the
dispatcher library in the first place -- only the earlier motivation
was CIMD2 processing.
Now though I'm actually using it as a sort-of Front Controller for an
HTTP based service I'm working on -- where it holds implementations of
the handlers dispatched according to the resource being requested
through a URI.
The latest code can be gotten from SVN at Sourceforge:
-- Dean Michael C. Berris Software Engineer, Friendster, Inc. [http://cplusplus-soup.blogspot.com/] [mikhailberis_at_[hidden]] [+63 928 7291459] [+1 408 4049523]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk