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) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>,
6  Hermann Vosseler <Ichthyostega@web.de>
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of
11  the License, or (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 
22 * *****************************************************/
23 
35 #include "lib/format-string.hpp"
36 
37 extern "C" {
38 #include "common/interface.h"
40 
41 #include "interface/say-hello.h"
42 }
43 
44 #include <iostream>
45 
46 using std::cout;
47 using std::endl;
48 
49 
50 
52  {
53  public:
54  static LumieraInterface
55  myopen (LumieraInterface self, LumieraInterface interfaces)
56  {
57  static util::_Fmt fmt("opened %x global interfaces %x");
58  cout << fmt % self % interfaces << endl;
59  return self;
60  }
61 
62  static void
63  myclose (LumieraInterface)
64  {
65  cout << "dying" << endl;
66  }
67  };
68 
69 
71  : public ExamplePlugin
72  {
73  public:
74  static void
75  griazi ()
76  {
77  cout << "Hallo Welt!" << endl;
78  }
79 
80  static void
81  servus (const char* m)
82  {
83  cout << "Tschüss " << m << endl;
84  }
85  };
86 
87 
89  : public ExamplePlugin
90  {
91  public:
92  static void
93  hello ()
94  {
95  cout << "Hello World!" << endl;
96  }
97 
98  static void
99  bye (const char* m)
100  {
101  cout << "Bye " << m << endl;
102  }
103  };
104 
105 
106 
107 
108 extern "C" { /* ================== define two lumieraorg_testhello instance ======================= */
109 
110 
111 
112  LUMIERA_EXPORT( /* ===================== PLUGIN EXPORTS ================================== */
113 
114  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0
115  ,lumieraorg_hello_german_cpp
116  , NULL /* no descriptor given */
117  , ExamplePlugin::myopen
118  , ExamplePlugin::myclose
119  , LUMIERA_INTERFACE_MAP (hello,
120  ExamplePlugin_de::griazi)
121  , LUMIERA_INTERFACE_MAP (goodbye,
122  ExamplePlugin_de::servus)
123  ),
124  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0
125  ,lumieraorg_hello_english_cpp
126  , NULL /* no descriptor given */
127  , ExamplePlugin::myopen
128  , ExamplePlugin::myclose
129  , LUMIERA_INTERFACE_MAP (hello,
130  ExamplePlugin_en::hello)
131  , LUMIERA_INTERFACE_MAP (goodbye,
132  ExamplePlugin_en::bye)
133  )
134  );
135 
136 } // 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:318
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.