[DEV] update new ememory::SharedPtr

This commit is contained in:
Edouard DUPIN 2016-07-15 21:22:11 +02:00
parent ea6e306ee6
commit 73f02160b5
14 changed files with 46 additions and 46 deletions

View File

@ -6,7 +6,7 @@
* @license APACHE v2.0 (see license file)
*/
#include <memory>
#include <ememory/memory.h>
#include <esignal/debug.h>
#include <esignal/Interface.h>
#include <esignal/Base.h>

View File

@ -8,7 +8,7 @@
#pragma once
#include <functional>
#include <memory>
#include <ememory/memory.h>
#include <esignal/debug.h>
#include <esignal/Base.h>
#include <functional>
@ -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<void>& _obj) = 0;
virtual void disconnectShared(const ememory::SharedPtr<void>& _obj) = 0;
/**
* @brief Disconnect an observer of the signal.
* @param[in] _uid Unique id of the signal connection.

View File

@ -8,7 +8,7 @@
#pragma once
#include <functional>
#include <memory>
#include <ememory/memory.h>
#include <esignal/debug.h>
#include <esignal/Base.h>

View File

@ -8,7 +8,7 @@
#pragma once
#include <functional>
#include <memory>
#include <ememory/memory.h>
#include <esignal/debug.h>
#include <esignal/Base.h>
#include <esignal/Signal.h>

View File

@ -6,7 +6,7 @@
* @license APACHE v2.0 (see license file)
*/
#include <memory>
#include <ememory/memory.h>
#include <esignal/debug.h>
#include <esignal/InterfaceData.h>
#include <esignal/Base.h>
@ -50,7 +50,7 @@ std::vector<std::string> esignal::InterfaceData::getAll() const {
return out;
}
void esignal::InterfaceData::disconnect(const std::shared_ptr<void>& _object) {
void esignal::InterfaceData::disconnect(const ememory::SharedPtr<void>& _object) {
if (_object == nullptr) {
ESIGNAL_ERROR("Input ERROR nullptr pointer Object ...");
return;

View File

@ -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<void>& _sharedPtr);
void disconnect(const ememory::SharedPtr<void>& _sharedPtr);
};
}

View File

