From 0f595e076f03c02b366901e8d3c5cc0c50681108 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Tue, 23 Aug 2016 02:46:27 +0200 Subject: generic plugin manager example, fully working --- plugins/plugin.hpp | 39 +++++++++++++++++++++++++++++++++++++++ plugins/plugin_test1.cpp | 35 +++++++++++++++++++++++++++++++++++ plugins/plugin_test1.hpp | 33 +++++++++++++++++++++++++++++++++ plugins/plugin_test2.cpp | 24 ++++++++++++++++++++++++ plugins/plugin_test2.hpp | 34 ++++++++++++++++++++++++++++++++++ plugins/plugin_test3.cpp | 24 ++++++++++++++++++++++++ plugins/plugin_test3.hpp | 34 ++++++++++++++++++++++++++++++++++ 7 files changed, 223 insertions(+) create mode 100644 plugins/plugin.hpp create mode 100644 plugins/plugin_test1.cpp create mode 100644 plugins/plugin_test1.hpp create mode 100644 plugins/plugin_test2.cpp create mode 100644 plugins/plugin_test2.hpp create mode 100644 plugins/plugin_test3.cpp create mode 100644 plugins/plugin_test3.hpp (limited to 'plugins') diff --git a/plugins/plugin.hpp b/plugins/plugin.hpp new file mode 100644 index 0000000..9a354c2 --- /dev/null +++ b/plugins/plugin.hpp @@ -0,0 +1,39 @@ +/* + * plugin.hpp + * + * Copyright 2009 Max Christian Pohle + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef PLUGIN_HPP +#define PLUGIN_HPP + #include + #include + #include + #include + + using namespace std; + class Plugin + { + private: + int version; + public: + //Plugin() : version(0) + virtual const int get_version() = 0; + virtual void dosomething() = 0; + }; +#endif diff --git a/plugins/plugin_test1.cpp b/plugins/plugin_test1.cpp new file mode 100644 index 0000000..e02612c --- /dev/null +++ b/plugins/plugin_test1.cpp @@ -0,0 +1,35 @@ +/* + * plugin_test1.hpp + * + * Copyright 2009 Max Christian Pohle + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include "plugin_test1.hpp" + +plugin_test::plugin_test() +{ std::cout << "constructor of plugin I.\n"; } + +void plugin_test::dosomething() +{ std::cout << "teste dosomething in plugin I.\n"; } + +const int plugin_test::get_version() +{ return VERSION; } + +// the class factories +extern "C" plugin_test* create() +{ return new plugin_test; } + diff --git a/plugins/plugin_test1.hpp b/plugins/plugin_test1.hpp new file mode 100644 index 0000000..ec7597d --- /dev/null +++ b/plugins/plugin_test1.hpp @@ -0,0 +1,33 @@ +/* + * plugin_test1.hpp + * + * Copyright 2009 Max Christian Pohle + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#ifndef PLUGIN_TEST1_HPP +#define PLUGIN_TEST1_HPP + +#include "plugin.hpp" +#define VERSION 3 +class plugin_test : public Plugin +{ + public: + plugin_test(); + const int get_version(); + virtual void dosomething(); +}; +#endif diff --git a/plugins/plugin_test2.cpp b/plugins/plugin_test2.cpp new file mode 100644 index 0000000..1dbbf7b --- /dev/null +++ b/plugins/plugin_test2.cpp @@ -0,0 +1,24 @@ +/* + * plugin_test2.cpp + * + * Copyright 2009 Max Christian Pohle + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include "plugin_test2.hpp" + +void plugin_test::dosomething() +{ std::cout << "teste dosomething in plugin II.\n"; } diff --git a/plugins/plugin_test2.hpp b/plugins/plugin_test2.hpp new file mode 100644 index 0000000..1291b18 --- /dev/null +++ b/plugins/plugin_test2.hpp @@ -0,0 +1,34 @@ +/* + * plugin_test2.hpp + * + * Copyright 2009 Max Christian Pohle + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include "plugin.hpp" +#define VERSION 2 +class plugin_test : public Plugin +{ + public: + plugin_test() + { std::cout << "Das ist plugin nummer II.\n"; } + const int get_version() + { return VERSION; } + void dosomething(); +}; + +extern "C" Plugin* create() +{ return new plugin_test(); } diff --git a/plugins/plugin_test3.cpp b/plugins/plugin_test3.cpp new file mode 100644 index 0000000..39c4988 --- /dev/null +++ b/plugins/plugin_test3.cpp @@ -0,0 +1,24 @@ +/* + * plugin_test3.cpp + * + * Copyright 2009 Max Christian Pohle + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include "plugin_test3.hpp" + +void plugin_test::dosomething() +{ std::cout << "teste dosomething in plugin III.\n"; } diff --git a/plugins/plugin_test3.hpp b/plugins/plugin_test3.hpp new file mode 100644 index 0000000..a057d8f --- /dev/null +++ b/plugins/plugin_test3.hpp @@ -0,0 +1,34 @@ +/* + * plugin_test3.hpp + * + * Copyright 2009 Max Christian Pohle + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include "plugin.hpp" +#define VERSION 1 +class plugin_test : public Plugin +{ + public: + plugin_test() + { std::cout << "Das ist plugin nummer III.\n"; } + const int get_version() + { return VERSION; } + void dosomething(); +}; + +extern "C" Plugin* create() +{ return new plugin_test(); } -- cgit v1.2.3