From 4c3b5b1278f49a97ac12f43442bf314c71e06e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Mon, 7 Jun 2021 18:12:31 +0800 Subject: [PATCH] single instance log & add global broadcast --- doric-Qt/example/doric/DoricContextManager.h | 4 ++-- doric-Qt/example/doric/DoricNativeDriver.h | 4 ++-- doric-Qt/example/doric/DoricRegistry.cpp | 2 ++ doric-Qt/example/doric/DoricRegistry.h | 2 +- doric-Qt/example/doric/doric.pro | 2 ++ .../doric/utils/DoricGlobalBroadcast.cpp | 1 + .../doric/utils/DoricGlobalBroadcast.h | 20 +++++++++++++++++++ .../example/doric/utils/DoricNetworkService.h | 4 ++-- 8 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 doric-Qt/example/doric/utils/DoricGlobalBroadcast.cpp create mode 100644 doric-Qt/example/doric/utils/DoricGlobalBroadcast.h diff --git a/doric-Qt/example/doric/DoricContextManager.h b/doric-Qt/example/doric/DoricContextManager.h index 13a773b2..59215a60 100644 --- a/doric-Qt/example/doric/DoricContextManager.h +++ b/doric-Qt/example/doric/DoricContextManager.h @@ -10,9 +10,9 @@ class DORIC_EXPORT DoricContextManager { private: static DoricContextManager *local_instance; - DoricContextManager() {} + DoricContextManager() { qDebug() << "DoricContextManager constructor"; } - ~DoricContextManager() {} + ~DoricContextManager() { qDebug() << "DoricContextManager destructor"; } QAtomicInt *counter = new QAtomicInt(); QMap *contextMap = diff --git a/doric-Qt/example/doric/DoricNativeDriver.h b/doric-Qt/example/doric/DoricNativeDriver.h index 7dfd8e3b..1bae79f6 100644 --- a/doric-Qt/example/doric/DoricNativeDriver.h +++ b/doric-Qt/example/doric/DoricNativeDriver.h @@ -11,9 +11,9 @@ class DORIC_EXPORT DoricNativeDriver : public DoricInterfaceDriver { private: static DoricNativeDriver *local_instance; - DoricNativeDriver() {} + DoricNativeDriver() { qDebug() << "DoricNativeDriver constructor"; } - ~DoricNativeDriver() {} + ~DoricNativeDriver() { qDebug() << "DoricNativeDriver destructor"; } DoricJSEngine jsEngine; diff --git a/doric-Qt/example/doric/DoricRegistry.cpp b/doric-Qt/example/doric/DoricRegistry.cpp index dba380e3..10ae6dfa 100644 --- a/doric-Qt/example/doric/DoricRegistry.cpp +++ b/doric-Qt/example/doric/DoricRegistry.cpp @@ -22,6 +22,8 @@ #include "shader/slider/DoricSliderNode.h" DoricRegistry::DoricRegistry() { + qDebug() << "DoricRegistry constructor"; + registerNativePlugin("shader"); registerNativePlugin("modal"); registerNativePlugin("popover"); diff --git a/doric-Qt/example/doric/DoricRegistry.h b/doric-Qt/example/doric/DoricRegistry.h index 067844f0..ff143e28 100644 --- a/doric-Qt/example/doric/DoricRegistry.h +++ b/doric-Qt/example/doric/DoricRegistry.h @@ -14,7 +14,7 @@ class DORIC_EXPORT DoricRegistry { private: static DoricRegistry *local_instance; - ~DoricRegistry() { qDebug() << "destructor"; } + ~DoricRegistry() { qDebug() << "DoricRegistry destructor"; } public: static DoricRegistry *getInstance() { diff --git a/doric-Qt/example/doric/doric.pro b/doric-Qt/example/doric/doric.pro index c3d7babf..c85cd41b 100644 --- a/doric-Qt/example/doric/doric.pro +++ b/doric-Qt/example/doric/doric.pro @@ -62,6 +62,7 @@ SOURCES += \ utils/DoricContextHolder.cpp \ utils/DoricDialogBridge.cpp \ utils/DoricDraggableBridge.cpp \ + utils/DoricGlobalBroadcast.cpp \ utils/DoricImageBridge.cpp \ utils/DoricInputBridge.cpp \ utils/DoricLayouts.cpp \ @@ -151,6 +152,7 @@ HEADERS += \ utils/DoricCountDownLatch.h \ utils/DoricDialogBridge.h \ utils/DoricDraggableBridge.h \ + utils/DoricGlobalBroadcast.h \ utils/DoricImageBridge.h \ utils/DoricInputBridge.h \ utils/DoricLayouts.h \ diff --git a/doric-Qt/example/doric/utils/DoricGlobalBroadcast.cpp b/doric-Qt/example/doric/utils/DoricGlobalBroadcast.cpp new file mode 100644 index 00000000..a195cb7e --- /dev/null +++ b/doric-Qt/example/doric/utils/DoricGlobalBroadcast.cpp @@ -0,0 +1 @@ +#include "DoricGlobalBroadcast.h" diff --git a/doric-Qt/example/doric/utils/DoricGlobalBroadcast.h b/doric-Qt/example/doric/utils/DoricGlobalBroadcast.h new file mode 100644 index 00000000..e3128aad --- /dev/null +++ b/doric-Qt/example/doric/utils/DoricGlobalBroadcast.h @@ -0,0 +1,20 @@ +#ifndef DORICGLOBALBROADCAST_H +#define DORICGLOBALBROADCAST_H + +#include + +class DoricGlobalBroadcast { +private: + static DoricGlobalBroadcast *local_instance; + DoricGlobalBroadcast() { qDebug() << "DoricGlobalBroadcast constructor"; } + + ~DoricGlobalBroadcast() { qDebug() << "DoricGlobalBroadcast destructor"; } + +public: + static DoricGlobalBroadcast *getInstance() { + static DoricGlobalBroadcast instance; + return &instance; + } +}; + +#endif // DORICGLOBALBROADCAST_H diff --git a/doric-Qt/example/doric/utils/DoricNetworkService.h b/doric-Qt/example/doric/utils/DoricNetworkService.h index eab945b9..df632336 100644 --- a/doric-Qt/example/doric/utils/DoricNetworkService.h +++ b/doric-Qt/example/doric/utils/DoricNetworkService.h @@ -70,11 +70,11 @@ private: static DoricNetworkService *local_instance; DoricNetworkService() { - qDebug() << "constructor"; + qDebug() << "DoricNetworkService constructor"; thread.start(); } - ~DoricNetworkService() { qDebug() << "destructor"; } + ~DoricNetworkService() { qDebug() << "DoricNetworkService destructor"; } public: static DoricNetworkService *getInstance() {