LayerManagerService: updated IPlugin, PluginBase
authorTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Wed, 28 Nov 2012 10:15:25 +0000 (02:15 -0800)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Mon, 14 Jan 2013 08:34:16 +0000 (00:34 -0800)
all plugins are now required to provide their API type and version
as well as their name.

This allows loading all plugins using the same mechanism and detect
their type during runtime. The API version can be used to make sure,
that the LayerManagerService supports this verison of the plugin API.

The name of the plugin is used for logging.

Signed-off-by: Timo Lotterbach <timo.lotterbach@bmw-carit.de>
LayerManagerClient/ilmClient/include/ilm_types.h
LayerManagerService/include/IPlugin.h
LayerManagerService/include/PluginBase.h
LayerManagerService/src/Layermanager.cpp
LayerManagerService/src/PluginBase.cpp

index c847281..4713aff 100644 (file)
@@ -312,4 +312,32 @@ enum HealthCondition
     HealthDead
 };
 
+/**
+ * enum for identifying plugin types and versions
+ *
+ * All plugins are started in the order defined by their value
+ * in this enum (lowest first, highest last).
+ * The plugins are stopped in opposite order (highest first,
+ * lowest last).
+ */
+typedef enum PluginApi
+{
+    Renderer_Api            = 0x00010000,
+    Renderer_Api_v1,
+
+    SceneProvider_Api       = 0x00020000,
+    SceneProvider_Api_v1,
+
+    Communicator_Api        = 0x00040000,
+    Communicator_Api_v1,
+
+    HealthMonitor_Api       = 0x00080000,
+    HealthMonitor_Api_v1
+} ilmPluginApi;
+
+#define PLUGIN_IS_COMMUNICATOR(x)  ((x) & Communicator_Api)
+#define PLUGIN_IS_RENDERER(x)      ((x) & Renderer_Api)
+#define PLUGIN_IS_SCENEPROVIDER(x) ((x) & SceneProvider_Api)
+#define PLUGIN_IS_HEALTHMONITOR(x) ((x) & HealthMonitor_Api)
+
 #endif // _ILM_TYPES_H_
index ccc46ae..6d73e2e 100644 (file)
 class IPlugin
 {
 public:
-    virtual HealthCondition getHealth() = 0;
+    virtual PluginApi pluginGetApi() const = 0;
+    virtual t_ilm_const_string pluginGetName() const = 0;
+    virtual HealthCondition pluginGetHealth() = 0;
+
+    virtual ~IPlugin() {}
 };
 
 #endif // __IPLUGIN_H__
index e4d146f..21fb913 100644 (file)
 #define __PLUGINBASE_H__
 
 #include "IPlugin.h"
+#include "ilm_types.h"
+
+class ICommandExecutor;
+class Configuration;
 
 class PluginBase : public IPlugin
 {
 public:
-    PluginBase();
-    virtual HealthCondition getHealth();
+    PluginBase(ICommandExecutor& executor, Configuration& config, ilmPluginApi api);
+    virtual ~PluginBase();
+
+    // from IPlugin
+    virtual PluginApi pluginGetApi() const;
+    virtual t_ilm_const_string pluginGetName() const;
+    virtual HealthCondition pluginGetHealth();
+
+protected:
+    void pluginSetHealth(HealthCondition health);
 
 protected:
-    void setHealth(HealthCondition health);
+    ICommandExecutor& mExecutor;
+    Configuration& mConfiguration;
 
 private:
+    PluginApi mApi;
     HealthCondition mHealth;
 };
 
index 34cd2b1..3e31d6c 100644 (file)
@@ -551,7 +551,7 @@ HealthCondition Layermanager::getHealth()
     while ((iter != iterEnd) && (HealthRunning == returnValue))
     {
         IPlugin* monitoredPlugin = *iter;
-        returnValue = monitoredPlugin->getHealth();
+        returnValue = monitoredPlugin->pluginGetHealth();
         ++iter;
     }
 
index dd065ae..b16ed65 100644 (file)
 #include "ICommandExecutor.h"
 #include "Scene.h"
 
-PluginBase::PluginBase()
-: mHealth(HealthStopped)
+PluginBase::PluginBase(ICommandExecutor& executor, Configuration& config, ilmPluginApi api)
+: mExecutor(executor)
+, mConfiguration(config)
+, mApi(api)
+, mHealth(HealthStopped)
 {
 }
 
-HealthCondition PluginBase::getHealth()
+PluginBase::~PluginBase()
+{
+}
+
+PluginApi PluginBase::pluginGetApi() const
+{
+    return mApi;
+}
+
+t_ilm_const_string PluginBase::pluginGetName() const
+{
+    return "NoName";
+}
+
+HealthCondition PluginBase::pluginGetHealth()
 {
     return mHealth;
 }
 
-void PluginBase::setHealth(HealthCondition health)
+void PluginBase::pluginSetHealth(HealthCondition health)
 {
     mHealth = health;
 }