summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/plugininterface.h30
-rw-r--r--src/plugins/pluginloader.cpp10
-rw-r--r--src/plugins/pluginloader.h41
-rw-r--r--src/plugins/pluginmanager.cpp4
-rw-r--r--src/plugins/pluginmanager.h51
5 files changed, 65 insertions, 71 deletions
diff --git a/src/plugins/plugininterface.h b/src/plugins/plugininterface.h
index 6554b44..838dbfd 100644
--- a/src/plugins/plugininterface.h
+++ b/src/plugins/plugininterface.h
@@ -14,17 +14,17 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// plugininterface.h
-
/**
- * @file plugin/plugininterface.h
- * @brief Generic plugin interface
+ * \file plugins/plugininterface.h
+ * \brief Generic plugin interface
*/
#pragma once
+
#include <string>
+
#define PLUGIN_INTERFACE(class_type) \
static class_type* Plugin##class_type; \
extern "C" void InstallPluginEntry() { Plugin##class_type = new class_type(); Plugin##class_type->InstallPlugin(); } \
@@ -37,29 +37,29 @@
/**
-* @class CPluginInterface
-*
-* @brief Generic plugin interface. All plugins that will be managed by plugin manager have to derive from this class.
-*
-*/
+ * \class CPluginInterface
+ *
+ * \brief Generic plugin interface. All plugins that will be managed by plugin manager have to derive from this class.
+ *
+ */
class CPluginInterface {
public:
/** Function to get plugin name or description
- * @return returns plugin name
+ * \return returns plugin name
*/
- inline virtual std::string PluginName() { return "abc"; };
+ inline virtual std::string PluginName() { return "abc"; }
/** Function to get plugin version. 1 means version 0.01, 2 means 0.02 etc.
- * @return number indicating plugin version
+ * \return number indicating plugin version
*/
- inline virtual int PluginVersion() { return 0; };
+ inline virtual int PluginVersion() { return 0; }
/** Function to initialize plugin
*/
- inline virtual void InstallPlugin() {};
+ inline virtual void InstallPlugin() {}
/** Function called before removing plugin
*/
- inline virtual bool UninstallPlugin(std::string &) { return true; };
+ inline virtual bool UninstallPlugin(std::string &) { return true; }
};
diff --git a/src/plugins/pluginloader.cpp b/src/plugins/pluginloader.cpp
index fd8ce74..bd0c8be 100644
--- a/src/plugins/pluginloader.cpp
+++ b/src/plugins/pluginloader.cpp
@@ -14,10 +14,8 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// pluginloader.cpp
-
-#include "pluginloader.h"
+#include "plugins/pluginloader.h"
CPluginLoader::CPluginLoader(std::string filename)
@@ -57,7 +55,7 @@ bool CPluginLoader::UnloadPlugin()
return true;
}
- bool (*uninstall)(std::string &) = (bool (*)(std::string &)) lt_dlsym(mHandle, "UninstallPluginEntry");
+ bool (*uninstall)(std::string &) = reinterpret_cast<bool (*)(std::string &)>( lt_dlsym(mHandle, "UninstallPluginEntry") );
if (!uninstall) {
GetLogger()->Error("Error getting UninstallPluginEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
return false;
@@ -88,13 +86,13 @@ bool CPluginLoader::LoadPlugin()
return false;
}
- void (*install)() = (void (*)()) lt_dlsym(mHandle, "InstallPluginEntry");
+ void (*install)() = reinterpret_cast<void (*)()>( lt_dlsym(mHandle, "InstallPluginEntry") );
if (!install) {
GetLogger()->Error("Error getting InstallPluginEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
return false;
}
- CPluginInterface* (*getInterface)() = (CPluginInterface* (*)()) lt_dlsym(mHandle, "GetPluginInterfaceEntry");
+ CPluginInterface* (*getInterface)() = reinterpret_cast<CPluginInterface* (*)()>( lt_dlsym(mHandle, "GetPluginInterfaceEntry") );
if (!getInterface) {
GetLogger()->Error("Error getting GetPluginInterfaceEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
diff --git a/src/plugins/pluginloader.h b/src/plugins/pluginloader.h
index 3dfa20b..e8c2c73 100644
--- a/src/plugins/pluginloader.h
+++ b/src/plugins/pluginloader.h
@@ -14,68 +14,67 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// pluginloader.h
-
/**
- * @file plugin/pluginloader.h
- * @brief Plugin loader interface
+ * \file plugins/pluginloader.h
+ * \brief Plugin loader interface
*/
#pragma once
-#include <ltdl.h>
-#include <string>
#include "common/logger.h"
-#include "plugininterface.h"
+#include "plugins/plugininterface.h"
+
+#include <ltdl.h>
+#include <string>
/**
-* @class CPluginLoader
-*
-* @brief Plugin loader interface. Plugin manager uses this class to load plugins.
-*
-*/
+ * \class CPluginLoader
+ *
+ * \brief Plugin loader interface. Plugin manager uses this class to load plugins.
+ *
+ */
class CPluginLoader {
public:
/** Class contructor
- * @param std::string plugin filename
+ * \param filename plugin filename
*/
- CPluginLoader(std::string);
+ CPluginLoader(std::string filename);
/** Function to get plugin name or description
- * @return returns plugin name
+ * \return returns plugin name
*/
std::string GetName();
/** Function to get plugin version
- * @return returns plugin version
+ * \return returns plugin version
*/
int GetVersion();
/** Function to unload plugin
- * @return returns true on success
+ * \return returns true on success
*/
bool UnloadPlugin();
/** Function to load plugin
- * @return returns true on success
+ * \return returns true on success
*/
bool LoadPlugin();
/** Function to check if plugin is loaded
- * @return returns true if plugin is loaded
+ * \return returns true if plugin is loaded
*/
bool IsLoaded();
/** Function to set plugin filename
- * @return returns true on success. Action can fail if plugin was loaded and cannot be unloaded
+ * \return returns true on success. Action can fail if plugin was loaded and cannot be unloaded
*/
bool SetFilename(std::string);
/** Function to get plugin filename
- * @return returns plugin filename
+ * \return returns plugin filename
*/
std::string GetFilename();
diff --git a/src/plugins/pluginmanager.cpp b/src/plugins/pluginmanager.cpp
index 39d1d17..f4dbcdb 100644
--- a/src/plugins/pluginmanager.cpp
+++ b/src/plugins/pluginmanager.cpp
@@ -14,10 +14,8 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// pluginmanager.cpp
-
-#include "pluginmanager.h"
+#include "plugins/pluginmanager.h"
template<> CPluginManager* CSingleton<CPluginManager>::mInstance = nullptr;
diff --git a/src/plugins/pluginmanager.h b/src/plugins/pluginmanager.h
index 7a69820..2798483 100644
--- a/src/plugins/pluginmanager.h
+++ b/src/plugins/pluginmanager.h
@@ -14,33 +14,32 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// pluginmanager.h
-
/**
- * @file plugin/pluginmanager.h
- * @brief Plugin manager class.
+ * \file plugins/pluginmanager.h
+ * \brief Plugin manager class.
*/
#pragma once
-#include <string>
-#include <set>
-#include <vector>
#include "common/logger.h"
#include "common/profile.h"
#include "common/singleton.h"
-#include "pluginloader.h"
+#include "plugins/pluginloader.h"
+
+#include <string>
+#include <set>
+#include <vector>
/**
-* @class CPluginManager
-*
-* @brief Plugin manager class. Plugin manager can load plugins from colobot.ini or manually specified files.
-*
-*/
+ * \class CPluginManager
+ *
+ * \brief Plugin manager class. Plugin manager can load plugins from colobot.ini or manually specified files.
+ *
+ */
class CPluginManager : public CSingleton<CPluginManager> {
public:
CPluginManager();
@@ -51,31 +50,31 @@ class CPluginManager : public CSingleton<CPluginManager> {
void LoadFromProfile();
/** Function loads specified plugin
- * @param std::string plugin filename
- * @return returns true on success
+ * \param filename plugin filename
+ * \return returns true on success
*/
- bool LoadPlugin(std::string);
+ bool LoadPlugin(std::string filename);
/** Function unloads specified plugin
- * @param std::string plugin filename
- * @return returns true on success
+ * \param filename plugin filename
+ * \return returns true on success
*/
- bool UnloadPlugin(std::string);
+ bool UnloadPlugin(std::string filename);
/** Function adds path to be checked when searching for plugin file. If path was already added it will be ignored
- * @param std::string plugin search path
- * @return returns true on success
+ * \param dir plugin search path
+ * \return returns true on success
*/
- bool AddSearchDirectory(std::string);
+ bool AddSearchDirectory(std::string dir);
/** Function removes path from list
- * @param std::string plugin search path
- * @return returns true on success
+ * \param dir plugin search path
+ * \return returns true on success
*/
- bool RemoveSearchDirectory(std::string);
+ bool RemoveSearchDirectory(std::string dir);
/** Function tries to unload all plugins
- * @return returns true on success
+ * \return returns true on success
*/
bool UnloadAllPlugins();