Boost logo

Boost :

Subject: Re: [boost] [flyweight] key value with objects not constructible from a key
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2008-11-12 16:09:16


Michael Marcin <mike.marcin <at> gmail.com> writes:

>
> joaquin <at> tid.es wrote:
> > Michael Marcin escribió:
[...]
> Let's say my key is a filename and my value is a texture.
>
> If texture has to be constructible from key then texture has to have
> direct access to file and image loading functionality. I can't pass any
> information other than the key to the construction site without
> resorting to singletons.

OK, please help me make out a more complete picture of
the use case you've got in mind. Imagine you have a flyweight
type that behaves the way you need/want, let's call it
texture_flyweight. The associated key is std::string and the
associated value is texture. Now, you write the following:

  texture_flyweight fw("wood.texture");

If an equivalent flyweight already exists then there is no
problem, fw will be assigned the same texture object, this is
how Boost.Flyweight currently works. Now, imagine that
no equivalent texture exists, and yet you can't construct
a texture object from "wood.texture" alone. How would you
have then the above statement behave?

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk