|
Boost : |
From: Marco (mrcekets_at_[hidden])
Date: 2007-10-19 12:50:16
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. :-)
Regards,
Marco
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk