Lumiera  0.pre.03
»edityourfreedom«
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
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
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 */
119  , LUMIERA_INTERFACE_MAP (hello,
121  , LUMIERA_INTERFACE_MAP (goodbye,
123  ),
124  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0
125  ,lumieraorg_hello_english_cpp
126  , NULL /* no descriptor given */
129  , LUMIERA_INTERFACE_MAP (hello,
131  , LUMIERA_INTERFACE_MAP (goodbye,
133  )
134  );
135 
136 } // extern "C"
void hello(void)
static LumieraInterface myopen(LumieraInterface self, LumieraInterface interfaces)
Front-end for printf-style string template interpolation.
static void servus(const char *m)
A front-end for using printf-style formatting.
LUMIERA_EXPORT(LUMIERA_INTERFACE_DEFINE(lumieraorg_testhello, 0, lumieraorg_hello_german_cpp, NULL, ExamplePlugin::myopen, ExamplePlugin::myclose, LUMIERA_INTERFACE_MAP(hello, ExamplePlugin_de::griazi), LUMIERA_INTERFACE_MAP(goodbye, ExamplePlugin_de::servus)), LUMIERA_INTERFACE_DEFINE(lumieraorg_testhello, 0, lumieraorg_hello_english_cpp, NULL, ExamplePlugin::myopen, ExamplePlugin::myclose, LUMIERA_INTERFACE_MAP(hello, ExamplePlugin_en::hello), LUMIERA_INTERFACE_MAP(goodbye, ExamplePlugin_en::bye)))
static void griazi()
Lumiera interface macros and structures.
A mock interface to support testing of the interface system.
return NULL
Definition: llist.h:596
static void hello()
A data record to describe interface, interface instances and plug-in instances.
External interface to the lumiera configuration system.
static void myclose(LumieraInterface)
static void bye(const char *m)
lumiera_interface * LumieraInterface
Definition: interface.h:364