2007-08-14 20:45:23 +00:00
|
|
|
/*
|
2008-01-01 17:20:20 +00:00
|
|
|
* This file Copyright (C) 2007-2008 Charles Kerr <charles@rebelbase.com>
|
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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _TR_PUBLISHER_H_
|
|
|
|
#define _TR_PUBLISHER_H_
|
|
|
|
|
|
|
|
/**
|
|
|
|
*** A lightweight implementation of the 'Observable' design pattern.
|
|
|
|
**/
|
|
|
|
|
|
|
|
typedef struct tr_publisher_s tr_publisher_t;
|
|
|
|
|
|
|
|
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-09-23 19:11:04 +00:00
|
|
|
tr_publisher_tag tr_publisherSubscribe( tr_publisher_t * publisher,
|
|
|
|
tr_delivery_func delivery_func,
|
|
|
|
void * user_data );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_publisherUnsubscribe( tr_publisher_t * publisher,
|
|
|
|
tr_publisher_tag tag );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** Observable API
|
|
|
|
**/
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_publisher_t * tr_publisherNew( void );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_publisherFree( tr_publisher_t ** publisher );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
void tr_publisherPublish( tr_publisher_t * publisher,
|
|
|
|
void * source,
|
|
|
|
void * event );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
|
|
|
#endif
|