diff options
| author | Zdenek Prikryl <zprikryl@redhat.com> | 2009-03-19 14:29:35 +0100 |
|---|---|---|
| committer | Zdenek Prikryl <zprikryl@redhat.com> | 2009-03-19 14:29:35 +0100 |
| commit | d698cf9bca1ac7f5c1a989161ea959a895900273 (patch) | |
| tree | 1f63a97e9b7aa3eb50ccedc6afa26ecd69ed52d4 /lib/MiddleWare | |
| parent | 700d189946cecea3461cb89b5a755dbfdb578e71 (diff) | |
replaced language and application plugins by analyzer plugin
added action plugin
simplify plugin iface
Diffstat (limited to 'lib/MiddleWare')
| -rw-r--r-- | lib/MiddleWare/Action.h | 17 | ||||
| -rw-r--r-- | lib/MiddleWare/Analyzer.h | 12 | ||||
| -rw-r--r-- | lib/MiddleWare/CrashTypes.h | 1 | ||||
| -rw-r--r-- | lib/MiddleWare/Makefile.am | 6 | ||||
| -rw-r--r-- | lib/MiddleWare/MiddleWare.cpp | 90 | ||||
| -rw-r--r-- | lib/MiddleWare/MiddleWare.h | 18 | ||||
| -rw-r--r-- | lib/MiddleWare/Plugin.h | 23 | ||||
| -rw-r--r-- | lib/MiddleWare/PluginManager.cpp | 25 | ||||
| -rw-r--r-- | lib/MiddleWare/PluginManager.h | 8 |
9 files changed, 71 insertions, 129 deletions
diff --git a/lib/MiddleWare/Action.h b/lib/MiddleWare/Action.h index 8b1d7ec..9a2c2f1 100644 --- a/lib/MiddleWare/Action.h +++ b/lib/MiddleWare/Action.h @@ -1,5 +1,5 @@ /* - Application.h - header file for application plugin + Action.h - header file for action plugin Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) Copyright (C) 2009 RedHat inc. @@ -19,19 +19,18 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef APPLICATION_H_ -#define APPLICATION_H_ +#ifndef ACTION_H_ +#define ACTION_H_ #include <string> #include "Plugin.h" -class CApplication : public CPlugin +class CAction : public CPlugin { public: - virtual ~CApplication() {} - virtual std::string GetLocalUUID(const std::string& pDebugDumpPath) = 0; - virtual std::string GetGlobalUUID(const std::string& pDebugDumpPath) = 0; - virtual void CreateReport(const std::string& pDebugDumpPath) = 0; + virtual ~CAction() {} + virtual void Run(const std::string& pDebugDumpDir, + const std::string& pArgs) = 0; }; -#endif /*APPLICATION_H_*/ +#endif /*ACTION_H_*/ diff --git a/lib/MiddleWare/Analyzer.h b/lib/MiddleWare/Analyzer.h index 60e8275..dda976f 100644 --- a/lib/MiddleWare/Analyzer.h +++ b/lib/MiddleWare/Analyzer.h @@ -1,5 +1,5 @@ /* - Language.h - header file for language plugin + Analyzer.h - header file for analyzer plugin Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) Copyright (C) 2009 RedHat inc. @@ -19,19 +19,19 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef LANGUAGE_H_ -#define LANGUAGE_H_ +#ifndef ANALYZER_H_ +#define ANALYZER_H_ #include <string> #include "Plugin.h" -class CLanguage : public CPlugin +class CAnalyzer : public CPlugin { public: - virtual ~CLanguage() {} + virtual ~CAnalyzer() {} virtual std::string GetLocalUUID(const std::string& pDebugDumpPath) = 0; virtual std::string GetGlobalUUID(const std::string& pDebugDumpPath) = 0; virtual void CreateReport(const std::string& pDebugDumpPath) = 0; }; -#endif /*LANGUAGE_H_*/ +#endif /*ANALYZER_H_*/ diff --git a/lib/MiddleWare/CrashTypes.h b/lib/MiddleWare/CrashTypes.h index 07f1f02..f9fe625 100644 --- a/lib/MiddleWare/CrashTypes.h +++ b/lib/MiddleWare/CrashTypes.h @@ -3,6 +3,7 @@ #include <string> #include <map> +#include <vector> typedef std::map<std::string, std::string> map_crash_t; diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am index 27eda45..0a618a8 100644 --- a/lib/MiddleWare/Makefile.am +++ b/lib/MiddleWare/Makefile.am @@ -2,10 +2,10 @@ lib_LTLIBRARIES = libMiddleWare.la libMiddleWare_la_SOURCES = MiddleWare.cpp MiddleWare.h PluginManager.cpp \ PluginManager.h ABRTPlugin.cpp \ ABRTPlugin.h DynamicLibrary.cpp \ - DynamicLibrary.h Settings.h Settings.cpp \ + DynamicLibrary.h \ RPM.cpp RPM.h Plugin.h CrashTypes.h \ - MiddleWareTypes.h Application.h Database.h \ - Reporter.h Language.h + MiddleWareTypes.h Action.h Database.h \ + Reporter.h Analyzer.h libMiddleWare_la_LIBADD = $(DL_LIBS) ../Utils/libUtils.la $(RPM_LIBS) libMiddleWare_la_LDFLAGS = -version-info 0:1:0 libMiddleWare_la_CPPFLAGS = -I$(srcdir)/../Utils $(RPM_CFLAGS) diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp index 02bfc25..d1ee50f 100644 --- a/lib/MiddleWare/MiddleWare.cpp +++ b/lib/MiddleWare/MiddleWare.cpp @@ -147,46 +147,25 @@ void CMiddleWare::UnRegisterPlugin(const std::string& pName) } -std::string CMiddleWare::GetLocalUUIDLanguage(const std::string& pLanguage, - const std::string& pDebugDumpDir) +std::string CMiddleWare::GetLocalUUID(const std::string& pAnalyzer, + const std::string& pDebugDumpDir) { - CLanguage* language = m_pPluginManager->GetLanguage(pLanguage); - return language->GetLocalUUID(pDebugDumpDir); + CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer); + return analyzer->GetLocalUUID(pDebugDumpDir); } -std::string CMiddleWare::GetGlobalUUIDLanguage(const std::string& pLanguage, - const std::string& pDebugDumpDir) -{ - CLanguage* language = m_pPluginManager->GetLanguage(pLanguage); - return language->GetGlobalUUID(pDebugDumpDir); -} - -void CMiddleWare::CreateReportLanguage(const std::string& pLanguage, +std::string CMiddleWare::GetGlobalUUID(const std::string& pAnalyzer, const std::string& pDebugDumpDir) { - CLanguage* language = m_pPluginManager->GetLanguage(pLanguage); - return language->CreateReport(pDebugDumpDir); + CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer); + return analyzer->GetGlobalUUID(pDebugDumpDir); } -std::string CMiddleWare::GetLocalUUIDApplication(const std::string& pApplication, - const std::string& pDebugDumpDir) +void CMiddleWare::CreateReport(const std::string& pAnalyzer, + const std::string& pDebugDumpDir) { - CApplication* application = m_pPluginManager->GetApplication(pApplication); - return application->GetLocalUUID(pDebugDumpDir); -} - -std::string CMiddleWare::GetGlobalUUIDApplication(const std::string& pApplication, - const std::string& pDebugDumpDir) -{ - CApplication* application = m_pPluginManager->GetApplication(pApplication); - return application->GetGlobalUUID(pDebugDumpDir); -} - -void CMiddleWare::CreateReportApplication(const std::string& pApplication, - const std::string& pDebugDumpDir) -{ - CApplication* application = m_pPluginManager->GetApplication(pApplication); - return application->CreateReport(pDebugDumpDir); + CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer); + return analyzer->CreateReport(pDebugDumpDir); } void CMiddleWare::CreateReport(const std::string& pUUID, @@ -204,28 +183,21 @@ void CMiddleWare::CreateReport(const std::string& pUUID, throw std::string("CMiddleWare::CreateReport(): UUID '"+pUUID+"' is not in database."); } - std::string appLan; + std::string analyzer; std::string UUID; CDebugDump dd; dd.Open(row.m_sDebugDumpDir); - if (dd.Exist(FILENAME_APPLICATION)) - { - dd.LoadText(FILENAME_APPLICATION, appLan); - CreateReportApplication(appLan, row.m_sDebugDumpDir); - UUID = GetGlobalUUIDApplication(appLan, row.m_sDebugDumpDir); - } - if (dd.Exist(FILENAME_LANGUAGE)) - { - dd.LoadText(FILENAME_LANGUAGE, appLan); - CreateReportLanguage(appLan, row.m_sDebugDumpDir); - UUID = GetGlobalUUIDLanguage(appLan, row.m_sDebugDumpDir); - } + + dd.LoadText(FILENAME_ANALYZER, analyzer); + CreateReport(analyzer, row.m_sDebugDumpDir); + UUID = GetGlobalUUID(analyzer, row.m_sDebugDumpDir); + dd.SaveText(FILENAME_UUID, UUID); dd.Close(); DebugDump2Report(row.m_sDebugDumpDir, pCrashReport); - pCrashReport.m_sMWID = appLan + ";" + pUID + ";" + pUUID ; + pCrashReport.m_sMWID = analyzer + ";" + pUID + ";" + pUUID ; } void CMiddleWare::Report(const crash_report_t& pCrashReport) @@ -317,8 +289,7 @@ int CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pDebugDump dd.LoadText(FILENAME_EXECUTABLE, executable); if (executable == "kernel") { - package = "kernel"; - packageName = package; + packageName = package = "kernel"; } else { @@ -354,28 +325,15 @@ int CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pDebugDump int CMiddleWare::SaveUUIDToDebugDump(const std::string& pDebugDumpDir) { + std::string analyzer; std::string UUID; CDebugDump dd; dd.Open(pDebugDumpDir); - if (dd.Exist(FILENAME_APPLICATION)) - { - std::string application; - dd.LoadText(FILENAME_APPLICATION, application); - UUID = GetLocalUUIDApplication(application, pDebugDumpDir); - } - if (dd.Exist(FILENAME_LANGUAGE)) - { - std::string language; - dd.LoadText(FILENAME_LANGUAGE, language); - UUID = GetLocalUUIDLanguage(language, pDebugDumpDir); - } - if (UUID == "") - { - dd.Delete(); - dd.Close(); - return 0; - } + + dd.LoadText(FILENAME_ANALYZER, analyzer); + UUID = GetLocalUUID(analyzer, pDebugDumpDir); + dd.SaveText(FILENAME_UUID, UUID); dd.Close(); diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h index 6c94311..def29ce 100644 --- a/lib/MiddleWare/MiddleWare.h +++ b/lib/MiddleWare/MiddleWare.h @@ -48,18 +48,12 @@ class CMiddleWare bool m_bOpenGPGCheck; - std::string GetLocalUUIDLanguage(const std::string& pLanguage, - const std::string& pDebugDumpDir); - std::string GetGlobalUUIDLanguage(const std::string& pLanguage, - const std::string& pDebugDumpDir); - void CreateReportLanguage(const std::string& pLanguage, - const std::string& pDebugDumpDir); - std::string GetLocalUUIDApplication(const std::string& pApplication, - const std::string& pDebugDumpDir); - std::string GetGlobalUUIDApplication(const std::string& pApplication, - const std::string& pDebugDumpDir); - void CreateReportApplication(const std::string& pApplication, - const std::string& pDebugDumpDir); + std::string GetLocalUUID(const std::string& pAnalyzer, + const std::string& pDebugDumpDir); + std::string GetGlobalUUID(const std::string& pAnalyzer, + const std::string& pDebugDumpDir); + void CreateReport(const std::string& pAnalyzer, + const std::string& pDebugDumpDir); void LoadSettings(const std::string& pPath); diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h index 014733d..e4ebc3c 100644 --- a/lib/MiddleWare/Plugin.h +++ b/lib/MiddleWare/Plugin.h @@ -25,7 +25,6 @@ #include <string> #include <map> -#include "Settings.h" #define PLUGINS_MAGIC_NUMBER 1 @@ -38,13 +37,13 @@ class CPlugin public: virtual ~CPlugin() {} - virtual void Init() = 0; - virtual void DeInit() = 0; - virtual void SetSettings(const map_settings_t& pSettings) = 0; + virtual void Init() {} + virtual void DeInit() {} + virtual void LoadSettings(const std::string& pPath) {} }; -typedef enum { LANGUAGE, REPORTER, APPLICATION, DATABASE } plugin_type_t; -const char* const plugin_type_str_t[] = {"Language", "Reporter", "Application", "Database"}; +typedef enum { ANALYZER, ACTION, REPORTER, DATABASE } plugin_type_t; +const char* const plugin_type_str_t[] = {"Analyzer", "Action", "Reporter", "Database"}; typedef struct SPluginInfo { @@ -59,19 +58,11 @@ typedef struct SPluginInfo #define PLUGIN_IFACE extern "C" -#define PLUGIN_INIT(plugin_class)\ +#define PLUGIN_INFO(type, plugin_class, name, version, description, email, www)\ PLUGIN_IFACE CPlugin* plugin_new()\ {\ - plugin_class* plugin = new plugin_class();\ - if (plugin == NULL)\ - {\ - throw std::string("Not enought memory");\ - }\ - return plugin;\ + return new plugin_class();\ }\ - - -#define PLUGIN_INFO(type, name, version, description, email, www)\ PLUGIN_IFACE const plugin_info_t plugin_info =\ {\ type,\ diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp index e0def74..03e636c 100644 --- a/lib/MiddleWare/PluginManager.cpp +++ b/lib/MiddleWare/PluginManager.cpp @@ -79,7 +79,7 @@ void CPluginManager::LoadPlugin(const std::string& pName) std::string libPath = m_sPlugisLibDir + "/" + PLUGINS_LIB_PREFIX + pName + "." + PLUGINS_LIB_EXTENSION; abrtPlugin = new CABRTPlugin(libPath); if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER || - (abrtPlugin->GetType() < LANGUAGE && abrtPlugin->GetType() > DATABASE)) + (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE)) { throw std::string("non-compatible plugin"); } @@ -117,10 +117,9 @@ void CPluginManager::RegisterPlugin(const std::string& pName) { map_settings_t settings; std::string path = m_sPlugisConfDir + "/" + pName + "." + PLUGINS_CONF_EXTENSION; - load_settings(path, settings); CPlugin* plugin = m_mapABRTPlugins[pName]->PluginNew(); plugin->Init(); - plugin->SetSettings(settings); + plugin->LoadSettings(path); m_mapPlugins[pName] = plugin; std::cerr << "Registred plugin " << pName << "(" << plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()] @@ -145,14 +144,14 @@ void CPluginManager::UnRegisterPlugin(const std::string& pName) } } -CLanguage* CPluginManager::GetLanguage(const std::string& pName) +CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName) { if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { - throw std::string("CPluginManager::GetLanguage():" - "Language plugin: '"+pName+"' is not loaded."); + throw std::string("CPluginManager::GetAnalyzer():" + "Analyzer plugin: '"+pName+"' is not loaded."); } - return (CLanguage*) m_mapPlugins[pName]; + return dynamic_cast<CAnalyzer*>(m_mapPlugins[pName]); } CReporter* CPluginManager::GetReporter(const std::string& pName) @@ -162,17 +161,17 @@ CReporter* CPluginManager::GetReporter(const std::string& pName) throw std::string("CPluginManager::GetReporter():" "Reporter plugin: '"+pName+"' is not loaded."); } - return (CReporter*) m_mapPlugins[pName]; + return dynamic_cast<CReporter*>(m_mapPlugins[pName]); } -CApplication* CPluginManager::GetApplication(const std::string& pName) +CAction* CPluginManager::GetAction(const std::string& pName) { if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { - throw std::string("CPluginManager::GetApplication():" - "Application plugin: '"+pName+"' is not loaded."); + throw std::string("CPluginManager::GetAction():" + "Action plugin: '"+pName+"' is not loaded."); } - return (CApplication*) m_mapPlugins[pName]; + return dynamic_cast<CAction*>(m_mapPlugins[pName]); } CDatabase* CPluginManager::GetDatabase(const std::string& pName) @@ -182,6 +181,6 @@ CDatabase* CPluginManager::GetDatabase(const std::string& pName) throw std::string("CPluginManager::GetDatabase():" "Database plugin: '"+pName+"' is not loaded."); } - return (CDatabase*) m_mapPlugins[pName]; + return dynamic_cast<CDatabase*>(m_mapPlugins[pName]); } diff --git a/lib/MiddleWare/PluginManager.h b/lib/MiddleWare/PluginManager.h index 9f5979a..8ef5991 100644 --- a/lib/MiddleWare/PluginManager.h +++ b/lib/MiddleWare/PluginManager.h @@ -27,10 +27,10 @@ #include <string> #include "ABRTPlugin.h" #include "Plugin.h" -#include "Language.h" +#include "Analyzer.h" #include "Reporter.h" #include "Database.h" -#include "Application.h" +#include "Action.h" class CPluginManager { @@ -59,9 +59,9 @@ class CPluginManager void RegisterPlugin(const std::string& pName); void UnRegisterPlugin(const std::string& pName); - CLanguage* GetLanguage(const std::string& pName); + CAnalyzer* GetAnalyzer(const std::string& pName); CReporter* GetReporter(const std::string& pName); - CApplication* GetApplication(const std::string& pName); + CAction* GetAction(const std::string& pName); CDatabase* GetDatabase(const std::string& pName); }; |
