[DEV] correct interface declaration

This commit is contained in:
Edouard DUPIN 2016-03-02 21:51:44 +01:00
parent abb334a3a2
commit 67d644353f
4 changed files with 18 additions and 12 deletions

View File

@ -21,7 +21,7 @@ namespace esignal {
template<class... T_ARGS> template<class... T_ARGS>
class ISignal : public Signal<T_ARGS...> { class ISignal : public Signal<T_ARGS...> {
protected: protected:
esignal::Interface& m_signalInterfaceLink; //!< interface of the signal manager. esignal::Interface* m_signalInterfaceLink; //!< interface of the signal manager.
std::string m_name; //!< name of the signal. std::string m_name; //!< name of the signal.
std::string m_description; //!< description of the signal. std::string m_description; //!< description of the signal.
public: public:
@ -36,10 +36,10 @@ namespace esignal {
ISignal(CLASS_TYPE* _signalInterfaceLink, ISignal(CLASS_TYPE* _signalInterfaceLink,
FUNC_TYPE _func, FUNC_TYPE _func,
const std::string& _name, const std::string& _name,
const std::string& _description = ""); const std::string& _description);
ISignal(esignal::Interface& _signalInterfaceLink, ISignal(esignal::Interface* _signalInterfaceLink,
const std::string& _name, const std::string& _name,
const std::string& _description = ""); const std::string& _description);
/** /**
* @brief Destructor. * @brief Destructor.
*/ */
@ -56,10 +56,12 @@ esignal::ISignal<T_ARGS...>::ISignal(CLASS_TYPE* _class,
const std::string& _name, const std::string& _name,
const std::string& _description) : const std::string& _description) :
esignal::Signal<T_ARGS...>(_class, _func), esignal::Signal<T_ARGS...>(_class, _func),
m_signalInterfaceLink(*_class), m_signalInterfaceLink(_class),
m_name(_name), m_name(_name),
m_description(_description) { m_description(_description) {
// add a reference on the current signal ... // add a reference on the current signal ...
m_signalInterfaceLink.signalAdd(this); if (m_signalInterfaceLink != nullptr) {
m_signalInterfaceLink->signalAdd(this);
}
} }

View File

@ -11,19 +11,23 @@
#include <esignal/details/Signal.hxx> #include <esignal/details/Signal.hxx>
template<class... T_ARGS> template<class... T_ARGS>
esignal::ISignal<T_ARGS...>::ISignal(esignal::Interface& _signalInterfaceLink, esignal::ISignal<T_ARGS...>::ISignal(esignal::Interface* _signalInterfaceLink,
const std::string& _name, const std::string& _name,
const std::string& _description): const std::string& _description):
m_signalInterfaceLink(_signalInterfaceLink), m_signalInterfaceLink(_signalInterfaceLink),
m_name(_name), m_name(_name),
m_description(_description) { m_description(_description) {
// add a reference on the current signal ... // add a reference on the current signal ...
m_signalInterfaceLink.signalAdd(this); if (m_signalInterfaceLink != nullptr) {
m_signalInterfaceLink->signalAdd(this);
}
} }
template<class... T_ARGS> template<class... T_ARGS>
esignal::ISignal<T_ARGS...>::~ISignal() { esignal::ISignal<T_ARGS...>::~ISignal() {
m_signalInterfaceLink.signalRemove(this); if (m_signalInterfaceLink != nullptr) {
m_signalInterfaceLink->signalRemove(this);
}
} }
template<class... T_ARGS> template<class... T_ARGS>

View File

@ -13,7 +13,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#undef __class__ #undef __class__
#define __class__ "etk-test" #define __class__ "esignal-test"
int main(int _argc, const char *_argv[]) { int main(int _argc, const char *_argv[]) {
::testing::InitGoogleTest(&_argc, const_cast<char **>(_argv)); ::testing::InitGoogleTest(&_argc, const_cast<char **>(_argv));

View File

@ -26,8 +26,8 @@ class testISignal : public esignal::Interface {
size_t m_count; size_t m_count;
testISignal(): testISignal():
m_signalInt(this, &testISignal::changeCount, "int", "desc int"), m_signalInt(this, &testISignal::changeCount, "int", "desc int"),
m_signalString(*this, "string", "desc string"), m_signalString(this, "string", "desc string"),
m_signalFloat(*this, "float", "desc float") { m_signalFloat(this, "float", "desc float") {
m_count = 0; m_count = 0;
} }
void changeCount(size_t _a) { void changeCount(size_t _a) {