summaryrefslogtreecommitdiffstats
path: root/include/pils/interface.h
blob: 5a5114e84bb8d3a7008015c9bddd00bd8bd6bd28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * Copyright (C) 2000 Alan Robertson <alanr@unix.sh>
 * This software licensed under the GNU LGPL.
 *
 *
 * 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.1 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
 *
 */
#ifndef PILS_INTERFACE_H
#  define PILS_INTERFACE_H
#  ifndef PILS_PLUGIN_H
#    include <pils/plugin.h>
#  endif

/*****************************************************************************
 *
 * The most basic interface type is the "IFManager" interface.
 * Each interface manager registers and deals with interfaces of a given type.
 *
 * Such an interface must be loaded before any plugins of it's type can
 * be loaded.
 *
 * In order to register any plugin of type "foo", we must load a interface of
 * type "Interface" named "foo".  This interface then manages the
 * registration of all interfaces of type foo.
 *
 * To bootstrap, we load a interface of type "Interface" named "Interface"
 * during the initialization of the plugin system.
 *
 * IFManagers will be autoloaded if certain conditions are met...
 *
 * If a IFManager is to be autoloaded, there must be one interface manager
 * per file, and the file must be named according to the type of the
 * interface it implements, and loaded in the directory named PI_IFMANAGER
 * ("Interface").
 *
 */


/*
 *	I'm unsure exactly which of the following structures
 *	are needed to write a interface, or a interface manager.
 *	We'll get that figured out and scope the defintions accordingly...
 */

/*
 *	PILInterface (AKA struct PILInterface_s) holds the information
 *	we use to track a single interface manager.
 */


struct PILInterface_s {
	unsigned long		MagicNum;	
	PILInterfaceType*	interfacetype;	/* Parent pointer	*/
	char *			interfacename;	/* malloced interface name */
	PILInterface*		ifmanager;	/* plugin managing us	*/
	void*			exports;	/* Exported Functions	*/
						/* for this interface	*/
	PILInterfaceFun		if_close;	/* Interface close operation*/
	void*			ud_interface;	/* per-interface user data */
	int			refcnt;		/* Ref count for plugin	*/
	PILPlugin*		loadingpi;	/* Plugin that loaded us */
};
/*
 *	PILInterfaceType (AKA struct PILInterfaceType_s) holds the info
 *	we use to track the set of all interfaces of a single kind.
 */
struct PILInterfaceType_s {
	unsigned long		MagicNum;	
	char*			typename;	/* Our interface type name */
	GHashTable*		interfaces;	/* The set of interfaces
						 * of our type.  The
						 * "values" are all
						 * PILInterface * objects
						 */
	void*			ud_if_type;	/* per-interface-type user
						   data*/
	PILInterfaceUniv*	universe;	/* Pointer to parent (up) */
	PILInterface*		ifmgr_ref;	/* Pointer to our interface
						   manager */
};

/*
 *	PILInterfaceUniv (AKA struct PILInterfaceUniv_s) holds the information
 *	for all interfaces of all types.  From our point of view this is
 *	our universe ;-)
 */

struct PILInterfaceUniv_s{
	unsigned long		MagicNum;	
	GHashTable*		iftypes;	/*
						 * Set of Interface Types
						 * The values are all
						 * PILInterfaceType objects
						 */
	struct PILPluginUniv_s*	piuniv;		/* parallel universe of
						 * plugins
						 */
};

#ifdef ENABLE_PLUGIN_MANAGER_PRIVATE
/*
 * From here to the end is specific to interface managers.
 * This data is only needed by interface managers, and the interface
 * management system itself.
 *
 */
typedef struct PILInterfaceOps_s		PILInterfaceOps;


/* Interfaces imported by a IFManager interface */
struct PILInterfaceImports_s {

		/* Return current reference count */
	int (*RefCount)(PILInterface * eifinfo);

		/* Incr/Decr reference count */
	int (*ModRefCount)(PILInterface*eifinfo, int plusminus);

		/* Unregister us as a interface */
	void (*ForceUnRegister)(PILInterface *eifinfo);

		/* For each client */
	void (*ForEachClientDel)(PILInterface* manangerif
	,	gboolean(*f)(PILInterface* clientif, void * other)
	,	void* other);

};

/* Interfaces exported by an InterfaceManager interface */
struct PILInterfaceOps_s{
/*
 *	These are the interfaces exported by an InterfaceManager to the
 *	interface management infrastructure.  These are not imported
 *	by interfaces - only the interface management infrastructure.
 */

	/* RegisterInterface - register this interface */
 	PIL_rc (*RegisterInterface)(PILInterface* newif
		,	void**	imports);

	PIL_rc	(*UnRegisterInterface)(PILInterface*ifinfo); /* Unregister IF*/
				/* And destroy PILInterface object */
};

#endif /* ENABLE_PLUGIN_MANAGER_PRIVATE */
#endif /* PILS_INTERFACE_H */