2007-08-14 20:45:23 +00:00
|
|
|
/*
|
2010-01-04 21:00:47 +00:00
|
|
|
* This file Copyright (C) 2007-2010 Mnemosyne LLC
|
2007-08-14 20:45:23 +00:00
|
|
|
*
|
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
2008-09-23 19:11:04 +00:00
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
2007-08-14 20:45:23 +00:00
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
2007-08-18 17:05:51 +00:00
|
|
|
*
|
2007-08-18 17:19:49 +00:00
|
|
|
* $Id$
|
2007-08-14 20:45:23 +00:00
|
|
|
*/
|
|
|
|
|
2008-11-24 20:17:36 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
|
|
|
#error only libtransmission should #include this header.
|
|
|
|
#endif
|
|
|
|
|
2007-08-14 20:45:23 +00:00
|
|
|
#ifndef _TR_PUBLISHER_H_
|
|
|
|
#define _TR_PUBLISHER_H_
|
|
|
|
|
2008-12-29 18:10:07 +00:00
|
|
|
struct tr_list;
|
|
|
|
|
2007-08-14 20:45:23 +00:00
|
|
|
/**
|
|
|
|
*** A lightweight implementation of the 'Observable' design pattern.
|
|
|
|
**/
|
|
|
|
|
2008-12-29 18:10:07 +00:00
|
|
|
typedef struct tr_publisher
|
|
|
|
{
|
|
|
|
struct tr_list * list;
|
|
|
|
}
|
|
|
|
tr_publisher;
|
2007-08-14 20:45:23 +00:00
|
|
|
|
|
|
|
typedef void * tr_publisher_tag;
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
typedef void tr_delivery_func ( void * source,
|
|
|
|
void * event,
|
|
|
|
void * user_data );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** Observer API
|
|
|
|
**/
|
|
|
|
|
2008-12-29 18:10:07 +00:00
|
|
|
tr_publisher_tag tr_publisherSubscribe( tr_publisher * publisher,
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_delivery_func delivery_func,
|
|
|
|
void * user_data );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
2008-12-29 18:10:07 +00:00
|
|
|
void tr_publisherUnsubscribe( tr_publisher * publisher,
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_publisher_tag tag );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** Observable API
|
|
|
|
**/
|
|
|
|
|
2008-12-29 18:10:07 +00:00
|
|
|
extern const tr_publisher TR_PUBLISHER_INIT;
|
2007-08-14 20:45:23 +00:00
|
|
|
|
2008-12-29 18:10:07 +00:00
|
|
|
void tr_publisherDestruct( tr_publisher * );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
2008-12-29 18:10:07 +00:00
|
|
|
void tr_publisherPublish( tr_publisher * publisher,
|
2008-09-23 19:11:04 +00:00
|
|
|
void * source,
|
|
|
|
void * event );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
|
|
|
#endif
|