|
Boost : |
From: Matias Capeletto (matias.capeletto_at_[hidden])
Date: 2006-07-17 11:15:09
> * Do you deem the lib worth eventually proposing to Boost?
Yes!
> * 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.
> * Are you OK with the design concepts, in particular with the concepts
> around factories and holders?
This is one of the strong point of the library. This makes it very flexible.
I like the design a lot.
> * Have you been able to use it?
Yes, with Linux/gcc4, no problems...
> * 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?
Thanks for yet another great library!
Best regards
Matias Capeletto
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk