Graphics properties as objects
Michael Goffioul
michael.goffioul at gmail.com
Sun Jan 6 15:24:00 CST 2008
On 1/6/08, John W. Eaton <jwe at bevo.che.wisc.edu> wrote:
> OK, I think my understanding of the problem is better now.
>
> Can we hide some of the details so that we can write
>
> all_props.insert ("my_property", string_property (...));
>
> ? I don't mind that the property class might need a series of
> constructors like
>
> property (const color_property& p) : rep (new color_property (p)) { ... }
> property (const radio_property& p) : rep (new radio_property (p)) { ... }
> property (const string_property& p) : rep (new string_property (p)) { ... }
> ...
>
> Also, I'd like to hide the following details in some way:
>
> property p (&string);
> p.increment_count_by_one ();
> xproperties.add (p);
>
> So maybe we could write
>
> axes::properties::properties (const graphics_handle& mh,
> const graphics_handle& p)
> : base_properties (go_name, mh, p),
> position (Matrix ()),
> ...
> {
> ...
>
> all_props.insert_static_property ("position", position);
> ...
> }
>
> and have all the reference counting and address-of details hidden?
I agree with the concept og hiding things, but from the code above,
I have the impression that the typed property object (contained in
the "property" interface object) stored in the property map would be
a copy of the typed property field contained in the graphic object.
Is this what you want? Or do you mean that "insert_static_property"
should get an implementation like the following to make sure the
typed property object is really shared:
void insert_static_property (const std::string& name, position_property& p)
{
all_props[name] = property (&p);
}
I have the impression that using a copy of "position" in the property map
will get you into trouble: if you change the position from octave, the
obvious implementation will probably be to access the map and change
the property. But the C++ backend will use get_position() to access
the property. If you use copies, the values won't match?
Or did I miss something?
Michael.
More information about the Octave-maintainers
mailing list