[Property Map] Composition of properties

Hello everyone, I have been using properties quite extensively in my work. And these last days i have needed to combine properties numerous times. By that, i mean that i have n properties p1, p2, ... pn and what i use is get( p1, get( p2, get( ..., get( pn, object ) ... ) ) ) I would very much want to make a composite property p to be used like this : get( p, object ) (most of the time, n=2, but why stop there ? :-) ) I have to tried to find such functionality but in vain so far... Does it not exist ? Are there obstacles that i have not foreseen ? I am thinking of something like the following : template<class Prop1, class Prop2> struct composite_property { composite_property( Prop1 p1_, Prop2 p2_ ) : p1( p1_ ), p2( p2_ ) { } Prop1 p1; Prop2 p2; }; template<class Prop1, class Prop2> typename property_traits<Prop1>::reference get(composite_property<Prop1, Prop2> comp, typename property_traits<Prop2>::reference x ) { return get( comp.p1, get( comp.p2, x ) ); } How do you all feel about this ? I believe it would be very useful ! -- Benoît Casoetto

--- Benoit wrote:
Hello everyone,
Howdy!
I have been using properties quite extensively in my work. And these last days I have needed to combine properties numerous times.
By that, I mean that I have n properties p1, p2, ... pn and what I use is get( p1, get( p2, get( ..., get( pn, object ) ... ) ) ) I would very much want to make a composite property p to be used like this : get( p, object ) (most of the time, n=2, but why stop there ? :-) )
I have to tried to find such functionality but in vain so far... Does it not exist? Are there obstacles that i have not foreseen? I am thinking of something like the following:
template<class Prop1, class Prop2> struct composite_property { composite_property(Prop1 p1_, Prop2 p2_) : p1( p1_ ), p2( p2_ ) { }
Prop1 p1; Prop2 p2; };
template<class Prop1, class Prop2> typename property_traits<Prop1>::reference get(composite_property<Prop1, Prop2> comp, typename property_traits<Prop2>::reference x) { return get( comp.p1, get( comp.p2, x ) ); }
How do you all feel about this? I believe it would be very useful!
I believe that the Fusion library provides a map that possesses the functionality you need. You can wait until Boost version 1.34 is released, or you can grab a CVS snapshot in order to play with it right away. HTH, Cromwell D. Enage __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Hello, Thanks for the quick answer. Unfortunately, since i am completely new to boost.fusion, i can't seem to find what you are talking about in the documentation... Can you tell me a bit more about what you have in mind ? For now, I feel i would still have to write the get() function, and optionally check that each property's key type is the value type of the previous one in the "sequence" (which i named composite_property in my first mail). If i do, i guess i won't wait for boost 1.34. Benoît 2006/9/16, Cromwell Enage <sponage@yahoo.com>:
--- Benoit wrote:
Hello everyone,
Howdy!
I have been using properties quite extensively in my work. And these last days I have needed to combine properties numerous times.
By that, I mean that I have n properties p1, p2, ... pn and what I use is get( p1, get( p2, get( ..., get( pn, object ) ... ) ) ) I would very much want to make a composite property p to be used like this : get( p, object ) (most of the time, n=2, but why stop there ? :-) )
I have to tried to find such functionality but in vain so far... Does it not exist? Are there obstacles that i have not foreseen? I am thinking of something like the following:
template<class Prop1, class Prop2> struct composite_property { composite_property(Prop1 p1_, Prop2 p2_) : p1( p1_ ), p2( p2_ ) { }
Prop1 p1; Prop2 p2; };
template<class Prop1, class Prop2> typename property_traits<Prop1>::reference get(composite_property<Prop1, Prop2> comp, typename property_traits<Prop2>::reference x) { return get( comp.p1, get( comp.p2, x ) ); }
How do you all feel about this? I believe it would be very useful!
I believe that the Fusion library provides a map that possesses the functionality you need. You can wait until Boost version 1.34 is released, or you can grab a CVS snapshot in order to play with it right away.
HTH, Cromwell D. Enage
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Benoît "When you have a hammer, everything else looks like a nail"

