[ZOOM] Re: zoom.hh

Adam Dickmeiss adam at indexdata.dk
Thu Nov 29 23:50:06 CET 2001


On Thu, Nov 29, 2001 at 03:27:27PM +0000, Mike Taylor wrote:
> Yesterday I wrote:
> 
> > Date: Wed, 28 Nov 2001 17:10:14 GMT
> > From: Mike Taylor <mike at tecc.co.uk>
> > 
> > So we seem to be agreed that in some circumstances, we want records
> > to be "owned" by their result sets, so that we don't have to bother
> > explicitly freeing them; and in others, we want the records to be
> > fully autonomous, so that we can return them from scopes in which
> > they are obtained from transient result sets.
> > 
> > I can think of three, maybe four ways of expressing that choice in
> > the interface.  I'll tell you what they are tomorrow, and then we
> > can choose which is least offensive.
> 
> OK, here are the alternatives I'm aware of:
> 
> Option 1 (which is what we have in 1.0g):
> 
> 	class resultSet {
> 	  public:
> 	    const record *getRecord (size_t i) const;
> 	}
> 
> 	class record {
> 	  public:
> 	    record *clone () const = 0;
> 	}
> 
> Option 2 (which is similar, except that instead of taking an
> autonomous copy of an existing resultSet-owned record, an existing
> record _becomes_ autonomous):
> 
> 	class resultSet {
> 	  public:
> 	    const record *getRecord (size_t i) const;
> 	}
> 
> 	class record {
> 	  public:
> 	    void steal(void) const;
> 	}
> 
> Option 3 (in which you can get either kind of record directly from the
> resultSet object):
> 
> 	class resultSet {
> 	  public:
> 	    const record *getRSOwnedRecord (size_t i) const;
> 	    const record *getAutonomousRecord (size_t i) const;
> 	}
> 
> Each of these approaches is of course subject to further refinements
> -- for example, the clone() method of the first approach could be
> provided in the form of a copy constructor -- but I don't want to talk
> about those refinements yet, if we can avoid it: I just want to get a
> sense of which of these three fundamentally different models we prefer
> for providing both "flavours" of record ownership.
> 
> Who likes what?  Why?

I prefer option 1. First, it's what we've decided already.
Second, in many cases you don't need to clone, so there's one method
to get the data from the result set (unlike 3). Finally, I don't
like method steal from 2, since that requires us to keep a pointer to
something in the originating result set within a record (so that we
can release ourselves from it).

-- Adam

>  _/|_	 _______________________________________________________________
> /o ) \/  Mike Taylor   <mike at miketaylor.org.uk>   www.miketaylor.org.uk
> )_v__/\  "Adjectives are like spices, to be used for flavour, with
> 	 care: not to kill the essential flavour of the sentence" --
> 	 Rheal Nadeau.
> 
> _______________________________________________
> ZOOM mailing list
> ZOOM at indexdata.dk
> http://www.indexdata.dk/mailman/listinfo/zoom

-- 
Adam Dickmeiss  mailto:adam at indexdata.dk  http://www.indexdata.dk
Index Data      T: +45 33410100           Mob.: 212 212 66



More information about the ZOOM mailing list