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)
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
22 #include <stdio.h>
23 
26 
27 #include "interface/say-hello.h"
28 
29 
31 
32 LumieraInterface
33 myopen (LumieraInterface self, LumieraInterface interfaces)
34 {
35  LUMIERA_PLUGIN_STORE_INTERFACEHANDLE (interfaces);
36 
37  fprintf (stderr, "opened %p global interfaces %p\n", self, interfaces);
38  return self;
39 }
40 
41 void
42 myclose (LumieraInterface self)
43 {
44  fprintf (stderr, "closed %p\n", self);
45 }
46 
47 void hallo (void)
48 {
49  printf ("Hallo Welt!\n");
50 }
51 
52 void tschuess (const char* m)
53 {
54  printf ("Tschuess %s\n", m);
55 }
56 
57 void hello (void)
58 {
59  printf ("Hello World!\n");
60 }
61 
62 void bye (const char* m)
63 {
64  printf ("Bye %s\n", m);
65 }
66 
67 
68 void yeahbabe (void)
69 {
70  LUMIERA_INTERFACE_HANDLE (lumieraorg_testhello, 0) german =
71  LUMIERA_INTERFACE_OPEN (lumieraorg_testhello, 0, 0, lumieraorg_hello_german);
72 
73  LUMIERA_INTERFACE_HANDLE (lumieraorg_testhello, 0) english =
74  LUMIERA_INTERFACE_OPEN (lumieraorg_testhello, 0, 0, lumieraorg_hello_english);
75 
76  LUMIERA_INTERFACE_HANDLE (lumieraorg_configuration, 0) config =
77  LUMIERA_INTERFACE_OPEN (lumieraorg_configuration, 0, 0, lumieraorg_configuration);
78 
79  const char* path;
80  if (config->wordlist_get ("config.path", &path))
81  printf ("config path is: %s\n", path);
82  if (config->wordlist_get ("plugin.path", &path))
83  printf ("plugin path is: %s\n", path);
84 
85  LUMIERA_INTERFACE_CLOSE (config);
86 
87  german->hello ();
88  english->hello ();
89  english->goodbye ("World!");
90  german->goodbye ("Welt!");
91 
92  LUMIERA_INTERFACE_CLOSE (german);
93  LUMIERA_INTERFACE_CLOSE (english);
94 }
95 
96 
97 
98 LUMIERA_INTERFACE_INSTANCE (lumieraorg_interfacedescriptor, 0,
99  lumieraorg_exampleplugin_descriptor,
100  NULL, NULL, NULL,
101  LUMIERA_INTERFACE_INLINE (name,
102  const char*, (LumieraInterface iface),
103  {(void)iface; return "LumieraTest";}
104  ),
105  LUMIERA_INTERFACE_INLINE (brief,
106  const char*, (LumieraInterface iface),
107  {(void)iface; return "Lumiera Test suite examples";}
108  ),
109  LUMIERA_INTERFACE_INLINE (homepage,
110  const char*, (LumieraInterface iface),
111  {(void)iface; return "http://www.lumiera.org/develompent.html";}
112  ),
113  LUMIERA_INTERFACE_INLINE (version,
114  const char*, (LumieraInterface iface),
115  {(void)iface; return "No Version";}
116  ),
117  LUMIERA_INTERFACE_INLINE (author,
118  const char*, (LumieraInterface iface),
119  {(void)iface; return "Christian Thaeter";}
120  ),
121  LUMIERA_INTERFACE_INLINE (email,
122  const char*, (LumieraInterface iface),
123  {(void)iface; return "ct@pipapo.org";}
124  ),
125  LUMIERA_INTERFACE_INLINE (copyright,
126  const char*, (LumieraInterface iface),
127  {
128  (void)iface;
129  return
130  "Copyright (C)\n"
131  " 2008, Christian Thaeter <ct@pipapo.org>";
132  }
133  ),
134  LUMIERA_INTERFACE_INLINE (license,
135  const char*, (LumieraInterface iface),
136  {
137  (void)iface;
138  return
139  "**Lumiera** is free software; you can redistribute it and/or modify it\n"
140  "under the terms of the GNU General Public License as published by the\n"
141  "Free Software Foundation; either version 2 of the License, or (at your\n"
142  "option) any later version. See the file COPYING for further details."
143  ;
144  }
145  ),
146 
147  LUMIERA_INTERFACE_INLINE (state,
148  int, (LumieraInterface iface),
149  {(void)iface; return LUMIERA_INTERFACE_EXPERIMENTAL;}
150  ),
151 
152  LUMIERA_INTERFACE_INLINE (versioncmp,
153  int, (const char* a, const char* b),
154  {(void)a;(void)b; return 0;}
155  )
156  );
157 
158 
160  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0,
161  lumieraorg_hello_german,
162  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
163  myopen,
164  myclose,
165  LUMIERA_INTERFACE_MAP (hello,
166  hallo),
167  LUMIERA_INTERFACE_MAP (goodbye,
168  tschuess)
169  ),
170  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0,
171  lumieraorg_hello_english,
172  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
173  myopen,
174  myclose,
175  LUMIERA_INTERFACE_MAP (hello,
176  hello),
177  LUMIERA_INTERFACE_MAP (goodbye,
178  bye)
179  ),
180  LUMIERA_INTERFACE_DEFINE (lumieraorg_testtest, 0,
181  lumieraorg_test_both,
182  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
183  myopen,
184  myclose,
185  LUMIERA_INTERFACE_MAP (testit,
186  yeahbabe)
187  )
188  )
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:309
Not finished development code.
#define LUMIERA_INTERFACE_INSTANCE(iname, version, name, descriptor, acquire, release,...)
Define an interface instance.
Definition: interface.h:185
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:119
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:347
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:316