"Benoit ." <trasfract@gmail.com> writes:
Hello,
Thanks for the quick answer. Unfortunately, since i am completely new to boost.fusion, i can't seem to find what you are talking about in the documentation...
<snip>
2006/9/16, Cromwell Enage <sponage@yahoo.com>:
--- Benoit wrote:
Hello everyone,
<snip long quote> Please try not to overquote. http://www.boost.org/more/discussion_policy.htm#effective Thanks, -- Dave Abrahams Boost Consulting www.boost-consulting.com

--- "Benoit ." wrote:
Hello,
Thanks for the quick answer. Unfortunately, since i am completely new to boost.fusion, i can't seem to find what you are talking about in the documentation...
Like I stated in a recent post, I may have jumped the gun.
Can you tell me a bit more about what you have in mind ?
I'll do my best. But first, I have a few questions of my own.
By that, I mean that I have n properties p1, p2, ... pn and what I use is get( p1, get( p2, get( ..., get( pn, object ) ... ) ) )
Now that I'm seeing it clearly, it looks like object is a propert maps of property maps and so on. Was that your intention?
I would very much want to make a composite property p to be used like this : get( p, object )
IIUC, p is your composite of, say, p1 and p2? Is object a property map for whom p is a key? Cromwell D. Enage __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Now that I'm seeing it clearly, it looks like object is a property maps of property maps and so on. Was that your intention? No !!! object is simply the key to pn, and can be used like this : get( pn, object). The get function returns an item which is a key for property map p(n-1). And so forth until the actual information we are trying to retrieve...
get( p, object )
IIUC, p is your composite of, say, p1 and p2? Is object a property map for whom p is a key? p is definitely a composite of p1 and p2. But i stated above, object is in no way a property map ; it is simply the key to p, which is a property map.
i hope things are getting clearer, it seems the more i try to explain, the more confuse it gets ! -- Benoît Casoetto

I have written a functional version of what i was looking for. I still don't know if it yet existed. I am very interested in such functionality. Hope others will be too ! --Benoît Casoetto

Benoit <benoit.casoetto@m4x.org> writes:
Now that I'm seeing it clearly, it looks like object is a property maps of property maps and so on. Was that your intention? No !!! object is simply the key to pn, and can be used like this : get( pn, object). The get function returns an item which is a key for property map p(n-1). And so forth until the actual information we are trying to retrieve...
get( p, object )
IIUC, p is your composite of, say, p1 and p2? Is object a property map for whom p is a key? p is definitely a composite of p1 and p2. But i stated above, object is in no way a property map ; it is simply the key to p, which is a property map.
i hope things are getting clearer, it seems the more i try to explain, the more confuse it gets !
IIUC, Benoit wants, essentially, the property map equivalent of an indirect iterator. -- Dave Abrahams Boost Consulting www.boost-consulting.com

IIUC, Benoit wants, essentially, the property map equivalent of an indirect iterator. I am sorry, i am not familiar with indirect_iterator. Although i have taken a look at the documentation, i must admit i still don't see the link between with i am proposing.
Do you mean i could use indirect_iterator to implement it ? PS : there was a mistake in the file i provided : "typename boost::property_traits < Prop1 >::key_type" must be replaced by "typename boost::property_traits < Prop1 >::value_type". -- Benoît

Cromwell Enage <sponage@yahoo.com> writes:
I believe that the Fusion library provides a map that possesses the functionality you need. You can wait until Boost version 1.34 is released, or you can grab a CVS snapshot in order to play with it right away.
Are you sure you understand what the OP means by "property map?" It's a concept used in the Graph library. -- Dave Abrahams Boost Consulting www.boost-consulting.com

--- David Abrahams wrote:
Are you sure you understand what the OP means by "property map?"
Yes. I simply misread the problem. I'll try to come up with a more relevant answer for the next post. Cromwell D. Enage __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
participants (4)
-
Benoit
-
Benoit .
-
Cromwell Enage
-
David Abrahams