1 /* This file is part of Ganv. 2 * Copyright 2007-2016 David Robillard <http://drobilla.net> 3 * 4 * Ganv is free software: you can redistribute it and/or modify it under the 5 * terms of the GNU General Public License as published by the Free Software 6 * Foundation, either version 3 of the License, or any later version. 7 * 8 * Ganv is distributed in the hope that it will be useful, but WITHOUT ANY 9 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. 11 * 12 * You should have received a copy of the GNU General Public License along 13 * with Ganv. If not, see <http://www.gnu.org/licenses/>. 14 */ 15 16 #ifndef GANV_BOILERPLATE_H 17 #define GANV_BOILERPLATE_H 18 19 #include "ganv/item.h" 20 21 #include <glib.h> 22 23 typedef gpointer gobject; 24 25 /** 26 A case in a switch statement in a set_properties implementation. 27 @prop: Property enumeration ID. 28 @type: Name of the value type, e.g. uint for guint. 29 @field: Field to set to the new value. 30 */ 31 #define SET_CASE(prop, type, field) \ 32 case PROP_##prop: { \ 33 const g##type tmp = g_value_get_##type(value); \ 34 if ((field) != tmp) { \ 35 (field) = tmp; \ 36 ganv_item_request_update(GANV_ITEM(object)); \ 37 } \ 38 break; \ 39 } 40 41 /** 42 A case in a switch statement in a get_properties implementation. 43 @prop: Property enumeration ID. 44 @type: Name of the value type, e.g. uint for guint. 45 @field: Field to set to the new value. 46 */ 47 #define GET_CASE(prop, type, field) \ 48 case PROP_##prop: \ 49 g_value_set_##type(value, field); \ 50 break; 51 52 #endif // GANV_BOILERPLATE_H 53