diff options
Diffstat (limited to 'lib/CommLayer')
| -rw-r--r-- | lib/CommLayer/CommLayerInner.cpp | 29 | ||||
| -rw-r--r-- | lib/CommLayer/CommLayerInner.h | 101 | ||||
| -rw-r--r-- | lib/CommLayer/Observer.h | 9 |
3 files changed, 18 insertions, 121 deletions
diff --git a/lib/CommLayer/CommLayerInner.cpp b/lib/CommLayer/CommLayerInner.cpp index 33e0909..71b26aa 100644 --- a/lib/CommLayer/CommLayerInner.cpp +++ b/lib/CommLayer/CommLayerInner.cpp @@ -1,44 +1,35 @@ #include "CommLayerInner.h" -CCommLayerInner* g_pCommLayerInner = NULL; +static CObserver *g_pObs = NULL; -void comm_layer_inner_init(CCommLayerInner *pCommLayerInner) +void comm_layer_inner_init(CObserver *pObs) { - if (!g_pCommLayerInner) + if (!g_pObs) { - g_pCommLayerInner = pCommLayerInner; + g_pObs = pObs; } } void comm_layer_inner_debug(const std::string& pMessage) { - if (g_pCommLayerInner) + if (g_pObs) { - if (g_pCommLayerInner->GetDebugCommLayer()) - { - g_pCommLayerInner->GetDebugCommLayer()->Message(pMessage); - } + g_pObs->Debug(pMessage); } } void comm_layer_inner_warning(const std::string& pMessage) { - if (g_pCommLayerInner) + if (g_pObs) { - if (g_pCommLayerInner->GetWarningCommLayer()) - { - g_pCommLayerInner->GetWarningCommLayer()->Message(pMessage); - } + g_pObs->Warning(pMessage); } } void comm_layer_inner_status(const std::string& pMessage) { - if (g_pCommLayerInner) + if (g_pObs) { - if (g_pCommLayerInner->GetStatusCommLayer()) - { - g_pCommLayerInner->GetStatusCommLayer()->Message(pMessage); - } + g_pObs->Status(pMessage); } } diff --git a/lib/CommLayer/CommLayerInner.h b/lib/CommLayer/CommLayerInner.h index f4b1ac2..491c161 100644 --- a/lib/CommLayer/CommLayerInner.h +++ b/lib/CommLayer/CommLayerInner.h @@ -1,108 +1,9 @@ #ifndef COMMLAYERINNER_H_ #define COMMLAYERINNER_H_ -#include <iostream> #include "Observer.h" -class CDebugCommLayer -{ - private: - CObserver *m_pObserver; - public: - CDebugCommLayer(CObserver *pObs) : - m_pObserver(pObs) - {} - void Message(const std::string& pMsg) - { - if(m_pObserver) - { - m_pObserver->Debug(pMsg); - } - } -}; - -class CWarningCommLayer -{ - private: - CObserver *m_pObserver; - public: - CWarningCommLayer(CObserver *pObs) : - m_pObserver(pObs) - {} - void Message(const std::string& pMsg) - { - if(m_pObserver) - { - m_pObserver->Warning(pMsg); - } - } -}; - -class CStatusCommLayer -{ - private: - CObserver *m_pObserver; - public: - CStatusCommLayer(CObserver *pObs) : - m_pObserver(pObs) - {} - void Message(const std::string& pMsg) - { - if(m_pObserver) - { - m_pObserver->Status(pMsg); - } - } -}; - -class CCommLayerInner -{ - private: - CDebugCommLayer* m_pDebugCommLayer; - CWarningCommLayer* m_pWarningCommLayer; - CStatusCommLayer* m_pStatusCommLayer; - public: - CDebugCommLayer* GetDebugCommLayer() - { - return m_pDebugCommLayer; - } - CWarningCommLayer* GetWarningCommLayer() - { - return m_pWarningCommLayer; - } - CStatusCommLayer* GetStatusCommLayer() - { - return m_pStatusCommLayer; - } - CCommLayerInner(CObserver *pObs, bool pDebug, bool pWarning) - { - m_pDebugCommLayer = NULL; - m_pWarningCommLayer = NULL; - if (pDebug) - { - m_pDebugCommLayer = new CDebugCommLayer(pObs); - } - if (pWarning) - { - m_pWarningCommLayer = new CWarningCommLayer(pObs); - } - m_pStatusCommLayer = new CStatusCommLayer(pObs); - } - ~CCommLayerInner() - { - if (m_pDebugCommLayer) - { - delete m_pDebugCommLayer; - } - if (m_pWarningCommLayer) - { - delete m_pWarningCommLayer; - } - delete m_pStatusCommLayer; - } -}; - -void comm_layer_inner_init(CCommLayerInner *pCommLayerInner); +void comm_layer_inner_init(CObserver *pObs); void comm_layer_inner_debug(const std::string& pMessage); void comm_layer_inner_warning(const std::string& pMessage); void comm_layer_inner_status(const std::string& pMessage); diff --git a/lib/CommLayer/Observer.h b/lib/CommLayer/Observer.h index 81e7695..42fd147 100644 --- a/lib/CommLayer/Observer.h +++ b/lib/CommLayer/Observer.h @@ -4,6 +4,7 @@ //FIXME: move all common types to AbrtTypes.h ?? #include "DBusCommon.h" #include <string> +#include <iostream> #include <stdint.h> class CObserver { @@ -13,10 +14,14 @@ class CObserver { virtual void Status(const std::string& pMessage, const std::string& pDest="0") = 0; virtual void Debug(const std::string& pMessage, const std::string& pDest="0") = 0; virtual void Warning(const std::string& pMessage, const std::string& pDest="0") = 0; -/* this should be implemented in daemon */ + /* this should be implemented in daemon */ virtual vector_crash_infos_t GetCrashInfos(const std::string &pSender) = 0; virtual map_crash_report_t CreateReport(const std::string &pUUID,const std::string &pSender) = 0; - virtual uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender){std::cout << "DEFAULT OBSERVER";return 0;}; + virtual uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender) + { + std::cout << "DEFAULT OBSERVER"; + return 0; + } virtual bool Report(map_crash_report_t pReport, const std::string &pSender) = 0; virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender) = 0; virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string &pSender) = 0; |
