From 73f02160b5a39fb0c107bdc218f4a5ab1c7d7a08 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 15 Jul 2016 21:22:11 +0200 Subject: [PATCH] [DEV] update new ememory::SharedPtr --- esignal/Base.cpp | 2 +- esignal/Base.h | 4 +-- esignal/Connection.h | 2 +- esignal/ISignal.h | 2 +- esignal/InterfaceData.cpp | 4 +-- esignal/InterfaceData.h | 2 +- esignal/Signal.h | 18 ++++++------ sample/sampleAll.cpp | 2 +- test/test_isignal.cpp | 6 ++-- test/test_signal_class_func.cpp | 2 +- test/test_signal_counter.cpp | 2 +- test/test_signal_recursive.cpp | 2 +- test/test_signal_shared_ptr_func.cpp | 42 ++++++++++++++-------------- test/test_signal_static_func.cpp | 2 +- 14 files changed, 46 insertions(+), 46 deletions(-) diff --git a/esignal/Base.cpp b/esignal/Base.cpp index 4fc0c9d..0da9171 100644 --- a/esignal/Base.cpp +++ b/esignal/Base.cpp @@ -6,7 +6,7 @@ * @license APACHE v2.0 (see license file) */ -#include +#include #include #include #include diff --git a/esignal/Base.h b/esignal/Base.h index c759d03..219a8a7 100644 --- a/esignal/Base.h +++ b/esignal/Base.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ namespace esignal { * @brief Disconnect the shared_ptr form the Signal * @param[in] _obj Link with the object to check */ - virtual void disconnectShared(const std::shared_ptr& _obj) = 0; + virtual void disconnectShared(const ememory::SharedPtr& _obj) = 0; /** * @brief Disconnect an observer of the signal. * @param[in] _uid Unique id of the signal connection. diff --git a/esignal/Connection.h b/esignal/Connection.h index c9cdf8b..f84bea1 100644 --- a/esignal/Connection.h +++ b/esignal/Connection.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include diff --git a/esignal/ISignal.h b/esignal/ISignal.h index 2b3dbe9..33d2121 100644 --- a/esignal/ISignal.h +++ b/esignal/ISignal.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/esignal/InterfaceData.cpp b/esignal/InterfaceData.cpp index 68b5d0e..9fd36e6 100644 --- a/esignal/InterfaceData.cpp +++ b/esignal/InterfaceData.cpp @@ -6,7 +6,7 @@ * @license APACHE v2.0 (see license file) */ -#include +#include #include #include #include @@ -50,7 +50,7 @@ std::vector esignal::InterfaceData::getAll() const { return out; } -void esignal::InterfaceData::disconnect(const std::shared_ptr& _object) { +void esignal::InterfaceData::disconnect(const ememory::SharedPtr& _object) { if (_object == nullptr) { ESIGNAL_ERROR("Input ERROR nullptr pointer Object ..."); return; diff --git a/esignal/InterfaceData.h b/esignal/InterfaceData.h index 5a94c74..54f3e3f 100644 --- a/esignal/InterfaceData.h +++ b/esignal/InterfaceData.h @@ -48,7 +48,7 @@ namespace esignal { * @brief Remove binding on all event class. * @param[in] _sharedPtr sharedPtr to unlink (no type needed ...). */ - void disconnect(const std::shared_ptr& _sharedPtr); + void disconnect(const ememory::SharedPtr& _sharedPtr); }; } diff --git a/esignal/Signal.h b/esignal/Signal.h index 75cab5f..2a2fc42 100644 --- a/esignal/Signal.h +++ b/esignal/Signal.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include #include @@ -88,7 +88,7 @@ namespace esignal { * @return true The Executor depend on this shared_ptr * @return false The Executor does not depend on this shared_ptr */ - virtual bool isSharedPtr(const std::shared_ptr& _obj); + virtual bool isSharedPtr(const ememory::SharedPtr& _obj); }; protected: std::vector> m_executors; //!< List of all executors. @@ -98,14 +98,14 @@ namespace esignal { */ class ExecutorShared : public Executor { protected: - std::weak_ptr m_object; //!< a weak reference on the object to verify that it is alive + ememory::WeakPtr m_object; //!< a weak reference on the object to verify that it is alive public: /** * @brief shared constructor. * @param[in] _object A weak reference of the object. * @param[in] _observer Observer to call. */ - ExecutorShared(std::weak_ptr _object, Observer&& _observer); + ExecutorShared(ememory::WeakPtr _object, Observer&& _observer); public: /** * @brief Emit the data on the observer. @@ -113,7 +113,7 @@ namespace esignal { */ void emit(const T_ARGS&... _values) override; public: - bool isSharedPtr(const std::shared_ptr& _obj) override; + bool isSharedPtr(const ememory::SharedPtr& _obj) override; }; public: /** @@ -141,7 +141,7 @@ namespace esignal { * @param[in] _args Argument optinnal the user want to add. */ template - void connect(const std::shared_ptr& _class, + void connect(const ememory::SharedPtr& _class, void (CLASS_TYPE::*_func)(const T_ARGS&..., FUNC_ARGS_TYPE...), FUNC_ARGS_TYPE... _args); public: @@ -166,7 +166,7 @@ namespace esignal { * @brief Disconnect the shared_ptr form the Signal * @param[in] _obj Link with the object to check */ - void disconnectShared(const std::shared_ptr& _obj) override; + void disconnectShared(const ememory::SharedPtr& _obj) override; /** * @brief Get the number of observers connected on the signal. * @return The count of observer. @@ -224,7 +224,7 @@ esignal::Connection esignal::Signal::connect(CLASS_TYPE* _class, template template -void esignal::Signal::connect(const std::shared_ptr& _class, +void esignal::Signal::connect(const ememory::SharedPtr& _class, void (CLASS_TYPE::*_func)(const T_ARGS&..., FUNC_ARGS_TYPE...), FUNC_ARGS_TYPE... _args) { ESIGNAL_DEBUG("esignal: '" << getName() << "' try connect: '" << getName() << "' (weak pointer)"); @@ -232,7 +232,7 @@ void esignal::Signal::connect(const std::shared_ptr obj2 = std::dynamic_pointer_cast(_class); + ememory::SharedPtr obj2 = ememory::dynamicPointerCast(_class); if (obj2 == nullptr) { ESIGNAL_ERROR("Can not connect signal ..."); return; diff --git a/sample/sampleAll.cpp b/sample/sampleAll.cpp index d2d3d85..7594b85 100644 --- a/sample/sampleAll.cpp +++ b/sample/sampleAll.cpp @@ -100,7 +100,7 @@ void sharedConnection() { // Create the signal esignal::Signal signalValue; // Declare the class - std::shared_ptr myClassShared = std::make_shared(); + ememory::SharedPtr myClassShared = ememory::makeShared(); // Connect signals signalValue.connect(myClassShared, &TmpClass::localCallBack); // Emit sample signals diff --git a/test/test_isignal.cpp b/test/test_isignal.cpp index 43838ee..6cd4c25 100644 --- a/test/test_isignal.cpp +++ b/test/test_isignal.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include @@ -85,7 +85,7 @@ TEST(test_isignal_counter, localbasicNameDesc) { EXPECT_EQ(localClass.m_signalString.getDescription(), "desc string"); } -class testCallbackIShared : public std::enable_shared_from_this { +class testCallbackIShared : public ememory::EnableSharedFromThis { public: testCallbackIShared() { } @@ -110,7 +110,7 @@ TEST(test_isignal_counter, localbasicInterfaceDisconnectNullPtr) { TEST(test_isignal_counter, localbasicInterfaceDisconnectSharedPtr) { testISignal localClass; - std::shared_ptr tmp = std::make_shared(); + ememory::SharedPtr tmp = ememory::makeShared(); localClass.signals.disconnect(tmp); EXPECT_EQ(localClass.m_signalInt.size(), 0); EXPECT_EQ(localClass.m_signalInt.empty(), true); diff --git a/test/test_signal_class_func.cpp b/test/test_signal_class_func.cpp index fc4f87b..6f82027 100644 --- a/test/test_signal_class_func.cpp +++ b/test/test_signal_class_func.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include class testCallback { diff --git a/test/test_signal_counter.cpp b/test/test_signal_counter.cpp index 250660b..3686f5a 100644 --- a/test/test_signal_counter.cpp +++ b/test/test_signal_counter.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include class testCounter { diff --git a/test/test_signal_recursive.cpp b/test/test_signal_recursive.cpp index a42f2eb..eca0175 100644 --- a/test/test_signal_recursive.cpp +++ b/test/test_signal_recursive.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include static esignal::Signal* signalll; diff --git a/test/test_signal_shared_ptr_func.cpp b/test/test_signal_shared_ptr_func.cpp index 34299bc..a4c043a 100644 --- a/test/test_signal_shared_ptr_func.cpp +++ b/test/test_signal_shared_ptr_func.cpp @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include -class testCallbackShared : public std::enable_shared_from_this { +class testCallbackShared : public ememory::EnableSharedFromThis { public: int32_t m_int32; std::string m_string; @@ -74,7 +74,7 @@ class testCallbackShared : public std::enable_shared_from_this* _signal) { - _signal->disconnectShared(shared_from_this()); + _signal->disconnectShared(sharedFromThis()); } }; @@ -84,7 +84,7 @@ void removeObserver(size_t _count) { } TEST(test_signal_shared_ptr_func, localNullClass) { - std::shared_ptr localClass; + ememory::SharedPtr localClass; esignal::Signal<> signal(&removeObserver); EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -96,7 +96,7 @@ TEST(test_signal_shared_ptr_func, localNullClass) { /* Impossible case ... TEST(test_signal_shared_ptr_func, localNullFunction) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal<> signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -108,7 +108,7 @@ TEST(test_signal_shared_ptr_func, localNullFunction) { } */ TEST(test_signal_shared_ptr_func, localFunctionVoid) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal<> signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -120,7 +120,7 @@ TEST(test_signal_shared_ptr_func, localFunctionVoid) { } TEST(test_signal_shared_ptr_func, localFunctionInt32) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -136,7 +136,7 @@ TEST(test_signal_shared_ptr_func, localFunctionInt32) { } TEST(test_signal_shared_ptr_func, localFunctionConstInt32) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -148,7 +148,7 @@ TEST(test_signal_shared_ptr_func, localFunctionConstInt32) { } TEST(test_signal_shared_ptr_func, localFunctionString) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -164,7 +164,7 @@ TEST(test_signal_shared_ptr_func, localFunctionString) { } TEST(test_signal_shared_ptr_func, localFunctionConstString) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -176,7 +176,7 @@ TEST(test_signal_shared_ptr_func, localFunctionConstString) { } TEST(test_signal_shared_ptr_func, localFunctionIntString) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -193,7 +193,7 @@ TEST(test_signal_shared_ptr_func, localFunctionIntString) { } TEST(test_signal_shared_ptr_func, localFunctionConstIntString) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -206,7 +206,7 @@ TEST(test_signal_shared_ptr_func, localFunctionConstIntString) { } TEST(test_signal_shared_ptr_func, localFunctionMixedIntString) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -224,7 +224,7 @@ TEST(test_signal_shared_ptr_func, localFunctionMixedIntString) { TEST(test_signal_shared_ptr_func, localFunctionConstIntStringPolyArg) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -246,7 +246,7 @@ class testCallbackSharedHerited : public testCallbackShared { TEST(test_signal_shared_ptr_func, localFunctionHerited) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -260,7 +260,7 @@ TEST(test_signal_shared_ptr_func, localFunctionHerited) { TEST(test_signal_shared_ptr_func, disconnect) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -276,7 +276,7 @@ TEST(test_signal_shared_ptr_func, disconnect) { TEST(test_signal_shared_ptr_func, connect_disconnect_multiple) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -302,7 +302,7 @@ TEST(test_signal_shared_ptr_func, connect_disconnect_multiple) { TEST(test_signal_shared_ptr_func, disconnect_inCallback) { - std::shared_ptr localClass = std::make_shared(); + ememory::SharedPtr localClass = ememory::makeShared(); esignal::Signal<> signal; EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -319,8 +319,8 @@ static void callbackVoid() { } TEST(test_signal_shared_ptr_func, localFunctionWeakTest) { - std::shared_ptr localClassA = std::make_shared(); - std::shared_ptr localClassB = std::make_shared(); + ememory::SharedPtr localClassA = ememory::makeShared(); + ememory::SharedPtr localClassB = ememory::makeShared(); esignal::Signal<> signal(&removeObserver); EXPECT_EQ(signal.size(), 0); EXPECT_EQ(signal.empty(), true); @@ -339,7 +339,7 @@ TEST(test_signal_shared_ptr_func, localFunctionWeakTest) { signal.emit(); EXPECT_EQ(signal.size(), 3); EXPECT_EQ(signal.empty(), false); - localClassB = std::make_shared(); + localClassB = ememory::makeShared(); signal.connect(localClassB, &testCallbackShared::callbackVoid); EXPECT_EQ(signal.size(), 4); EXPECT_EQ(signal.empty(), false); diff --git a/test/test_signal_static_func.cpp b/test/test_signal_static_func.cpp index 27cca9d..52eae09 100644 --- a/test/test_signal_static_func.cpp +++ b/test/test_signal_static_func.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include static int32_t tmpRetInt32 = 0;