/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __MODEL_FILTER_H_
#define __MODEL_FILTER_H_

#include "gdammodel.h"
#include <gdam/client/gdamrequest.h>

typedef struct _GdamFilter GdamFilter;
typedef struct _GdamFilterClass GdamFilterClass;

GtkType gdam_filter_get_type();
#define GDAM_TYPE_FILTER			(gdam_filter_get_type ())
#define GDAM_FILTER(obj)			(GTK_CHECK_CAST ((obj), GDAM_TYPE_FILTER, GdamFilter))
#define GDAM_FILTER_CLASS(klass)		(GTK_CHECK_CLASS_CAST ((klass), GDAM_TYPE_FILTER, GdamFilterClass))
#define GDAM_IS_FILTER(obj)		(GTK_CHECK_TYPE ((obj), GDAM_TYPE_FILTER))
#define GDAM_IS_FILTER_CLASS(klass)	(GTK_CHECK_CLASS_TYPE ((klass), GDAM_TYPE_FILTER))

struct _GdamFilterClass {
	GdamModelClass		base_class;
	gboolean		(*attach_child)	       (GdamFilter* 	filter,
							GdamModel* 	child);
	gboolean		(*detach_child)	       (GdamFilter* 	filter,
							GdamModel* 	child);

	void                    (*disconnect)          (GdamFilter*     filter);
	void                    (*connect)             (GdamFilter*     filter);
	int         		(*append_start_request)(GdamFilter*	filter,
							int 	    source_id,
							GdamRequestBuilder*);
	void        		(*append_stop_request) (GdamFilter*	filter,
							GdamRequestBuilder*);

	void                    (*on_child_set_beat_info)
	                                               (GdamFilter*     filter,
						        const GdamBeatInfo*);
	void                    (*on_child_set_source)
	                                               (GdamFilter*     filter,
						        guint      source_id);
};

struct _GdamFilter 
{
	GdamModel		model;
	GdamModel*		child;
	  /* These are id's from signal connects.  We keep these in case we 
	   * need to remove them. */
	guint 			destroy_connect_id;
	guint 			set_source_connect_id;
	guint 			set_beat_info_connect_id;
};

void         gdam_filter_set_child            (GdamFilter*          filter,
                                               GdamModel*           child);
GdamModel*   gdam_filter_get_child            (GdamFilter*          filter);

/* Needed by builder.  Rather than using set/get child, parent and child
 * pointers are adjusted by hand and connect / disconnect called afterwards. */
void gdam_filter_disconnect(GdamFilter* filter);
void gdam_filter_connect(GdamFilter* filter);
int          gdam_filter_append_start_request(GdamFilter*           filter,
                                              int                   child_id,
					      GdamRequestBuilder*   builder);
void         gdam_filter_append_stop_request (GdamFilter*           filter,
                                              GdamRequestBuilder*   builder);

#endif
