Lumiera  0.pre.03
»edit your freedom«
example-plugin.c
Go to the documentation of this file.
1 /*
2  ExamplePlugin - example plugin for testing the interface/plugin system
3 
4  Copyright (C) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
31 #include <stdio.h>
32 
35 
36 #include "interface/say-hello.h"
37 
38 
40 
41 LumieraInterface
42 myopen (LumieraInterface self, LumieraInterface interfaces)
43 {
44  LUMIERA_PLUGIN_STORE_INTERFACEHANDLE (interfaces);
45 
46  fprintf (stderr, "opened %p global interfaces %p\n", self, interfaces);
47  return self;
48 }
49 
50 void
51 myclose (LumieraInterface self)
52 {
53  fprintf (stderr, "closed %p\n", self);
54 }
55 
56 void hallo (void)
57 {
58  printf ("Hallo Welt!\n");
59 }
60 
61 void tschuess (const char* m)
62 {
63  printf ("Tschuess %s\n", m);
64 }
65 
66 void hello (void)
67 {
68  printf ("Hello World!\n");
69 }
70 
71 void bye (const char* m)
72 {
73  printf ("Bye %s\n", m);
74 }
75 
76 
77 void yeahbabe (void)
78 {
79  LUMIERA_INTERFACE_HANDLE (lumieraorg_testhello, 0) german =
80  LUMIERA_INTERFACE_OPEN (lumieraorg_testhello, 0, 0, lumieraorg_hello_german);
81 
82  LUMIERA_INTERFACE_HANDLE (lumieraorg_testhello, 0) english =
83  LUMIERA_INTERFACE_OPEN (lumieraorg_testhello, 0, 0, lumieraorg_hello_english);
84 
85  LUMIERA_INTERFACE_HANDLE (lumieraorg_configuration, 0) config =
86  LUMIERA_INTERFACE_OPEN (lumieraorg_configuration, 0, 0, lumieraorg_configuration);
87 
88  const char* path;
89  if (config->wordlist_get ("config.path", &path))
90  printf ("config path is: %s\n", path);
91  if (config->wordlist_get ("plugin.path", &path))
92  printf ("plugin path is: %s\n", path);
93 
94  LUMIERA_INTERFACE_CLOSE (config);
95 
96  german->hello ();
97  english->hello ();
98  english->goodbye ("World!");
99  german->goodbye ("Welt!");
100 
101  LUMIERA_INTERFACE_CLOSE (german);
102  LUMIERA_INTERFACE_CLOSE (english);
103 }
104 
105 
106 
107 LUMIERA_INTERFACE_INSTANCE (lumieraorg_interfacedescriptor, 0,
108  lumieraorg_exampleplugin_descriptor,
109  NULL, NULL, NULL,
110  LUMIERA_INTERFACE_INLINE (name,
111  const char*, (LumieraInterface iface),
112  {(void)iface; return "LumieraTest";}
113  ),
114  LUMIERA_INTERFACE_INLINE (brief,
115  const char*, (LumieraInterface iface),
116  {(void)iface; return "Lumiera Test suite examples";}
117  ),
118  LUMIERA_INTERFACE_INLINE (homepage,
119  const char*, (LumieraInterface iface),
120  {(void)iface; return "http://www.lumiera.org/develompent.html";}
121  ),
122  LUMIERA_INTERFACE_INLINE (version,
123  const char*, (LumieraInterface iface),
124  {(void)iface; return "No Version";}
125  ),
126  LUMIERA_INTERFACE_INLINE (author,
127  const char*, (LumieraInterface iface),
128  {(void)iface; return "Christian Thaeter";}
129  ),
130  LUMIERA_INTERFACE_INLINE (email,
131  const char*, (LumieraInterface iface),
132  {(void)iface; return "ct@pipapo.org";}
133  ),
134  LUMIERA_INTERFACE_INLINE (copyright,
135  const char*, (LumieraInterface iface),
136  {
137  (void)iface;
138  return
139  "Copyright (C) Lumiera.org\n"
140  " 2008 Christian Thaeter <ct@pipapo.org>";
141  }
142  ),
143  LUMIERA_INTERFACE_INLINE (license,
144  const char*, (LumieraInterface iface),
145  {
146  (void)iface;
147  return
148  "This program is free software; you can redistribute it and/or modify\n"
149  "it under the terms of the GNU General Public License as published by\n"
150  "the Free Software Foundation; either version 2 of the License, or\n"
151  "(at your option) any later version.\n"
152  "\n"
153  "This program is distributed in the hope that it will be useful,\n"
154  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
155  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
156  "GNU General Public License for more details.\n"
157  "\n"
158  "You should have received a copy of the GNU General Public License\n"
159  "along with this program; if not, write to the Free Software\n"
160  "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA";
161  }
162  ),
163 
164  LUMIERA_INTERFACE_INLINE (state,
165  int, (LumieraInterface iface),
166  {(void)iface; return LUMIERA_INTERFACE_EXPERIMENTAL;}
167  ),
168 
169  LUMIERA_INTERFACE_INLINE (versioncmp,
170  int, (const char* a, const char* b),
171  {(void)a;(void)b; return 0;}
172  )
173  );
174 
175 
177  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0,
178  lumieraorg_hello_german,
179  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
180  myopen,
181  myclose,
182  LUMIERA_INTERFACE_MAP (hello,
183  hallo),
184  LUMIERA_INTERFACE_MAP (goodbye,
185  tschuess)
186  ),
187  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0,
188  lumieraorg_hello_english,
189  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
190  myopen,
191  myclose,
192  LUMIERA_INTERFACE_MAP (hello,
193  hello),
194  LUMIERA_INTERFACE_MAP (goodbye,
195  bye)
196  ),
197  LUMIERA_INTERFACE_DEFINE (lumieraorg_testtest, 0,
198  lumieraorg_test_both,
199  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
200  myopen,
201  myclose,
202  LUMIERA_INTERFACE_MAP (testit,
203  yeahbabe)
204  )
205  )
LUMIERA_EXPORT(LUMIERA_INTERFACE_DEFINE(lumieraorg_interface, 0, lumieraorg_interface, NULL, NULL, NULL, LUMIERA_INTERFACE_MAP(open, lumiera_interface_open), LUMIERA_INTERFACE_MAP(close, lumiera_interface_close), LUMIERA_INTERFACE_MAP(version, lumiera_interface_version),))
Definition of &#39;the mother of all interfaces&#39; since this interface is singleton and required for any c...
Definition: interface.c:318
Not finished development code.
#define LUMIERA_INTERFACE_INSTANCE(iname, version, name, descriptor, acquire, release,...)
Define an interface instance.
Definition: interface.h:194
A mock interface to support testing of the interface system.
#define LUMIERA_INTERFACE_REF(iname, version, dname)
Return a reference (pointer) to an interface implementation.
Definition: interface.h:128
A data record to describe interface, interface instances and plug-in instances.
External interface to the lumiera configuration system.
#define LUMIERA_INTERFACE_HANDLE(interface, version)
create a handle for a interface (WIP)
Definition: interface.h:356
ElementBoxWidget::Config::Qualifier name(string id)
define the name-ID displayed in the caption
#define LUMIERA_PLUGIN_INTERFACEHANDLE
Create a plugin interface when being compiled as plugin.
Definition: interface.h:325