bug-mailutils
[Top][All Lists]
Advanced

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

Re: Confused about owner


From: Alain Magloire
Subject: Re: Confused about owner
Date: Mon, 14 May 2001 01:21:26 -0400 (EDT)

Bonjour

> Can someone clue me in to the thinking behind the object's
> owner.

Sure.  Actually a couple of people could, but they never
posted to the list, they just come down to my desk 8-)

> A header's owner seems to be a message. So it looks like

Yes, an object is the owner of its parts.
You will have to blame dxxxxxs for this 8-).

> the owner is being used for encapsulation.

Yes.

> But a message's owner seems to be it's derived object. I.e.

A message owner is usually
- a mailbox object or its concrete implementation.
- a mime parser object
- null,(floating message .i.e with no implementation)
- Actually anything 8-).

> a imap_message is derived from a message, and a message
> has a pointer back up to an imap message.

Yes.
An imap_message(struct _msg_imap *) is the owner of a message that you
get from a IMAP mailbox.  So if you are at the leaf say:

mailbox_create (&mbox, "imap://...");
mailbox_open (..);
mailbox_get_message (mbox, &msg);
message_get_header (msg, &header);
header_get_stream (header, &stream);

the stream is own by the header, the header is own by the message
and the message is own by the ... imap_message 8).

Technically it should have been by the mailbox
... but heu .. well it was easier for me to short-circuit a little 8-).
So the theory is:
stream -> header -> message -> mailbox -> concrete implementatin (POP, IMAP,
MBOX, etc ..)

> So it looks like "random data, useful to the creator of the
> object".

Yes.

> That's cool, but can I (as a user of the mailbox API) use it, too?

No, it is not yours to play with.

> Can I cal set_owner on things, or am going to trample something?

You can not and there is no xxx_set_owner() for this reason.

> It looks like it. This kind of looks
> like something that should be for internal use only

Yes. void *owner is never inspected by anyone and you do know the type.

>  because it returns pointers to objects who's type's I don't know,
> so can't use.
> 
> Am I correct?

Yes.

There is a proposal by dxxxxxs to change the "void *owner"
to owner_t with a known interface, that you could query etc ...
At that time it was not clear for him nor for me the usefullness
of it  we did not go forward with the idea.

Why do you need this?  As you pointed out the "void *owner" is use
for encapsulation/overloading. When you overload a function the
"void *owner" is handle back to you.

This is a simple technique to implement shallow encapsulation and overloading
I did not want to go to deep into OO like providing deep level of
inheritance etc ...

Since I did not have the language to do it, I went with simplicity instead
of constructing vtables and supers etc ... C is not C++.

So encapsulation with some basic overloading, one level of inheritance
and providing aggregate objects instead of deep level of inheritance.

If we had choosen C++ things would be different 8-)

--
alain




reply via email to

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