summaryrefslogtreecommitdiff
path: root/libmodman/module.hpp
diff options
context:
space:
mode:
authornpmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56>2010-02-05 06:52:13 +0000
committernpmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56>2010-02-05 06:52:13 +0000
commit25e1080dd5ae9ce82a33828d8acaaa4c61f44145 (patch)
tree2b46686d96490d0a8753c146183dee4c126d064b /libmodman/module.hpp
parentee59072c05c9a94556c3470a5a60571b84105781 (diff)
downloadlibproxy-25e1080dd5ae9ce82a33828d8acaaa4c61f44145.tar.gz
massive rework; split off libmodman; make unit tests for libmodman; remove config_wpad; remove config_file (both intenal and module); remove config ordering support; merge lukas' kde plugin rework
git-svn-id: http://libproxy.googlecode.com/svn/trunk@513 c587cffe-e639-0410-9787-d7902ae8ed56
Diffstat (limited to 'libmodman/module.hpp')
-rw-r--r--libmodman/module.hpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/libmodman/module.hpp b/libmodman/module.hpp
new file mode 100644
index 0000000..b48f17b
--- /dev/null
+++ b/libmodman/module.hpp
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * libmodman - A library for extending applications
+ * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ ******************************************************************************/
+
+#ifndef MODULE_HPP_
+#define MODULE_HPP_
+
+#include <typeinfo>
+#include <cstdlib>
+
+#ifdef WIN32
+#define DLL_PUBLIC __declspec(dllexport)
+#else
+#define DLL_PUBLIC __attribute__ ((visibility("default")))
+#endif
+
+#define MM_MODULE_VERSION 1
+#define MM_MODULE_NAME __module
+
+#define MM_MODULE_DEFINE DLL_PUBLIC struct com::googlecode::libmodman::module MM_MODULE_NAME[]
+#define MM_MODULE_LAST { MM_MODULE_VERSION, NULL, NULL, NULL, NULL }
+#define MM_MODULE_RECORD(type, init, test, symb) \
+ { MM_MODULE_VERSION, type::base_type(), init, test, symb }
+
+#define MM_MODULE_EZ(clsname, cond, symb) \
+ static bool clsname ## _test() { \
+ return (cond); \
+ } \
+ static com::googlecode::libmodman::base_extension** clsname ## _init() { \
+ com::googlecode::libmodman::base_extension** retval = new com::googlecode::libmodman::base_extension*[2]; \
+ retval[0] = new clsname(); \
+ retval[1] = NULL; \
+ return retval; \
+ } \
+ MM_MODULE_DEFINE = { \
+ MM_MODULE_RECORD(clsname, clsname ## _init, clsname ## _test, symb), \
+ MM_MODULE_LAST, \
+ };
+
+namespace com {
+namespace googlecode {
+namespace libmodman {
+
+class DLL_PUBLIC base_extension {
+public:
+ static const char* base_type() { return typeid(base_extension).name(); }
+ static bool singleton();
+
+ virtual ~base_extension();
+ virtual bool operator<(const base_extension&) const;
+};
+
+template <class T>
+class DLL_PUBLIC extension : public base_extension {
+public:
+ static const char* base_type() { return typeid(T).name(); }
+};
+
+struct module {
+ const unsigned int vers;
+ const char* const type;
+ base_extension** (*init)();
+ bool (*test)();
+ const char* const symb;
+};
+
+}
+}
+}
+
+#endif /* MODULE_HPP_ */