From 27dd5fdfaf395276532042dc0e62010afad85f1c Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 23 Jun 2006 20:16:07 +0000 Subject: [PATCH] add plugin interface to objects git-svn-id: http://ltt.polymtl.ca/svn@1963 04897980-b3bd-0310-b5e0-8ef037075253 --- .../modules/gui/controlflow/lttv_plugin_cfv.c | 84 +++++++++++++++++++ .../modules/gui/controlflow/lttv_plugin_cfv.h | 63 ++++++++++++++ .../gui/lttvwindow/lttvwindow/lttv_plugin.c | 73 ++++++++++++++++ .../gui/lttvwindow/lttvwindow/lttv_plugin.h | 72 ++++++++++++++++ .../lttvwindow/lttvwindow/lttv_plugin_tab.c | 83 ++++++++++++++++++ .../lttvwindow/lttvwindow/lttv_plugin_tab.h | 62 ++++++++++++++ 6 files changed, 437 insertions(+) create mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/lttv_plugin_cfv.c create mode 100644 ltt/branches/poly/lttv/modules/gui/controlflow/lttv_plugin_cfv.h create mode 100644 ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin.c create mode 100644 ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin.h create mode 100644 ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin_tab.c create mode 100644 ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin_tab.h diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/lttv_plugin_cfv.c b/ltt/branches/poly/lttv/modules/gui/controlflow/lttv_plugin_cfv.c new file mode 100644 index 00000000..d8b005ab --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/lttv_plugin_cfv.c @@ -0,0 +1,84 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2006 Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + + +#include "lttv_plugin_cfv.h" +#include +#include "drawing.h" + +/* + * forward definitions + */ + +/* + * Implementation + */ + +static void cfv_update_filter(LttvPlugin *parent, LttvFilter *filter) +{ + LttvPluginCFV *self = LTTV_PLUGIN_CFV(parent); + g_message("In CFV update filter."); + lttv_filter_destroy(self->cfd->filter); + self->cfd->filter = filter; + redraw_notify(self->cfd, NULL); +} + + +static void +lttv_plugin_cfv_class_init (LttvPluginCFVClass *klass) +{ + LttvPluginClass *parent_klass; + parent_klass = &klass->parent; + parent_klass->update_filter = cfv_update_filter; + g_type_class_add_private (klass, sizeof (ControlFlowData)); +} + + +static void +lttv_plugin_cfv_init (GTypeInstance *instance, gpointer g_class) +{ + LttvPluginCFV *self = LTTV_PLUGIN_CFV (instance); + self->cfd = G_TYPE_INSTANCE_GET_PRIVATE (self, + LTTV_TYPE_PLUGIN_CFV, ControlFlowData); +} + + +GType +lttv_plugin_cfv_get_type (void) +{ + static GType type = 0; + if (type == 0) { + static const GTypeInfo info = { + sizeof (LttvPluginCFVClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + lttv_plugin_cfv_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (LttvPluginCFV), + 0, /* n_preallocs */ + lttv_plugin_cfv_init /* instance_init */ + }; + type = g_type_register_static (G_TYPE_OBJECT, + "LttvPluginCFVType", + &info, 0); + } + return type; +} + + diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/lttv_plugin_cfv.h b/ltt/branches/poly/lttv/modules/gui/controlflow/lttv_plugin_cfv.h new file mode 100644 index 00000000..45445da9 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/lttv_plugin_cfv.h @@ -0,0 +1,63 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2006 Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#ifndef LTTV_PLUGIN_CFV_H +#define LTTV_PLUGIN_CFV_H + +#include +#include +#include "cfv.h" + +/* + * Type macros. + */ + +#define LTTV_TYPE_PLUGIN_CFV (lttv_plugin_cfv_get_type ()) +#define LTTV_PLUGIN_CFV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TYPE_PLUGIN_CFV, LttvPluginCFV)) +#define LTTV_PLUGIN_CFV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LTTV_TYPE_PLUGIN_CFV, LttvPluginCFVClass)) +#define LTTV_IS_PLUGIN_CFV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TYPE_PLUGIN_CFV)) +#define LTTV_IS_PLUGIN_CFV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LTTV_TYPE_PLUGIN_CFV)) +#define LTTV_PLUGIN_CFV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LTTV_TYPE_PLUGIN_CFV, LttvPluginCFVClass)) + +typedef struct _LttvPluginCFV LttvPluginCFV; +typedef struct _LttvPluginCFVClass LttvPluginCFVClass; + +struct _LttvPluginCFV { + LttvPlugin parent; + + /* instance members */ + ControlFlowData *cfd; + + /* private */ +}; + +struct _LttvPluginCFVClass { + LttvPluginClass parent; + + /* class members */ +}; + +/* used by LTTV_PLUGIN_TAB_TYPE */ +GType lttv_plugin_cfv_get_type (void); + +/* + * Method definitions. + */ + + +#endif diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin.c new file mode 100644 index 00000000..32eb60b0 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin.c @@ -0,0 +1,73 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2006 Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + + +#include "lttv_plugin.h" + +/* + * forward definitions + */ + + + +static void +lttv_plugin_class_init (LttvPluginClass *klass) +{ + klass->update_filter = NULL; /* Pure Virtual */ +} + +static void +lttv_plugin_instance_init (GTypeInstance *instance, gpointer g_class) +{ + LttvPlugin *self; + self->top_widget = NULL; +} + +GType +lttv_plugin_get_type (void) +{ + static GType type = 0; + if (type == 0) { + static const GTypeInfo info = { + sizeof (LttvPluginClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + lttv_plugin_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (LttvPlugin), + 0, /* n_preallocs */ + NULL /* instance_init */ + }; + type = g_type_register_static (G_TYPE_OBJECT, + "LttvPluginType", + &info, 0); + } + return type; +} + + +/* implementation in the source file */ +void lttv_plugin_update_filter (LttvPlugin *self, LttvFilter *filter) +{ + LTTV_PLUGIN_GET_CLASS (self)->update_filter (self, filter); +} + + + + diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin.h new file mode 100644 index 00000000..4db2d04c --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin.h @@ -0,0 +1,72 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2006 Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +/* The LttvPlugin class is a pure virtual class. It only contains the functions + * available for interaction with a plugin (tab or viewer). + */ + +#ifndef LTTV_PLUGIN_H +#define LTTV_PLUGIN_H + +#include +#include + +/* + * Type macros. + */ + +#define LTTV_TYPE_PLUGIN (lttv_plugin_get_type ()) +#define LTTV_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TYPE_PLUGIN, LttvPlugin)) +#define LTTV_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LTTV_TYPE_PLUGIN, LttvPluginClass)) +#define LTTV_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TYPE_PLUGIN)) +#define LTTV_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LTTV_TYPE_PLUGIN)) +#define LTTV_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LTTV_TYPE_PLUGIN, LttvPluginClass)) + +typedef struct _LttvPlugin LttvPlugin; +typedef struct _LttvPluginClass LttvPluginClass; + +struct _LttvPlugin { + GObject parent; + /* instance members */ + GtkWidget *top_widget; + + /* private */ +}; + +struct _LttvPluginClass { + GObjectClass parent; + + void (*update_filter) (LttvPlugin *self, LttvFilter *filter); + + /* class members */ +}; + +/* used by LTTV_PLUGIN_TYPE */ +GType lttv_plugin_get_type (void); + +/* + * Method definitions. + */ + +/* declaration in the header. */ +void lttv_plugin_update_filter (LttvPlugin *self, LttvFilter *filter); + + + + +#endif diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin_tab.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin_tab.c new file mode 100644 index 00000000..4571f653 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin_tab.c @@ -0,0 +1,83 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2006 Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + + +#include "lttv_plugin_tab.h" +#include + +/* + * forward definitions + */ + +/* + * Implementation + */ + +static void tab_update_filter(LttvPlugin *parent, LttvFilter *filter) +{ + LttvPluginTab *self = LTTV_PLUGIN_TAB(parent); + g_message("In tab update filter."); + lttv_filter_destroy(self->tab->filter); + self->tab->filter = filter; + lttvwindow_report_filter(self->tab, filter); +} + + +static void +lttv_plugin_tab_class_init (LttvPluginTabClass *klass) +{ + LttvPluginClass *parent_klass; + parent_klass = &klass->parent; + parent_klass->update_filter = tab_update_filter; + g_type_class_add_private (klass, sizeof (Tab)); +} + + +static void +lttv_plugin_tab_init (GTypeInstance *instance, gpointer g_class) +{ + LttvPluginTab *self = LTTV_PLUGIN_TAB (instance); + self->tab = G_TYPE_INSTANCE_GET_PRIVATE (self, + LTTV_TYPE_PLUGIN_TAB, Tab); +} + + +GType +lttv_plugin_tab_get_type (void) +{ + static GType type = 0; + if (type == 0) { + static const GTypeInfo info = { + sizeof (LttvPluginTabClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + lttv_plugin_tab_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (LttvPluginTab), + 0, /* n_preallocs */ + lttv_plugin_tab_init /* instance_init */ + }; + type = g_type_register_static (G_TYPE_OBJECT, + "LttvPluginTabType", + &info, 0); + } + return type; +} + + diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin_tab.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin_tab.h new file mode 100644 index 00000000..6acbec43 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttv_plugin_tab.h @@ -0,0 +1,62 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2006 Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#ifndef LTTV_PLUGIN_TAB_H +#define LTTV_PLUGIN_TAB_H + +#include +#include + +/* + * Type macros. + */ + +#define LTTV_TYPE_PLUGIN_TAB (lttv_plugin_tab_get_type ()) +#define LTTV_PLUGIN_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TYPE_PLUGIN_TAB, LttvPluginTab)) +#define LTTV_PLUGIN_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LTTV_TYPE_PLUGIN_TAB, LttvPluginTabClass)) +#define LTTV_IS_PLUGIN_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TYPE_PLUGIN_TAB)) +#define LTTV_IS_PLUGIN_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LTTV_TYPE_PLUGIN_TAB)) +#define LTTV_PLUGIN_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LTTV_TYPE_PLUGIN_TAB, LttvPluginTabClass)) + +typedef struct _LttvPluginTab LttvPluginTab; +typedef struct _LttvPluginTabClass LttvPluginTabClass; + +struct _LttvPluginTab { + LttvPlugin parent; + + /* instance members */ + Tab *tab; + + /* private */ +}; + +struct _LttvPluginTabClass { + LttvPluginClass parent; + + /* class members */ +}; + +/* used by LTTV_PLUGIN_TAB_TYPE */ +GType lttv_plugin_tab_get_type (void); + +/* + * Method definitions. + */ + + +#endif -- 2.34.1