Lumiera  0.pre.03
»edit your freedom«
example-plugin.cpp
Go to the documentation of this file.
1 /*
2  ExamplePlugin - example plugin (C++) for testing the interface/plugin system
3 
4  Copyright (C)
5  2008, Christian Thaeter <ct@pipapo.org>,
6  Hermann Vosseler <Ichthyostega@web.de>
7 
8   **Lumiera** is free software; you can redistribute it and/or modify it
9   under the terms of the GNU General Public License as published by the
10   Free Software Foundation; either version 2 of the License, or (at your
11   option) any later version. See the file COPYING for further details.
12 
13 * *****************************************************************/
14 
26 #include "lib/format-string.hpp"
27 
28 extern "C" {
29 #include "common/interface.h"
31 
32 #include "interface/say-hello.h"
33 }
34 
35 #include <iostream>
36 
37 using std::cout;
38 using std::endl;
39 
40 
41 
43  {
44  public:
45  static LumieraInterface
46  myopen (LumieraInterface self, LumieraInterface interfaces)
47  {
48  static util::_Fmt fmt("opened %x global interfaces %x");
49  cout << fmt % self % interfaces << endl;
50  return self;
51  }
52 
53  static void
54  myclose (LumieraInterface)
55  {
56  cout << "dying" << endl;
57  }
58  };
59 
60 
62  : public ExamplePlugin
63  {
64  public:
65  static void
66  griazi ()
67  {
68  cout << "Hallo Welt!" << endl;
69  }
70 
71  static void
72  servus (const char* m)
73  {
74  cout << "Tschüss " << m << endl;
75  }
76  };
77 
78 
80  : public ExamplePlugin
81  {
82  public:
83  static void
84  hello ()
85  {
86  cout << "Hello World!" << endl;
87  }
88 
89  static void
90  bye (const char* m)
91  {
92  cout << "Bye " << m << endl;
93  }
94  };
95 
96 
97 
98 
99 extern "C" { /* ================== define two lumieraorg_testhello instance ======================= */
100 
101 
102 
103  LUMIERA_EXPORT( /* ===================== PLUGIN EXPORTS ================================== */
104 
105  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0
106  ,lumieraorg_hello_german_cpp
107  , NULL /* no descriptor given */
108  , ExamplePlugin::myopen
109  , ExamplePlugin::myclose
110  , LUMIERA_INTERFACE_MAP (hello,
111  ExamplePlugin_de::griazi)
112  , LUMIERA_INTERFACE_MAP (goodbye,
113  ExamplePlugin_de::servus)
114  ),
115  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0
116  ,lumieraorg_hello_english_cpp
117  , NULL /* no descriptor given */
118  , ExamplePlugin::myopen
119  , ExamplePlugin::myclose
120  , LUMIERA_INTERFACE_MAP (hello,
121  ExamplePlugin_en::hello)
122  , LUMIERA_INTERFACE_MAP (goodbye,
123  ExamplePlugin_en::bye)
124  )
125  );
126 
127 } // extern "C"
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
Front-end for printf-style string template interpolation.
A front-end for using printf-style formatting.
Lumiera interface macros and structures.
A mock interface to support testing of the interface system.
A data record to describe interface, interface instances and plug-in instances.
External interface to the lumiera configuration system.