|
Boost Users : |
From: Jens Müller (jens.mueller_at_[hidden])
Date: 2007-02-04 13:27:17
Dmitry schrieb:
>
> "Jens Muller" <jens.mueller_at_[hidden]> wrote in message
> news:<eq4poi$go9$1_at_[hidden]>...
>> Dmitry schrieb:
>>> Jens, the ReadablePropertyMap parameter has to be a class with the
> following
>>> typedef at least:
>>>
>>> typedef value_type some_type;
>>>
>>
>> Why?
>>
>> http://www.boost.org/libs/property_map/ReadablePropertyMap.html says:
>>
>> Associated Types
>> Value Type boost::property_traits<PMap>::value_type The type of
> the
>> property.
>>
>> That's what these traits classes are for: external adaption.
>>
>> You replied to the fixed version where I use property_traits.
>
> Jens,
> I think that you are missing something. As for me, the property_traits class
> is just a way of uniform data manipulation.
If every pm needed to be a class, there would be no need for the
*_traits template classes.
http://www.boost.org/libs/graph/doc/leda_conversion.html
The Adaptor pattern [12] typically requires that the adaptee object be
contained inside a new class that provides the desired interface. This
containment is not required when wrapping a graph for BGL because the
BGL graph interface consists solely of free (global) functions. Instead
of creating a new graph class, you need to overload all the free
functions required by the interface. We call this free function wrapper
approach external adaptation
...
All types associated with a BGL graph class are accessed though the
graph_traits class. We can partially specialize this traits class for
the LEDA GRAPH class in the following way.
The same is done here for vectors and the like.
> Your class has to be a model of
> this abstract concept. (To be a Read Property Map it is enough to have 3
> typedefs and get() function, see Concept Checking Class in the documentation
> that you referred).
Yes, it says the get() free function and 3 typedefs in property_traits
need to be defined.
Anyway, it works now, see attachments.
One question remains, though:
template<typename Graph, typename ReadablePropertyMap, typename ColorValue>
ColorValue MapAsColorMap<Graph, ReadablePropertyMap,
ColorValue>::get(key_type key)
{
return (boost::get(pm_, key)==white_) ?
boost::color_traits<ColorValue>::white()
:
boost::color_traits<ColorValue>::black();
}
works, while get(pm_, key) without boost:: doesn't.
Shouldn't the right get function be found by Koenig lookup?
http://www.boost.org/libs/property_map/ReadablePropertyMap.html says,
too, that get is required, not boost::get ...
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net