@ -8,7 +8,7 @@
#pragma once
#include <functional>
#include <memory>
#include <ememory/memory.h>
#include <esignal/debug.h>
#include <esignal/Base.h>
#include <esignal/LockSharedPtrRef.h>
@ -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<void>& _obj);
virtual bool isSharedPtr(const ememory::SharedPtr<void>& _obj);
};
protected:
std::vector<std::unique_ptr<Executor>> m_executors; //!< List of all executors.
@ -98,14 +98,14 @@ namespace esignal {
*/
class ExecutorShared : public Executor {
protected:
std::weak_ptr<void> m_object; //!< a weak reference on the object to verify that it is alive
ememory::WeakPtr<void> 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<void> _object, Observer&& _observer);
ExecutorShared(ememory::WeakPtr<void> _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<void>& _obj) override;
bool isSharedPtr(const ememory::SharedPtr<void>& _obj) override;
};
public:
/**
@ -141,7 +141,7 @@ namespace esignal {
* @param[in] _args Argument optinnal the user want to add.
*/
template<class PARENT_CLASS_TYPE, class CLASS_TYPE, typename... FUNC_ARGS_TYPE>
void connect(const std::shared_ptr<PARENT_CLASS_TYPE>& _class,
void connect(const ememory::SharedPtr<PARENT_CLASS_TYPE>& _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<void>& _obj) override;
void disconnectShared(const ememory::SharedPtr<void>& _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<T_ARGS...>::connect(CLASS_TYPE* _class,
template<class... T_ARGS>
template<class PARENT_CLASS_TYPE, class CLASS_TYPE, typename... FUNC_ARGS_TYPE>
void esignal::Signal<T_ARGS...>::connect(const std::shared_ptr<PARENT_CLASS_TYPE>& _class,
void esignal::Signal<T_ARGS...>::connect(const ememory::SharedPtr<PARENT_CLASS_TYPE>& _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<T_ARGS...>::connect(const std::shared_ptr<PARENT_CLASS_TYPE
ESIGNAL_ERROR(" '" << getName() << "' Class pointer in nullptr");
return;
}
std::shared_ptr<CLASS_TYPE> obj2 = std::dynamic_pointer_cast<CLASS_TYPE>(_class);
ememory::SharedPtr<CLASS_TYPE> obj2 = ememory::dynamicPointerCast<CLASS_TYPE>(_class);
if (obj2 == nullptr) {
ESIGNAL_ERROR("Can not connect signal ...");
return;

View File

@ -100,7 +100,7 @@ void sharedConnection() {
// Create the signal
esignal::Signal<int32_t> signalValue;
// Declare the class
std::shared_ptr<TmpClass> myClassShared = std::make_shared<TmpClass>();
ememory::SharedPtr<TmpClass> myClassShared = ememory::makeShared<TmpClass>();
// Connect signals
signalValue.connect(myClassShared, &TmpClass::localCallBack);
// Emit sample signals

View File

@ -10,7 +10,7 @@
#include <gtest/gtest.h>
#include <esignal/ISignal.h>
#include <esignal/Interface.h>
#include <memory>
#include <ememory/memory.h>
#include <test-debug/debug.h>
@ -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<testCallbackIShared> {
class testCallbackIShared : public ememory::EnableSharedFromThis<testCallbackIShared> {
public:
testCallbackIShared() {
}
@ -110,7 +110,7 @@ TEST(test_isignal_counter, localbasicInterfaceDisconnectNullPtr) {
TEST(test_isignal_counter, localbasicInterfaceDisconnectSharedPtr) {
testISignal localClass;
std::shared_ptr<testCallbackIShared> tmp = std::make_shared<testCallbackIShared>();
ememory::SharedPtr<testCallbackIShared> tmp = ememory::makeShared<testCallbackIShared>();
localClass.signals.disconnect(tmp);
EXPECT_EQ(localClass.m_signalInt.size(), 0);
EXPECT_EQ(localClass.m_signalInt.empty(), true);

View File

@ -10,7 +10,7 @@
#include <gtest/gtest.h>
#include <esignal/Signal.h>
#include <esignal/Interface.h>
#include <memory>
#include <ememory/memory.h>
#include <test-debug/debug.h>
class testCallback {

View File

@ -10,7 +10,7 @@
#include <gtest/gtest.h>
#include <esignal/Signal.h>
#include <esignal/Interface.h>
#include <memory>
#include <ememory/memory.h>
#include <test-debug/debug.h>
class testCounter {

View File

@ -10,7 +10,7 @@
#include <gtest/gtest.h>
#include <esignal/Signal.h>
#include <esignal/Interface.h>
#include <memory>
#include <ememory/memory.h>
#include <test-debug/debug.h>
static esignal::Signal<int32_t>* signalll;

View File

@ -10,10 +10,10 @@
#include <gtest/gtest.h>
#include <esignal/Signal.h>
#include <esignal/Interface.h>
#include <memory>
#include <ememory/memory.h>
#include <test-debug/debug.h>
class testCallbackShared : public std::enable_shared_from_this<testCallbackShared> {
class testCallbackShared : public ememory::EnableSharedFromThis<testCallbackShared> {
public:
int32_t m_int32;
std::string m_string;
@ -74,7 +74,7 @@ class testCallbackShared : public std::enable_shared_from_this<testCallbackShare
m_string = _b + _char;
}
void callbackDisconnect(esignal::Signal<>* _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<testCallbackShared> localClass;
ememory::SharedPtr<testCallbackShared> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<int32_t> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<int32_t> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<std::string> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<std::string> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<int32_t, std::string> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<int32_t, std::string> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<int32_t, std::string> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<int32_t, std::string> 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<testCallbackSharedHerited> localClass = std::make_shared<testCallbackSharedHerited>();
ememory::SharedPtr<testCallbackSharedHerited> localClass = ememory::makeShared<testCallbackSharedHerited>();
esignal::Signal<int32_t, std::string> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<int32_t> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
esignal::Signal<int32_t> 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<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
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<testCallbackShared> localClassA = std::make_shared<testCallbackShared>();
std::shared_ptr<testCallbackShared> localClassB = std::make_shared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClassA = ememory::makeShared<testCallbackShared>();
ememory::SharedPtr<testCallbackShared> localClassB = ememory::makeShared<testCallbackShared>();
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<testCallbackShared>();
localClassB = ememory::makeShared<testCallbackShared>();
signal.connect(localClassB, &testCallbackShared::callbackVoid);
EXPECT_EQ(signal.size(), 4);
EXPECT_EQ(signal.empty(), false);

View File

@ -10,7 +10,7 @@
#include <gtest/gtest.h>
#include <esignal/Signal.h>
#include <esignal/Interface.h>
#include <memory>
#include <ememory/memory.h>
#include <test-debug/debug.h>
static int32_t tmpRetInt32 = 0;