Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2006-07-17 17:32:02


----- Mensaje original -----
De: Matias Capeletto <matias.capeletto_at_[hidden]>
Fecha: Lunes, Julio 17, 2006 5:15 pm
Asunto: Re: [boost] [flyweight] new draft uploaded at vault

> > * Do you deem the lib worth eventually proposing to Boost?
>
> Yes!

Thank you :)

>
> > * Do you like the usage interface?
>
> Very much...
> However, as i will like it even more if the principal class name were
> easier to write, I am not a native English speaker and the ht, th
> kills me :)
> What about something like Boost.Flyweight / boost::flyweight / fw ?
> The code is cleaner this way.

I don't think such a short name as "fw" is really acceptable,
but well maybe some othe readers have their opinion about this...

> > * Improvements/extensions?
>
> I think that one nice thing to have is the ability to interact
> directly with the factories.
> I would like to be able, at least for debugging purpose but I have
> in mind some
> other scenarios, to write something like:
>
> struct names {};
>
> struct user
> {
> flyweight< std::string, tag<names>, set_factory > name;
> int age;
> };
>
> flyweight_factory< names >::instance().insert( "Joaquin" );
> flyweight_factory< names >::instance().insert( "Penelope" );
>
> ...
> ...
>
> std::for_each( flyweight_factory< names >::instance().begin(),
> flyweight_factory< names >::instance().end(),
> std::ostream_inserter< std::string >( cout
> ) );
>
>
> If I have this feature I will be able to use a flyweight to create a
> translation table for my
> program.
>
> I simple defined a map from English to "other language" phrases
> bindings (pb) and uses it as my assoc_container_factory. (some
details
> maybe need to be tunned but the idea is simple)
>
> I can now write:
>
> struct translations {};
>
> typedef flyweight
> <
> std::string,
> tag< translations >,
> assoc_container_factory< tunned_map<std::string,std::string> >
>
> > tr;
>
> ...
>
> fileMenu.set_text( "File" ); // set_text takes a tr object
>
> ...
>
> void ChangeLanguageToSpanish()
> {
> flyweight_factory< translations >::instance()[ "File" ] =
> "Archivo"; ...
> };
>
> Is this possible?

How's this different from an std::map<flyweight<std::string>,
flyweight<std::string> >?

On the other hand, I see value in somehow exposing the factory
for more or less advanced uses like debugging and so on,
as you propose. I'll try to elaborate on this in the next
draft.

>
> Thanks for yet another great library!

Thanks for your enthusiasm, I'm glad you like this.

> Best regards
> Matias Capeletto

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