diff --git a/lutinMacro_zeus.py b/lutinMacro_zeus.py index 69aba65..347f0be 100644 --- a/lutinMacro_zeus.py +++ b/lutinMacro_zeus.py @@ -731,6 +731,10 @@ class ServiceDefinition: out += space + " m_obj = _srv;\n" out += space + " return *this;\n" out += space + " }\n" + out += space + " const Proxy" + self.name[-1] + "& operator= (const Proxy" + self.name[-1] + "& _obj) {\n" + out += space + " m_obj = _obj.m_obj;\n" + out += space + " return *this;\n" + out += space + " }\n" out += space + " ~Proxy" + self.name[-1] + "() = default;\n" out += space + " Proxy" + self.name[-1] + "()" if len(self.attributes) != 0: diff --git a/zeus/Future.hpp b/zeus/Future.hpp index 78094bb..aeda887 100644 --- a/zeus/Future.hpp +++ b/zeus/Future.hpp @@ -62,6 +62,40 @@ namespace zeus { zeus::FutureBase::waitUntil(_endTime); return *this; } + using ObserverFut = std::function)>; //!< Define an Observer: function pointer for the local specific Future + /** + * @brief Attach callback on all return type of value + * @param[in] _callback Handle on the function to call in all case + */ + Future& andAll(ObserverFut _callback) { + zeus::FutureBase::andAll( + [=](zeus::FutureBase _fut) { + return _callback(zeus::Future(_fut)); + }); + return *this; + } + /** + * @brief Attach callback on a specific return action (SUCESS) + * @param[in] _callback Handle on the function to call in case of sucess on the call + */ + Future& andThen(ObserverFut _callback) { + zeus::FutureBase::andThen( + [=](zeus::FutureBase _fut) { + return _callback(zeus::Future(_fut)); + }); + return *this; + } + /** + * @brief Attach callback on a specific return action (ERROR) + * @param[in] _callback Handle on the function to call in case of error on the call + */ + Future& andElse(ObserverFut _callback) { + zeus::FutureBase::andElse( + [=](zeus::FutureBase _fut) { + return _callback(zeus::Future(_fut)); + }); + return *this; + } }; /** * @brief future template to cast type in a void methode (fallback) @@ -110,5 +144,39 @@ namespace zeus { zeus::FutureBase::waitUntil(_endTime); return *this; } + using ObserverFut = std::function)>; //!< Define an Observer: function pointer for the local specific Future + /** + * @brief Attach callback on all return type of value + * @param[in] _callback Handle on the function to call in all case + */ + Future& andAll(ObserverFut _callback) { + zeus::FutureBase::andAll( + [=](zeus::FutureBase _fut) { + return _callback(zeus::Future(_fut)); + }); + return *this; + } + /** + * @brief Attach callback on a specific return action (SUCESS) + * @param[in] _callback Handle on the function to call in case of sucess on the call + */ + Future& andThen(ObserverFut _callback) { + zeus::FutureBase::andThen( + [=](zeus::FutureBase _fut) { + return _callback(zeus::Future(_fut)); + }); + return *this; + } + /** + * @brief Attach callback on a specific return action (ERROR) + * @param[in] _callback Handle on the function to call in case of error on the call + */ + Future& andElse(ObserverFut _callback) { + zeus::FutureBase::andElse( + [=](zeus::FutureBase _fut) { + return _callback(zeus::Future(_fut)); + }); + return *this; + } }; } diff --git a/zeus/message/Answer.cpp b/zeus/message/Answer.cpp index 0ec74e6..0ffffce 100644 --- a/zeus/message/Answer.cpp +++ b/zeus/message/Answer.cpp @@ -40,6 +40,7 @@ void zeus::message::Answer::addError(const std::string& _value, const std::strin } bool zeus::message::Answer::writeOn(enet::WebSocket& _interface) { + std::unique_lock lock = _interface.getScopeLock(); zeus::Message::writeOn(_interface); _interface.writeData((uint8_t*)m_errorType.c_str(), m_errorType.size() + 1); if (m_errorType.size() != 0) { diff --git a/zeus/message/Call.cpp b/zeus/message/Call.cpp index 9a051c2..3e998b4 100644 --- a/zeus/message/Call.cpp +++ b/zeus/message/Call.cpp @@ -35,6 +35,7 @@ void zeus::message::Call::setCall(const std::string& _value) { } bool zeus::message::Call::writeOn(enet::WebSocket& _interface) { + std::unique_lock lock = _interface.getScopeLock(); zeus::Message::writeOn(_interface); _interface.writeData((uint8_t*)m_callName.c_str(), m_callName.size() + 1); return message::Parameter::writeOn(_interface);