Graphics properties as objects

Michael Goffioul michael.goffioul at gmail.com
Tue Jan 8 10:02:16 CST 2008


On 1/8/08, John W. Eaton <jwe at bevo.che.wisc.edu> wrote:
> | Yes, but in the meantime, you'll have another reference stored in the
> | map. So the internal object will not be deleted.
>
> OK, then why not pass by reference to avoid the unnecessary calls to
> the copy constructor and destructor?

Fine for me. It's just that constructing a property object is rather cheap
as it only involves incrementing the reference count. Note that it must
be a non-const reference because of the set_name/set_parent calls.

> Other than that, my initial impression is that the proposal is good
> and keeps most of the details hidden from the user.

Still to be determined: what type should the get_xxx return?

> It seems the only
> thing to really know is that there are some requirements for to the
> pointer to the base_property object that is passed to the property
> constructor:
>
>  * if persist is true, then the pointer must be valid for as long as
>    the map exists and it is the caller's responsibility to delete the
>    object that the pointer refers to

That's why I made "insert_static_property" protected (as it's the only
place where this could be used).

>  * if persiste is false, then the pointer should point to an object
>    that has been allocated with new and the object will be deleted
>    when the map is deleted
>
> Is that correct?  If so, I think these rules should be stated in a
> comment in the code.

OK, I'll add them.

Michael.


More information about the Octave-maintainers mailing list