octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Graphics properties as objects


From: John W. Eaton
Subject: Re: Graphics properties as objects
Date: Tue, 08 Jan 2008 10:55:54 -0500

On  8-Jan-2008, Michael Goffioul wrote:

| On 1/8/08, John W. Eaton <address@hidden> wrote:
| > On  8-Jan-2008, Michael Goffioul wrote:
| >
| > | On 1/8/08, John W. Eaton <address@hidden> wrote:
| > |
| > | > I'm surprised to see the property argument above not be a reference or
| > | > pointer.  Doesn't this cause a copy to be made when insert_property is
| > | > called?
| > |
| > | It just increases the reference counting of the underlying base_property
| > | object.
| >
| > But won't the count be decremented again when the destructor for the
| > local value in the insert_property function is called when the end of
| > the function is reached?
| 
| 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?

Other than that, my initial impression is that the proposal is good
and keeps most of the details hidden from the user.  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

  * 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.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]