|
Boost : |
From: Lubomir Bourdev (lbourdev_at_[hidden])
Date: 2006-10-06 11:28:32
Andy Little wrote:
>"Lubomir Bourdev" <lbourdev_at_[hidden]> wrote:
>> Any large library has some concepts that could stand on their own or be
>> reused in other contexts. Sometimes it makes sense to do so, but
>> sometimes (as I believe is the case with GIL) those other contexts are
>> quite nebulous and doing so would be somewhat extreme.
>
>? "Those other contexts are quite nebulous"? You lost me..
Again, lets take your example of extracting the 2D-navigation aspect of GIL (what you call Display Matrix) into a stand-alone library that you could use for purposes other than imaging. Your example is manipulating text characters in a rectangular grid.
I claim this is a nebulous example, because the moment you start getting down to business of writing this text-processing-display system, you will realize that the above DisplayMatrix is the wrong abstraction for your job. For one thing, most fonts have variable width, which means you have different number of characters per line. It is hard to accomodate the vertical random-access navigation. There is no longer a global "width" parameter, but width per line. You need a different model of a different concept.
Let's say you constrain yourself to fixed width fonts and rectangular grid (a severe constraint in my opinion). Still, the set of operations GIL provides make no sense for you. The operations you need for text manipulation are very much one-dimensional (insert/delete characters). It would be inefficient to keep your characters in a 2D grid. Navigating vertically has very little use. Operations meaningful for images, like copying a rectangular subgrid or displaying it 90-degree rotated make no sense for you.
Finally, if you want to constrain yourself to rectangular grid of characters and you feel those image-like operations could be meaningful for you, then you can interpret what you have as an 8-bit grayscale image (gil::gray8_view_t) whose pixel channel is the ASCII code of your character.
Lubomir
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk