N
notme
Hi, I'm using something similar to command pattern. I have an abstract base
class Command,
with some methods, and then some implementations: CmdOpen, CmdRead,
CmdClose, etc.
It works ok, but now I need to chain commands. The most obvious approach is
adding
a chain function, so if I need to do this sequence: open, read, close, I'd
do:
open->chain(read);
read->chain(close);
also possibly some class needs to set some parameter, so in fact this turns
to be:
read->setbuffer(buf);
open->chain(read);
read->chain(close);
This would create a linked list of commands. What I'm wondering is if there
something more
readable than this, basically some way to make it look like:
open [op] read [op] close; where [op] would denote some operator or
whatever.
Thanks!
class Command,
with some methods, and then some implementations: CmdOpen, CmdRead,
CmdClose, etc.
It works ok, but now I need to chain commands. The most obvious approach is
adding
a chain function, so if I need to do this sequence: open, read, close, I'd
do:
open->chain(read);
read->chain(close);
also possibly some class needs to set some parameter, so in fact this turns
to be:
read->setbuffer(buf);
open->chain(read);
read->chain(close);
This would create a linked list of commands. What I'm wondering is if there
something more
readable than this, basically some way to make it look like:
open [op] read [op] close; where [op] would denote some operator or
whatever.
Thanks!