iceWing
Main Page
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
main
plugin_comm.h
Go to the documentation of this file.
1
/* -*- mode: C; tab-width: 4; c-basic-offset: 4; -*- */
2
3
/*
4
* Author: Frank Loemker
5
*
6
* Copyright (C) 1999-2009
7
* Frank Loemker, Applied Computer Science, Faculty of Technology,
8
* Bielefeld University, Germany
9
*
10
* This file is part of iceWing, a graphical plugin shell.
11
*
12
* iceWing is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2 of the License, or
15
* (at your option) any later version.
16
*
17
* iceWing is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
*/
26
27
#ifndef iw_plugin_comm_H
28
#define iw_plugin_comm_H
29
30
#include "
plugin.h
"
31
32
/* Use default priority values */
33
#define PLUG_PRIORITY_DEFAULT (-1)
34
/* Always at end of list */
35
#define PLUG_PRIORITY_MIN 0
36
/* Always at start of list */
37
#define PLUG_PRIORITY_MAX 1000
38
39
/* Called if data stored with plug_data_set() should be released */
40
typedef
void (*
plugDataDestroyFunc
) (
void
*
data
);
41
typedef
void (*
plugFunc
) ();
42
43
/* Stored data, see e.g. plug_data_get(). */
44
typedef
struct
plugData
{
45
plugDefinition
*
plug
;
/* Plugin which stored the data */
46
char
*
ident
;
/* ID under which the data was stored */
47
void
*
data
;
/* The actual data */
48
}
plugData
;
49
50
/* Stored function, see e.g. plug_function_get() */
51
typedef
struct
plugDataFunc
{
52
plugDefinition
*
plug
;
/* Plugin which stored the function */
53
char
*
ident
;
/* ID under which the function was stored */
54
plugFunc
func
;
/* The actual function */
55
}
plugDataFunc
;
56
57
#ifdef __cplusplus
58
extern
"C"
{
59
#endif
60
61
/*
62
* Data interface:
63
* Store/Retrieve any data. Allows to exchange data between plugins.
64
*/
65
66
/*********************************************************************
67
Store refcounted data under the ID ident. plug is the plugin from
68
where this function is called.
69
destroy is called if the refcount drops to 0.
70
*********************************************************************/
71
void
plug_data_set
(
plugDefinition
*plug,
const
char
*ident,
void
*data,
72
plugDataDestroyFunc
destroy);
73
74
/*********************************************************************
75
By default, even if refcount of data drops to 0, it is deleted not
76
until the end of the current mainloop run. This changes it to delete
77
data immediately if refcount drops to 0. If unsure, don't use it.
78
*********************************************************************/
79
void
plug_data_sink
(
plugData
*data);
80
81
/*********************************************************************
82
Retrieve data stored under the ID 'ident'.
83
The refcount of 'data' is increased.
84
data : If != NULL the data stored after 'data' under 'ident'
85
is returned, otherwise the first data element with an
86
ID of 'ident.
87
_new() / onlynew: Get only data which was added after the
88
last restart of the mainloop.
89
plug_name: Get data stored by a plugin by this name.
90
*********************************************************************/
91
plugData
*
plug_data_get
(
const
char
*ident,
plugData
*data);
92
plugData
*
plug_data_get_new
(
const
char
*ident,
plugData
*data);
93
plugData
*
plug_data_get_full
(
const
char
*ident,
plugData
*data,
94
BOOL
onlynew,
const
char
*
plug_name
);
95
96
/*********************************************************************
97
Increase the refcount of 'data'. plug_data_unget() must be called
98
to drop the refcount.
99
*********************************************************************/
100
void
plug_data_ref
(
plugData
*data);
101
102
/*********************************************************************
103
Drop refcount of data.
104
*********************************************************************/
105
void
plug_data_unget
(
plugData
*data);
106
107
/*********************************************************************
108
Returns TRUE if there is a plugin which observes 'ident'.
109
*********************************************************************/
110
BOOL
plug_data_is_observed
(
const
char
*ident);
111
112
/*
113
* Observer interface:
114
* Install/Remove observer on data set with plug_data_set().
115
* The observer are called from the main loop if new data with the
116
* correct ident is stored via plug_data_set().
117
*
118
* Two points to remember:
119
* 1. Only old Data (-> data set before the current mainloop run
120
* started) with ID exists after restarting the mainloop:
121
* Observer for ID are NOT called.
122
* 2. MainLoop processes currently ID1 and new data with ID2 != ID1 is set:
123
* Call all ID2-observer before restarting the mainloop,
124
* if the new data is NOT deleted in the meantime
125
*/
126
127
/*********************************************************************
128
Add an observer for data with the ID 'ident'. plug is the plugin
129
from where this function is called. The plugin's proces() function
130
will be called if data with the ID 'ident' is available.
131
ident == "id" : Add the observer.
132
ident == "id()" : Add the observer. The proces() function is
133
called one after another for all available data elements
134
(see plug_add_default_page()).
135
ident == "id(plugs)": Add the observer. The proces() function is
136
additionally called for data elements from the plugins
137
"plugs" (see plug_add_default_page()).
138
*********************************************************************/
139
void
plug_observ_data
(
plugDefinition
*plug,
const
char
*ident);
140
void
plug_observ_data_priority
(
plugDefinition
*plug,
const
char
*ident,
int
pri);
141
142
/*********************************************************************
143
Remove an observer set with plug_observ_data().
144
ident == "id" : Remove the observer.
145
ident == "id()" : Remove the observer and any dependent plugins
146
in the plugin names string (see plug_add_default_page()).
147
ident == "id(plugs)": Remove the specified plugins from the plugin
148
names string (see plug_add_default_page()) and the observer,
149
if no dependent plugins in the plugin names string are left.
150
*********************************************************************/
151
void
plug_observ_data_remove
(
plugDefinition
*plug,
const
char
*ident);
152
153
/*
154
* Function interface:
155
* Store / Retrieve pointer to functions. Allows to call functions
156
* of other plugins. Please use the observer interface instead.
157
*/
158
159
/*********************************************************************
160
Register a function under the ID 'ident'. plug is the plugin from
161
where this function is called.
162
*********************************************************************/
163
void
plug_function_register
(
plugDefinition
*plug,
const
char
*ident,
164
plugFunc
func);
165
166
/*********************************************************************
167
Unregister a function registered with plug_function_register().
168
*********************************************************************/
169
void
plug_function_unregister
(
plugDefinition
*plug,
const
char
*ident);
170
171
/*********************************************************************
172
Get function stored under the ID 'ident'. If 'func'!=NULL the
173
function stored after 'func' under 'ident' is returned.
174
175
plug_name: Get function stored by a plugin by this name.
176
*********************************************************************/
177
plugDataFunc
*
plug_function_get
(
const
char
*ident,
plugDataFunc
*func);
178
plugDataFunc
*
plug_function_get_full
(
const
char
*ident,
plugDataFunc
*func,
179
const
char
*plug_name);
180
181
#ifdef __cplusplus
182
}
183
#endif
184
185
#endif
/* iw_plugin_comm_H */
Generated by
1.8.1