diff modules/dynlib/doc/mainpage.cpp @ 518:78f296a7b2e5

Dynlib: resurrection
author David Demelier <markand@malikania.fr>
date Wed, 01 Jun 2016 16:26:20 +0200
parents
children f48bb09bccc7
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/dynlib/doc/mainpage.cpp	Wed Jun 01 16:26:20 2016 +0200
@@ -0,0 +1,63 @@
+/**
+ * \mainpage
+ *
+ * Welcome to the dynlib library.
+ *
+ * ## Introduction
+ * 
+ * Opening shared libraries from C++ (e.g for plugins) is platform specific, with that class, you can open them very
+ * easily.
+ *
+ * ## Installation
+ *
+ * Just copy the file dynlib.hpp and add it to your project.
+ *
+ * ## Overview
+ *
+ * This one minute tutorial shows how to load a shared library named `plugin.so` and execute a C function `say_hello`.
+ *
+ * ### Main
+ *
+ * This is the main executable that loads the `plugin.so` file.
+ * 
+ * ````cpp
+ * #include <iostream>
+ * 
+ * #include "dynlib.hpp"
+ * 
+ * using HelloFunc = void (*)(const std::string &);
+ * 
+ * int main()
+ * {
+ *	try {
+ *		Dynlib library("./plugin.so");
+ *
+ *		HelloFunc hello = library.sym<HelloFunc>("say_hello");
+ *		hello("Test");
+ *	} catch (const std::exception &error) {
+ *		std::cerr << error.what() << std::endl;
+ *	}
+ *
+ *	return 0;
+ * }
+ * ````
+ *
+ * ### Plugin
+ *
+ * This is the plugin that you compile as a shared library.
+ *
+ * For example with gcc: `gcc -fPIC -shared plugin.cpp -o plugin.so`.
+ *
+ * ````cpp
+ * #include <iostream>
+ *
+ * #include "dynlib.hpp"
+ *
+ * extern "C" {
+ *
+ * DYNLIB_EXPORT void say_hello()
+ * {
+ *	std::cout << "Hello from the plugin!" << std::endl;
+ * }
+ * ````
+ */