bug-mailutils
[Top][All Lists]
Advanced

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

Re: [bug-mailutils] Merging libraries (was Re: Mailutils 0.3


From: Sergey Poznyakoff
Subject: Re: [bug-mailutils] Merging libraries (was Re: Mailutils 0.3
Date: Tue, 25 Feb 2003 12:14:21 +0200

Just an idea regarding object structures in the new libmailbox.
The mailutils objects have many things in common, so it may prove
useful to create a 'generic object' structure which will provide
the basic object functionality, e.g.:

typedef struct _mu_generic_object *mu_generic_object_t;

/* generic methods available to any object */
struct _mu_generic_vtab {
       int      (*create) (mu_generic_object_t *);
       int      (*close)  (mu_generic_object_t);
       int      (*destroy)(mu_generic_object_t *);
       int      (*notify) (mu_generic_object obj, int event, void *data);
       /* something else? */
};

/* generic object: a parent of all mailutils objects */
struct _mu_generic_object {
       int        type;         /* Type of the object */
       size_t     size;         /* Size of the object instance */
       struct     _mu_generic_vtab vtab; /* generic methods */
       /* Possibly something else? */
};

Now, mailbox structure would be defined as follows:

typedef struct _mu_mailbox *mu_mailbox_t;

struct _mu_mailbox {
       struct _mu_generic_object gen;   /* This provides basic methods */
       struct _mu_mailbox_vtab vtab;    /* mailbox-specific methods */
              /* Mailbox-specific data follow */
       unsigned int messages_count;
      /* ... etc ... */
};

Any particular mailbox implementation is built upon mu_mailbox_t in
the following way:

struct _mu_mbox_mailbox {
       struct _mu_mailbox base;         /* basic mailbox functionality*/
              /* Mbox-specific data */
       char *filename;                  
       lockfile_t  lockfile;
       /* ... etc ... */
};

Opinions?

Regards,
Sergey




reply via email to

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