[PATCH 4/6] core: add message handler

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

 



On Tue, 2017-10-03 at 19:41 +0200, Georg Chini wrote:
> On 03.10.2017 14:58, Tanu Kaskinen wrote:
> > On Mon, 2017-10-02 at 14:32 +0200, Georg Chini wrote:
> > > On 02.10.2017 11:31, Tanu Kaskinen wrote:
> > > > On Sun, 2017-10-01 at 20:31 +0200, Georg Chini wrote:
> > > > > On 01.10.2017 18:16, Tanu Kaskinen wrote:
> > > > > > On Sat, 2017-08-19 at 17:48 +0200, Georg Chini wrote:
> > > > > > > +/* List handlers */
> > > > > > > +char *pa_core_message_handler_list(pa_core *c);
> > > > > > 
> > > > > > Putting this function to core-messages.h doesn't seem right to me. The
> > > > > > function will never be used outside core.c, so the it should be a
> > > > > > private function in core.c.
> > > > > > 
> > > > > 
> > > > > If I put it in core.c, I would need to expose the pa_core_message_handler
> > > > > structure, which you wanted to keep private.
> > > > 
> > > > I think it actually makes sense to make the struct public. It could be
> > > > private if it didn't have the description field, but since the handler
> > > > objects contain information that clients can query, they're similar to
> > > > all other core objects. I think it even makes sense to move the struct
> > > > to a separate message-handler.h header (but if you don't like that
> > > > idea, I'm fine with keeping it in core-messaging.h or moving it to
> > > > core.h).
> > > 
> > > You want a header file just for this struct? I would keep it in
> > > core-messages.h but if you prefer, I don't mind using a
> > > separate file.
> > 
> > Indeed, creating a separate header just for the struct definition
> > doesn't make much sense. After thinking this a bit more, I still like
> > the idea of having message-handler.[ch] for the message handler object,
> >   though. The message-handler.h header could include not only the struct
> > definition, but also the following functions:
> > 
> > pa_message_handler_new()
> >      (renamed from pa_core_message_handler_register())
> > pa_message_handler_free()
> >      (renamed from pa_core_message_handler_unregister)
> > pa_message_handler_set_description()
> >      (renamed from pa_core_message_handler_set_description())
> > 
> > The only thing left in core-messaging.h would be
> > pa_core_send_message(), and I'd move that to core.h.
> > 
> > But do as you like, I don't care about this that much.
> > 
> 
> I don't like using pa_message_handler_new() because the function
> does not create a new message handler, but only registers it.

As far as I can tell, the register() function that you wrote very much
creates a new message handler object...

> I don't
> mind dropping the _core_ part from the names. I would then also
> rename pa_core_send_message() to
> pa_message_handler_send_message() and put it in the same header
> file.

I don't like renaming it to pa_message_handler_send_message(), because
the function isn't a "method" (in OOP lingo) of a message handler. It
fits better as a method of the core object.

But again, do as you want.

-- 
Tanu

https://www.patreon.com/tanuk


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux