[DEBUG/DEV] Buffer to message naming is OK, correct disconnection and add router optionnal for the gateway

This commit is contained in:
Edouard DUPIN 2016-12-08 00:16:40 +01:00
parent f1937e97d1
commit 0619e613eb
61 changed files with 596 additions and 558 deletions

View File

@ -432,33 +432,34 @@ class ServiceDefinition:
out += "#include <" + register_filename + ">\n" out += "#include <" + register_filename + ">\n"
out += "#include <" + register_filename_proxy + ">\n" out += "#include <" + register_filename_proxy + ">\n"
out += "#include <etk/types.hpp>\n" out += "#include <etk/types.hpp>\n"
out += "#include <zeus/debug.hpp>\n"
out += "#include <zeus/message/Message.hpp>\n" out += "#include <zeus/message/Message.hpp>\n"
out += "#include <zeus/message/Data.hpp>\n" out += "#include <zeus/message/Data.hpp>\n"
out += "#include <zeus/debug.hpp>\n" out += "#include <zeus/message/ParamType.hpp>\n"
out += "#include <zeus/ParamType.hpp>\n" out += "#include <zeus/message/Parameter.hpp>\n"
out += "#include <etk/stdTools.hpp>\n" out += "#include <etk/stdTools.hpp>\n"
out += "#include <zeus/AbstractFunction.hpp>\n" out += "#include <zeus/AbstractFunction.hpp>\n"
out += "#include <climits>\n" out += "#include <climits>\n"
out += "#include <etk/os/FSNode.hpp>\n" out += "#include <etk/os/FSNode.hpp>\n"
out += "#include <zeus/message/Parameter.hpp>\n"
out += "#include <zeus/WebServer.hpp>\n" out += "#include <zeus/WebServer.hpp>\n"
out += "#include <zeus/Object.hpp>\n" out += "#include <zeus/Object.hpp>\n"
out += "\n" out += "\n"
# now gebnerate the get and set parameter object ... # now gebnerate the get and set parameter object ...
out += "namespace zeus {\n" out += "namespace zeus {\n"
out += " template<> const zeus::ParamType& createType<ememory::SharedPtr<" + class_name + ">>() {\n" out += " namespace message {\n"
out += " static zeus::ParamType type(\"obj:" + class_name + "\", zeus::paramTypeObject, false, false);\n" out += " template<> const zeus::message::ParamType& createType<ememory::SharedPtr<" + class_name + ">>() {\n"
out += " static zeus::message::ParamType type(\"obj:" + class_name + "\", zeus::message::paramTypeObject, false, false);\n"
out += " return type;\n" out += " return type;\n"
out += " }\n" out += " }\n"
out += " \n" out += " \n"
out += " template<> const zeus::ParamType& createType<" + class_name_proxy + ">() {\n" out += " template<> const zeus::message::ParamType& createType<" + class_name_proxy + ">() {\n"
out += " static zeus::ParamType type(\"obj:" + class_name + "\", zeus::paramTypeObject, false, false);\n" out += " static zeus::message::ParamType type(\"obj:" + class_name + "\", zeus::message::paramTypeObject, false, false);\n"
out += " return type;\n" out += " return type;\n"
out += " }\n" out += " }\n"
out += " \n" out += " \n"
out += " template<>\n" out += " template<>\n"
out += " void BufferParameter::addParameter<ememory::SharedPtr<" + class_name + ">>(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _paramId, const ememory::SharedPtr<" + class_name + ">& _value) {\n" out += " void Parameter::addParameter<ememory::SharedPtr<" + class_name + ">>(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _paramId, const ememory::SharedPtr<" + class_name + ">& _value) {\n"
out += " std::vector<uint8_t> data;\n" out += " std::vector<uint8_t> data;\n"
""" """
out += " addType(data, createType<" + class_name + ">());\n" out += " addType(data, createType<" + class_name + ">());\n"
@ -486,11 +487,12 @@ class ServiceDefinition:
out += " }\n" out += " }\n"
out += " \n" out += " \n"
out += " template<>\n" out += " template<>\n"
out += " " + class_name_proxy + " BufferParameter::getParameter<" + class_name_proxy + ">(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {\n" out += " " + class_name_proxy + " Parameter::getParameter<" + class_name_proxy + ">(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {\n"
out += " ememory::SharedPtr<zeus::ObjectRemoteBase> out;\n" out += " ememory::SharedPtr<zeus::ObjectRemoteBase> out;\n"
out += " out = zeus::BufferParameter::getParameter<ememory::SharedPtr<zeus::ObjectRemoteBase>>(_iface, _id);\n" out += " out = zeus::message::Parameter::getParameter<ememory::SharedPtr<zeus::ObjectRemoteBase>>(_iface, _id);\n"
out += " return zeus::ObjectRemote(out);\n" out += " return zeus::ObjectRemote(out);\n"
out += " }\n" out += " }\n"
out += " }\n"
out += "}\n" out += "}\n"
return [filename, out] return [filename, out]
@ -656,7 +658,7 @@ class ServiceDefinition:
out += "#pragma once\n" out += "#pragma once\n"
out += "\n" out += "\n"
out += "#include <zeus/ObjectRemote.hpp>\n" out += "#include <zeus/ObjectRemote.hpp>\n"
out += "#include <zeus/BaseProxy.hpp>\n" out += "#include <zeus/Proxy.hpp>\n"
out += "#include <zeus/RemoteProperty.hpp>\n" out += "#include <zeus/RemoteProperty.hpp>\n"
out += "#include <string>\n" out += "#include <string>\n"
out += "#include <vector>\n" out += "#include <vector>\n"
@ -677,7 +679,7 @@ class ServiceDefinition:
out += space + " * authors:" + elem + "\n" out += space + " * authors:" + elem + "\n"
out += space + " */\n" out += space + " */\n"
#out += space + "class Proxy" + self.name[-1] + " : public " + self.name[-1] + " {\n" #out += space + "class Proxy" + self.name[-1] + " : public " + self.name[-1] + " {\n"
out += space + "class Proxy" + self.name[-1] + " :public zeus::BaseProxy {\n" out += space + "class Proxy" + self.name[-1] + " :public zeus::Proxy {\n"
space += " " space += " "
out += space + "public:\n" out += space + "public:\n"
out += space + " const Proxy" + self.name[-1] + "& operator= (const zeus::ObjectRemote& _srv) {\n" out += space + " const Proxy" + self.name[-1] + "& operator= (const zeus::ObjectRemote& _srv) {\n"
@ -697,7 +699,7 @@ class ServiceDefinition:
out += " {}\n" out += " {}\n"
out += space + " Proxy" + self.name[-1] + "(const zeus::ObjectRemote& _srv) :\n" out += space + " Proxy" + self.name[-1] + "(const zeus::ObjectRemote& _srv) :\n"
out += space + " zeus::BaseProxy(_srv)" out += space + " zeus::Proxy(_srv)"
for elem in self.attributes: for elem in self.attributes:
out += ",\n" out += ",\n"
out += space + " " + elem.name + "(m_obj, \"" + elem.name + "\")" out += space + " " + elem.name + "(m_obj, \"" + elem.name + "\")"

View File

@ -28,6 +28,8 @@ appl::DirectInterface::~DirectInterface() {
APPL_INFO("--------------------------"); APPL_INFO("--------------------------");
APPL_INFO("-- DELETE Direct Client --"); APPL_INFO("-- DELETE Direct Client --");
APPL_INFO("--------------------------"); APPL_INFO("--------------------------");
m_interfaceWeb.disconnect();
APPL_INFO("--------------------------");
} }
/* /*
void appl::clientSpecificInterface::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) { void appl::clientSpecificInterface::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) {
@ -69,7 +71,7 @@ bool appl::DirectInterface::start(appl::GateWay* _gateway) {
return true; return true;
} }
void appl::DirectInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) { void appl::DirectInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
@ -93,11 +95,11 @@ void appl::DirectInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) {
// TODO: Special hook for the first call that we need to get the curretn ID of the connection, think to set this at an other position ... // TODO: Special hook for the first call that we need to get the curretn ID of the connection, think to set this at an other position ...
if (m_uid == 0) { if (m_uid == 0) {
APPL_INFO("special case, we need to get the ID Of the client:"); APPL_INFO("special case, we need to get the ID Of the client:");
if (_value->getType() != zeus::Buffer::typeMessage::call) { if (_value->getType() != zeus::message::type::call) {
answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress'"); answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress'");
return; return;
} }
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value); ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
if (callObj->getCall() != "getAddress") { if (callObj->getCall() != "getAddress") {
answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress' and not '" + callObj->getCall() + "'"); answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress' and not '" + callObj->getCall() + "'");
return; return;
@ -116,7 +118,7 @@ void appl::DirectInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) {
} }
} }
void appl::DirectInterface::send(ememory::SharedPtr<zeus::Buffer> _value) { void appl::DirectInterface::send(ememory::SharedPtr<zeus::Message> _value) {
m_interfaceWeb.writeBinary(_value); m_interfaceWeb.writeBinary(_value);
} }

View File

@ -16,15 +16,16 @@ namespace appl {
zeus::WebServer m_interfaceWeb; zeus::WebServer m_interfaceWeb;
public: public:
DirectInterface(enet::Tcp _connection); DirectInterface(enet::Tcp _connection);
~DirectInterface(); virtual ~DirectInterface();
bool start(appl::GateWay* _gateway); bool start(appl::GateWay* _gateway);
void receive(ememory::SharedPtr<zeus::Buffer> _data); void receive(ememory::SharedPtr<zeus::Message> _data);
void send(ememory::SharedPtr<zeus::Buffer> _data); void send(ememory::SharedPtr<zeus::Message> _data);
bool requestURI(const std::string& _uri); bool requestURI(const std::string& _uri);
//void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); //void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
zeus::WebServer* getInterface() { zeus::WebServer* getInterface() {
return &m_interfaceWeb; return &m_interfaceWeb;
} }
bool isConnected() { return m_interfaceWeb.isActive(); };
}; };
} }

View File

@ -56,22 +56,23 @@ namespace appl {
// READ section data: // READ section data:
enet::Tcp data = std::move(m_interface.waitNext()); enet::Tcp data = std::move(m_interface.waitNext());
APPL_VERBOSE("New connection"); APPL_VERBOSE("New connection");
m_gateway->newService(std::move(data)); m_gateway->newDirectInterface(std::move(data));
} }
} }
}; };
} }
void appl::GateWay::newService(enet::Tcp _connection) { void appl::GateWay::newDirectInterface(enet::Tcp _connection) {
APPL_WARNING("New TCP connection (service)"); APPL_WARNING("New TCP connection (service)");
ememory::SharedPtr<appl::DirectInterface> tmp = ememory::makeShared<appl::DirectInterface>(std::move(_connection)); ememory::SharedPtr<appl::DirectInterface> tmp = ememory::makeShared<appl::DirectInterface>(std::move(_connection));
tmp->start(this); tmp->start(this);
m_listIODirect.push_back(tmp); m_listTemporaryIO.push_back(tmp);
} }
appl::GateWay::GateWay() : appl::GateWay::GateWay() :
m_idIncrement(10), m_idIncrement(10),
propertyUserName(this, "user", "no-name", "User name of the interface"), // must be set befor start ... propertyUserName(this, "user", "no-name", "User name of the interface"), // must be set befor start ...
propertyRouterNo(this, "no-router", false, "No connection on the router"),
propertyRouterIp(this, "router-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeClientIp), propertyRouterIp(this, "router-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeClientIp),
propertyRouterPort(this, "router-port", 1984, "Port to listen client", &appl::GateWay::onPropertyChangeClientPort), propertyRouterPort(this, "router-port", 1984, "Port to listen client", &appl::GateWay::onPropertyChangeClientPort),
propertyServiceIp(this, "service-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeServiceIp), propertyServiceIp(this, "service-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeServiceIp),
@ -86,6 +87,16 @@ appl::GateWay::~GateWay() {
void appl::GateWay::addIO(const ememory::SharedPtr<appl::IOInterface>& _io) { void appl::GateWay::addIO(const ememory::SharedPtr<appl::IOInterface>& _io) {
m_listIO.push_back(_io); m_listIO.push_back(_io);
// REMOVE of temporary element in the temporary list:
auto it = m_listTemporaryIO.begin();
while (it != m_listTemporaryIO.end()) {
ememory::SharedPtr<appl::IOInterface> tmp = *it;
if (tmp.get() == _io.get()) {
it = m_listTemporaryIO.erase(it);
} else {
++it;
}
}
} }
void appl::GateWay::removeIO(const ememory::SharedPtr<appl::IOInterface>& _io) { void appl::GateWay::removeIO(const ememory::SharedPtr<appl::IOInterface>& _io) {
@ -104,13 +115,20 @@ uint16_t appl::GateWay::getId() {
} }
void appl::GateWay::start() { void appl::GateWay::start() {
if (*propertyRouterNo == false) {
m_routerClient = ememory::makeShared<appl::RouterInterface>(*propertyRouterIp, *propertyRouterPort, *propertyUserName, this); m_routerClient = ememory::makeShared<appl::RouterInterface>(*propertyRouterIp, *propertyRouterPort, *propertyUserName, this);
if (m_routerClient->isAlive() == false) {
APPL_ERROR("Can not connect the Router (if it is the normal case, use option '--no-router'");
throw std::runtime_error("Can not connect router");
}
}
m_interfaceNewService->start(*propertyServiceIp, *propertyServicePort); m_interfaceNewService->start(*propertyServiceIp, *propertyServicePort);
} }
void appl::GateWay::stop() { void appl::GateWay::stop() {
m_routerClient.reset(); m_routerClient.reset();
m_listTemporaryIO.clear();
m_listIO.clear();
} }
bool appl::GateWay::serviceExist(const std::string& _service) { bool appl::GateWay::serviceExist(const std::string& _service) {
@ -141,20 +159,6 @@ uint16_t appl::GateWay::serviceClientIdGet(const std::string& _service) {
return 0; return 0;
} }
/*
ememory::SharedPtr<appl::ServiceInterface> appl::GateWay::get(const std::string& _serviceName) {
for (auto &it : m_serviceList) {
if (it == nullptr) {
continue;
}
if (it->getName() != _serviceName) {
continue;
}
return it;
}
return nullptr;
}
*/
std::vector<std::string> appl::GateWay::getAllServiceName() { std::vector<std::string> appl::GateWay::getAllServiceName() {
std::vector<std::string> out; std::vector<std::string> out;
@ -171,7 +175,7 @@ std::vector<std::string> appl::GateWay::getAllServiceName() {
} }
bool appl::GateWay::send(ememory::SharedPtr<zeus::Buffer> _data) { bool appl::GateWay::send(ememory::SharedPtr<zeus::Message> _data) {
auto it = m_listIO.begin(); auto it = m_listIO.begin();
uint16_t id = _data->getDestinationId(); uint16_t id = _data->getDestinationId();
while (it != m_listIO.end()) { while (it != m_listIO.end()) {
@ -188,25 +192,48 @@ bool appl::GateWay::send(ememory::SharedPtr<zeus::Buffer> _data) {
} }
void appl::GateWay::cleanIO() { void appl::GateWay::cleanIO() {
APPL_VERBOSE("Check if something need to be clean ..."); APPL_INFO("Check if something need to be clean ...");
/* std::vector<uint16_t> tmpIDToRemove;
auto it = m_listIODirect.begin(); // Clean all IOs...
while (it != m_listIODirect.end()) { {
auto it = m_listIO.begin();
while (it != m_listIO.end()) {
if (*it != nullptr) { if (*it != nullptr) {
if ((*it)->isAlive() == false) { if ((*it)->isConnected() == false) {
it = m_listIODirect.erase(it); tmpIDToRemove.push_back((*it)->getId());
it = m_listIO.erase(it);
continue; continue;
} }
} else { } else {
it = m_listIODirect.erase(it); it = m_listIO.erase(it);
continue; continue;
} }
++it; ++it;
} }
*/ }
// Clean all temporary connecting IO
{
auto it = m_listTemporaryIO.begin();
while (it != m_listTemporaryIO.end()) {
if (*it != nullptr) {
if ((*it)->isConnected() == false) {
it = m_listTemporaryIO.erase(it);
continue;
}
} else {
it = m_listTemporaryIO.erase(it);
continue;
}
++it;
}
}
// Clean router IO
if (m_routerClient != nullptr) { if (m_routerClient != nullptr) {
m_routerClient->clean(); m_routerClient->clean();
} }
if (tmpIDToRemove.size() != 0) {
APPL_TODO("Remove Ids ... " << tmpIDToRemove);
}
} }
void appl::GateWay::onClientConnect(const bool& _value) { void appl::GateWay::onClientConnect(const bool& _value) {

View File

@ -19,13 +19,14 @@ namespace appl {
ememory::SharedPtr<appl::TcpServerInput> m_interfaceNewService; ememory::SharedPtr<appl::TcpServerInput> m_interfaceNewService;
public: public:
eproperty::Value<std::string> propertyUserName; eproperty::Value<std::string> propertyUserName;
eproperty::Value<bool> propertyRouterNo;
eproperty::Value<std::string> propertyRouterIp; eproperty::Value<std::string> propertyRouterIp;
eproperty::Value<uint16_t> propertyRouterPort; eproperty::Value<uint16_t> propertyRouterPort;
eproperty::Value<std::string> propertyServiceIp; eproperty::Value<std::string> propertyServiceIp;
eproperty::Value<uint16_t> propertyServicePort; eproperty::Value<uint16_t> propertyServicePort;
eproperty::Value<uint16_t> propertyServiceMax; eproperty::Value<uint16_t> propertyServiceMax;
public: public:
std::vector<ememory::SharedPtr<appl::DirectInterface>> m_listIODirect; //!< List of all service availlable with their specific connection interface std::vector<ememory::SharedPtr<appl::DirectInterface>> m_listTemporaryIO; //!< List of all service availlable with their specific connection interface
std::vector<ememory::SharedPtr<appl::IOInterface>> m_listIO; std::vector<ememory::SharedPtr<appl::IOInterface>> m_listIO;
void addIO(const ememory::SharedPtr<appl::IOInterface>& _io); void addIO(const ememory::SharedPtr<appl::IOInterface>& _io);
void removeIO(const ememory::SharedPtr<appl::IOInterface>& _io); void removeIO(const ememory::SharedPtr<appl::IOInterface>& _io);
@ -37,8 +38,8 @@ namespace appl {
void stop(); void stop();
//ememory::SharedPtr<appl::ServiceInterface> get(const std::string& _serviceName); //ememory::SharedPtr<appl::ServiceInterface> get(const std::string& _serviceName);
std::vector<std::string> getAllServiceName(); std::vector<std::string> getAllServiceName();
bool send(ememory::SharedPtr<zeus::Buffer> _data); bool send(ememory::SharedPtr<zeus::Message> _data);
void newService(enet::Tcp _connection); void newDirectInterface(enet::Tcp _connection);
void cleanIO(); void cleanIO();
private: private:
void onPropertyChangeClientIp(); void onPropertyChangeClientIp();

View File

@ -55,7 +55,7 @@ const std::vector<std::string>& appl::IOInterface::getServiceList() {
return m_listService; return m_listService;
} }
void appl::IOInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) { void appl::IOInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
@ -69,12 +69,12 @@ void appl::IOInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) {
// Check if we are the destinated Of this message // Check if we are the destinated Of this message
if ( _value->getDestinationId() == ZEUS_ID_GATEWAY if ( _value->getDestinationId() == ZEUS_ID_GATEWAY
&& _value->getDestinationObjectId() == ZEUS_ID_GATEWAY_OBJECT) { && _value->getDestinationObjectId() == ZEUS_ID_GATEWAY_OBJECT) {
if (_value->getType() != zeus::Buffer::typeMessage::call) { if (_value->getType() != zeus::message::type::call) {
APPL_ERROR("Protocol error ==>missing 'call'"); APPL_ERROR("Protocol error ==>missing 'call'");
answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'"); answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'");
return; return;
} }
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value); ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
std::string callFunction = callObj->getCall(); std::string callFunction = callObj->getCall();
switch (m_state) { switch (m_state) {
case appl::clientState::disconnect: case appl::clientState::disconnect:

View File

@ -31,9 +31,9 @@ namespace appl {
virtual ~IOInterface(); virtual ~IOInterface();
bool start(appl::GateWay* _gateway, uint16_t _id); bool start(appl::GateWay* _gateway, uint16_t _id);
// Data arrive from the IO // Data arrive from the IO
virtual void receive(ememory::SharedPtr<zeus::Buffer> _value); virtual void receive(ememory::SharedPtr<zeus::Message> _value);
// Data must be send to the IO // Data must be send to the IO
virtual void send(ememory::SharedPtr<zeus::Buffer> _data) = 0; virtual void send(ememory::SharedPtr<zeus::Message> _data) = 0;
// Verify wich ID is provided by the IO // Verify wich ID is provided by the IO
bool checkId(uint16_t _id) const { bool checkId(uint16_t _id) const {
return m_uid == _id; return m_uid == _id;
@ -43,6 +43,7 @@ namespace appl {
} }
void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
virtual zeus::WebServer* getInterface() = 0; virtual zeus::WebServer* getInterface() = 0;
virtual bool isConnected() { return false; };
}; };
} }

View File

@ -42,12 +42,12 @@ bool appl::clientSpecificInterface::start(appl::GateWay* _gateway, zeus::WebServ
return true; return true;
} }
void appl::clientSpecificInterface::send(ememory::SharedPtr<zeus::Buffer> _value) { void appl::clientSpecificInterface::send(ememory::SharedPtr<zeus::Message> _value) {
m_interfaceWeb->writeBinary(_value); m_interfaceWeb->writeBinary(_value);
} }
#if 0 #if 0
void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) { void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
@ -58,7 +58,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Buffer> _va
answerProtocolError(transactionId, "missing parameter: 'id'"); answerProtocolError(transactionId, "missing parameter: 'id'");
return; return;
} }
if (_value->getType() == zeus::Buffer::typeMessage::data) { if (_value->getType() == zeus::Message::type::data) {
// TRANSMIT DATA ... // TRANSMIT DATA ...
if (m_state != appl::clientState::clientIdentify) { if (m_state != appl::clientState::clientIdentify) {
answerProtocolError(transactionId, "Not identify to send 'data' buffer (multiple packet element)"); answerProtocolError(transactionId, "Not identify to send 'data' buffer (multiple packet element)");
@ -85,12 +85,12 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Buffer> _va
(uint64_t(m_uid) << 32) + uint64_t(transactionId)); (uint64_t(m_uid) << 32) + uint64_t(transactionId));
return; return;
} }
if (_value->getType() != zeus::Buffer::typeMessage::call) { if (_value->getType() != zeus::Message::type::call) {
APPL_ERROR("Protocol error ==>missing 'call'"); APPL_ERROR("Protocol error ==>missing 'call'");
answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'"); answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'");
return; return;
} }
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value); ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
std::string callFunction = callObj->getCall(); std::string callFunction = callObj->getCall();
switch (m_state) { switch (m_state) {
case appl::clientState::disconnect: case appl::clientState::disconnect:
@ -289,7 +289,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Buffer> _va
} }
auto fut = m_listConnectedService[serviceId]->m_interfaceClient.callForward(m_uid, _value, (uint64_t(m_uid) << 32) + uint64_t(transactionId)); auto fut = m_listConnectedService[serviceId]->m_interfaceClient.callForward(m_uid, _value, (uint64_t(m_uid) << 32) + uint64_t(transactionId));
fut.andAll([=](zeus::FutureBase _ret) { fut.andAll([=](zeus::FutureBase _ret) {
ememory::SharedPtr<zeus::Buffer> tmpp = _ret.getRaw(); ememory::SharedPtr<zeus::Message> tmpp = _ret.getRaw();
if (tmpp == nullptr) { if (tmpp == nullptr) {
return true; return true;
} }
@ -360,7 +360,7 @@ bool appl::RouterInterface::isAlive() {
void appl::RouterInterface::onClientData(ememory::SharedPtr<zeus::Buffer> _value) { void appl::RouterInterface::onClientData(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
@ -382,7 +382,7 @@ void appl::RouterInterface::onClientData(ememory::SharedPtr<zeus::Buffer> _value
m_listClients[localId]->receive(_value); m_listClients[localId]->receive(_value);
} }
void appl::RouterInterface::send(const ememory::SharedPtr<zeus::Buffer>& _data) { void appl::RouterInterface::send(const ememory::SharedPtr<zeus::Message>& _data) {
m_interfaceWeb.writeBinary(_data); m_interfaceWeb.writeBinary(_data);
} }

View File

@ -19,7 +19,7 @@ namespace appl {
clientSpecificInterface(); clientSpecificInterface();
~clientSpecificInterface(); ~clientSpecificInterface();
bool start(appl::GateWay* _gateway, zeus::WebServer* _interfaceWeb, uint16_t _id); bool start(appl::GateWay* _gateway, zeus::WebServer* _interfaceWeb, uint16_t _id);
void send(ememory::SharedPtr<zeus::Buffer> _data); void send(ememory::SharedPtr<zeus::Message> _data);
//void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); //void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
zeus::WebServer* getInterface() { zeus::WebServer* getInterface() {
return m_interfaceWeb; return m_interfaceWeb;
@ -37,10 +37,11 @@ namespace appl {
RouterInterface(const std::string& _ip, uint16_t _port, std::string _userName, appl::GateWay* _gateway); RouterInterface(const std::string& _ip, uint16_t _port, std::string _userName, appl::GateWay* _gateway);
virtual ~RouterInterface(); virtual ~RouterInterface();
void stop(); void stop();
void onClientData(ememory::SharedPtr<zeus::Buffer> _value); void onClientData(ememory::SharedPtr<zeus::Message> _value);
bool isAlive(); bool isAlive();
void send(const ememory::SharedPtr<zeus::Buffer>& _data); void send(const ememory::SharedPtr<zeus::Message>& _data);
void clean(); void clean();
bool isConnected() { return m_interfaceWeb.isActive(); };
}; };
} }

View File

@ -73,18 +73,18 @@ void appl::ServiceInterface::stop() {
} }
void appl::ServiceInterface::SendData(uint64_t _userSessionId, ememory::SharedPtr<zeus::Buffer> _data) { void appl::ServiceInterface::SendData(uint64_t _userSessionId, ememory::SharedPtr<zeus::Message> _data) {
_data->setClientId(_userSessionId); _data->setClientId(_userSessionId);
m_interfaceClient.writeBinary(_data); m_interfaceClient.writeBinary(_data);
} }
void appl::ServiceInterface::onServiceData(ememory::SharedPtr<zeus::Buffer> _value) { void appl::ServiceInterface::onServiceData(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
uint32_t transactionId = _value->getTransactionId(); uint32_t transactionId = _value->getTransactionId();
//data.add("from-service", ejson::String(m_name)); //data.add("from-service", ejson::String(m_name));
if (_value->getType() == zeus::Buffer::typeMessage::event) { if (_value->getType() == zeus::Message::type::event) {
/* /*
if (data.valueExist("event") == true) { if (data.valueExist("event") == true) {
// No need to have a user ID ... // No need to have a user ID ...
@ -103,8 +103,8 @@ void appl::ServiceInterface::onServiceData(ememory::SharedPtr<zeus::Buffer> _val
*/ */
return; return;
} }
if (_value->getType() == zeus::Buffer::typeMessage::call) { if (_value->getType() == zeus::Message::type::call) {
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value); ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
std::string callFunction = callObj->getCall(); std::string callFunction = callObj->getCall();
if (callFunction == "getUserName") { if (callFunction == "getUserName") {
m_interfaceClient.answerValue(transactionId, _value->getClientId(), _value->getServiceId(), *m_gatewayInterface->propertyUserName); m_interfaceClient.answerValue(transactionId, _value->getClientId(), _value->getServiceId(), *m_gatewayInterface->propertyUserName);

View File

@ -24,10 +24,10 @@ namespace appl {
virtual ~ServiceInterface(); virtual ~ServiceInterface();
void start(); void start();
void stop(); void stop();
void onServiceData(ememory::SharedPtr<zeus::Buffer> _value); void onServiceData(ememory::SharedPtr<zeus::Message> _value);
bool requestURI(const std::string& _uri); bool requestURI(const std::string& _uri);
public: public:
void SendData(uint64_t _userSessionId, ememory::SharedPtr<zeus::Buffer> _data); void SendData(uint64_t _userSessionId, ememory::SharedPtr<zeus::Message> _data);
const std::string& getName() { const std::string& getName() {
return m_name; return m_name;
} }

View File

@ -20,6 +20,8 @@ int main(int _argc, const char *_argv[]) {
std::string data = _argv[iii]; std::string data = _argv[iii];
if (etk::start_with(data, "--user=") == true) { if (etk::start_with(data, "--user=") == true) {
basicGateway.propertyUserName.set(std::string(&data[7])); basicGateway.propertyUserName.set(std::string(&data[7]));
} else if (data == "--no-router") {
basicGateway.propertyRouterNo.set(true);
} else if (etk::start_with(data, "--router-ip=") == true) { } else if (etk::start_with(data, "--router-ip=") == true) {
basicGateway.propertyRouterIp.set(std::string(&data[12])); basicGateway.propertyRouterIp.set(std::string(&data[12]));
} else if (etk::start_with(data, "--router-port=") == true) { } else if (etk::start_with(data, "--router-port=") == true) {
@ -35,6 +37,7 @@ int main(int _argc, const char *_argv[]) {
APPL_PRINT(etk::getApplicationName() << " - help : "); APPL_PRINT(etk::getApplicationName() << " - help : ");
APPL_PRINT(" " << _argv[0] << " [options]"); APPL_PRINT(" " << _argv[0] << " [options]");
APPL_PRINT(" --user=XXX Name of the user that we are connected."); APPL_PRINT(" --user=XXX Name of the user that we are connected.");
APPL_PRINT(" --no-router Router connection disable ==> this enable the direct donnection of external client like on the router");
APPL_PRINT(" --router-ip=XXX Router connection IP (default: 1.7.0.0.1)"); APPL_PRINT(" --router-ip=XXX Router connection IP (default: 1.7.0.0.1)");
APPL_PRINT(" --router-port=XXX Router connection PORT (default: 1984)"); APPL_PRINT(" --router-port=XXX Router connection PORT (default: 1984)");
APPL_PRINT(" --service-ip=XXX Service connection IP (default: 1.7.0.0.1)"); APPL_PRINT(" --service-ip=XXX Service connection IP (default: 1.7.0.0.1)");
@ -48,7 +51,7 @@ int main(int _argc, const char *_argv[]) {
APPL_INFO("=================================="); APPL_INFO("==================================");
basicGateway.start(); basicGateway.start();
while (true) { while (true) {
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(10000));
basicGateway.cleanIO(); basicGateway.cleanIO();
} }
basicGateway.stop(); basicGateway.stop();

View File

@ -88,7 +88,7 @@ static int32_t nextP2(int32_t _value) {
return val; return val;
} }
void appl::BufferElementVideo::setSize(const ivec2& _size) { void appl::MessageElementVideo::setSize(const ivec2& _size) {
if (m_imagerealSize != _size) { if (m_imagerealSize != _size) {
// Resize the buffer: // Resize the buffer:
m_imagerealSize = _size; m_imagerealSize = _size;
@ -97,7 +97,7 @@ void appl::BufferElementVideo::setSize(const ivec2& _size) {
//m_image.getSize(); //m_image.getSize();
} }
} }
void appl::BufferElementAudio::configure(audio::format _format, uint32_t _sampleRate, int32_t _nbChannel, int32_t _nbSample) { void appl::MessageElementAudio::configure(audio::format _format, uint32_t _sampleRate, int32_t _nbChannel, int32_t _nbSample) {
// resize the buffer: // resize the buffer:
m_buffer.resize(_nbSample*_nbChannel*audio::getFormatBytes(_format)); m_buffer.resize(_nbSample*_nbChannel*audio::getFormatBytes(_format));
m_format = _format; m_format = _format;
@ -243,7 +243,7 @@ int appl::MediaDecoder::decode_packet(int *_gotFrame, int _cached) {
if (format == audio::format_unknow) { if (format == audio::format_unknow) {
APPL_ERROR("Unsupported audio format :" << m_frame->format << " ..."); APPL_ERROR("Unsupported audio format :" << m_frame->format << " ...");
} else { } else {
// configure Buffer: // configure Message:
m_audioPool[slotId].configure(format, m_frame->sample_rate, m_frame->channels, m_frame->nb_samples); m_audioPool[slotId].configure(format, m_frame->sample_rate, m_frame->channels, m_frame->nb_samples);
if (av_sample_fmt_is_planar((enum AVSampleFormat)m_frame->format) == 1) { if (av_sample_fmt_is_planar((enum AVSampleFormat)m_frame->format) == 1) {
for (int32_t ccc=0; ccc<m_frame->channels; ++ccc) { for (int32_t ccc=0; ccc<m_frame->channels; ++ccc) {
@ -467,7 +467,7 @@ void appl::MediaDecoder::stop() {
m_stopRequested = true; m_stopRequested = true;
} }
void appl::MediaDecoder::flushBuffer() { void appl::MediaDecoder::flushMessage() {
// flush all decoders ... // flush all decoders ...
avcodec_flush_buffers(m_audioStream->codec); avcodec_flush_buffers(m_audioStream->codec);
avcodec_flush_buffers(m_videoStream->codec); avcodec_flush_buffers(m_videoStream->codec);
@ -483,7 +483,7 @@ void appl::MediaDecoder::flushBuffer() {
void appl::MediaDecoder::applySeek(echrono::Duration _time) { void appl::MediaDecoder::applySeek(echrono::Duration _time) {
APPL_INFO("Apply seek : " << _time); APPL_INFO("Apply seek : " << _time);
flushBuffer(); flushMessage();
int64_t seekPos = int64_t(_time.toSeconds() * double(AV_TIME_BASE)); int64_t seekPos = int64_t(_time.toSeconds() * double(AV_TIME_BASE));
int32_t id = -1; int32_t id = -1;

View File

@ -19,32 +19,32 @@ extern "C" {
} }
namespace appl { namespace appl {
class BufferElement { class MessageElement {
public: public:
uint64_t m_id; //!< Id of the current image (must be unique) uint64_t m_id; //!< Id of the current image (must be unique)
echrono::Duration m_time; //!< Current time of the Buffer Element echrono::Duration m_time; //!< Current time of the Message Element
echrono::Duration m_duration; //!< if the FPS is static ==> the duration can be set otherwise (0) echrono::Duration m_duration; //!< if the FPS is static ==> the duration can be set otherwise (0)
bool m_isUsed; //!< This buffer is used bool m_isUsed; //!< This buffer is used
BufferElement(): MessageElement():
m_id(0), m_id(0),
m_isUsed(false) { m_isUsed(false) {
} }
virtual ~BufferElement() = default; virtual ~MessageElement() = default;
}; };
// class that contain all the element needed for a buffer image transfert: // class that contain all the element needed for a buffer image transfert:
class BufferElementVideo : public appl::BufferElement { class MessageElementVideo : public appl::BufferElement {
public: public:
egami::Image m_image; //!< Image to manage internal data egami::Image m_image; //!< Image to manage internal data
ivec2 m_imagerealSize; //!< Real size of the image, in OpenGL we need power of 2 border size. ivec2 m_imagerealSize; //!< Real size of the image, in OpenGL we need power of 2 border size.
int32_t m_lineSize; //!< Size of a single line (in byte) int32_t m_lineSize; //!< Size of a single line (in byte)
void setSize(const ivec2& _newSize); void setSize(const ivec2& _newSize);
BufferElementVideo(): MessageElementVideo():
m_image(ivec2(32,32), egami::colorType::RGB8) { m_image(ivec2(32,32), egami::colorType::RGB8) {
} }
}; };
class BufferElementAudio : public appl::BufferElement { class MessageElementAudio : public appl::BufferElement {
public: public:
std::vector<uint8_t> m_buffer; //!< raw audio data std::vector<uint8_t> m_buffer; //!< raw audio data
audio::format m_format; //!< Audio format buffer audio::format m_format; //!< Audio format buffer
@ -66,9 +66,9 @@ namespace appl {
return m_duration; return m_duration;
} }
public: public:
std::vector<BufferElementAudio> m_audioPool; std::vector<MessageElementAudio> m_audioPool;
echrono::Duration m_currentAudioTime; echrono::Duration m_currentAudioTime;
std::vector<BufferElementVideo> m_videoPool; std::vector<MessageElementVideo> m_videoPool;
echrono::Duration m_currentVideoTime; echrono::Duration m_currentVideoTime;
bool m_updateVideoTimeStampAfterSeek; bool m_updateVideoTimeStampAfterSeek;
int32_t audioGetOlderSlot(); int32_t audioGetOlderSlot();
@ -126,7 +126,7 @@ namespace appl {
void seek(const echrono::Duration& _time) { void seek(const echrono::Duration& _time) {
m_seek = _time; m_seek = _time;
} }
void flushBuffer(); void flushMessage();
void stop() override; void stop() override;
}; };

View File

@ -33,7 +33,7 @@ void appl::widget::VideoDisplay::init() {
// set call all time (sample ...). // set call all time (sample ...).
getObjectManager().periodicCall.connect(sharedFromThis(), &appl::widget::VideoDisplay::periodicEvent); getObjectManager().periodicCall.connect(sharedFromThis(), &appl::widget::VideoDisplay::periodicEvent);
// Create the VBO: // Create the VBO:
m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); m_VBO = gale::resource::VirtualMessageObject::create(NB_VBO);
if (m_VBO == nullptr) { if (m_VBO == nullptr) {
APPL_ERROR("can not instanciate VBO ..."); APPL_ERROR("can not instanciate VBO ...");
return; return;
@ -181,41 +181,41 @@ void appl::widget::VideoDisplay::printPart(const vec2& _size,
//EWOL_ERROR("Debug image " << m_filename << " ==> " << m_position << " " << _size << " " << _sourcePosStart << " " << _sourcePosStop); //EWOL_ERROR("Debug image " << m_filename << " ==> " << m_position << " " << _size << " " << _sourcePosStart << " " << _sourcePosStop);
vec3 point = m_position; vec3 point = m_position;
vec2 tex(_sourcePosStart.x(),_sourcePosStop.y()); vec2 tex(_sourcePosStart.x(),_sourcePosStop.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); m_VBO->pushOnMessage(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); m_VBO->pushOnMessage(m_vboIdColor, m_color);
tex.setValue(_sourcePosStop.x(),_sourcePosStop.y()); tex.setValue(_sourcePosStop.x(),_sourcePosStop.y());
point.setX(m_position.x() + _size.x()); point.setX(m_position.x() + _size.x());
point.setY(m_position.y()); point.setY(m_position.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); m_VBO->pushOnMessage(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); m_VBO->pushOnMessage(m_vboIdColor, m_color);
tex.setValue(_sourcePosStop.x(),_sourcePosStart.y()); tex.setValue(_sourcePosStop.x(),_sourcePosStart.y());
point.setX(m_position.x() + _size.x()); point.setX(m_position.x() + _size.x());
point.setY(m_position.y() + _size.y()); point.setY(m_position.y() + _size.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); m_VBO->pushOnMessage(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); m_VBO->pushOnMessage(m_vboIdColor, m_color);
m_VBO->pushOnBuffer(m_vboIdCoord, point); m_VBO->pushOnMessage(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); m_VBO->pushOnMessage(m_vboIdColor, m_color);
tex.setValue(_sourcePosStart.x(),_sourcePosStart.y()); tex.setValue(_sourcePosStart.x(),_sourcePosStart.y());
point.setX(m_position.x()); point.setX(m_position.x());
point.setY(m_position.y() + _size.y()); point.setY(m_position.y() + _size.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); m_VBO->pushOnMessage(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); m_VBO->pushOnMessage(m_vboIdColor, m_color);
tex.setValue(_sourcePosStart.x(),_sourcePosStop.y()); tex.setValue(_sourcePosStart.x(),_sourcePosStop.y());
point.setX(m_position.x()); point.setX(m_position.x());
point.setY(m_position.y()); point.setY(m_position.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); m_VBO->pushOnMessage(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); m_VBO->pushOnMessage(m_vboIdColor, m_color);
m_VBO->flush(); m_VBO->flush();
} }
@ -242,7 +242,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
m_currentTime = m_decoder->m_seekApply; m_currentTime = m_decoder->m_seekApply;
m_decoder->m_seekApply = echrono::Duration(-1); m_decoder->m_seekApply = echrono::Duration(-1);
if (m_audioInterface != nullptr) { if (m_audioInterface != nullptr) {
m_audioInterface->clearInternalBuffer(); m_audioInterface->clearInternalMessage();
} }
} }
// SET AUDIO: // SET AUDIO:

View File

@ -45,7 +45,7 @@ namespace appl {
static const int32_t m_vboIdCoord; static const int32_t m_vboIdCoord;
static const int32_t m_vboIdCoordTex; static const int32_t m_vboIdCoordTex;
static const int32_t m_vboIdColor; static const int32_t m_vboIdColor;
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_VBO; ememory::SharedPtr<gale::resource::VirtualMessageObject> m_VBO;
protected: protected:
etk::Color<float,4> m_color; etk::Color<float,4> m_color;
vec3 m_position; vec3 m_position;

View File

@ -8,7 +8,6 @@
#include <appl/ClientInterface.hpp> #include <appl/ClientInterface.hpp>
#include <zeus/Future.hpp> #include <zeus/Future.hpp>
#include <appl/Router.hpp> #include <appl/Router.hpp>
#include <zeus/message/Ctrl.hpp>
#include <zeus/AbstractFunction.hpp> #include <zeus/AbstractFunction.hpp>
@ -79,7 +78,7 @@ void appl::ClientInterface::answerProtocolError(uint32_t _transactionId, const s
} }
void appl::ClientInterface::onClientData(ememory::SharedPtr<zeus::Buffer> _value) { void appl::ClientInterface::onClientData(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
@ -103,11 +102,11 @@ void appl::ClientInterface::onClientData(ememory::SharedPtr<zeus::Buffer> _value
// TODO: Special hook for the first call that we need to get the curretn ID of the connection, think to set this at an other position ... // TODO: Special hook for the first call that we need to get the curretn ID of the connection, think to set this at an other position ...
if (m_uid == 0) { if (m_uid == 0) {
APPL_INFO("special case, we need to get the ID Of the client:"); APPL_INFO("special case, we need to get the ID Of the client:");
if (_value->getType() != zeus::Buffer::typeMessage::call) { if (_value->getType() != zeus::message::type::call) {
answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress'"); answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress'");
return; return;
} }
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value); ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
if (callObj->getCall() != "getAddress") { if (callObj->getCall() != "getAddress") {
answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress' and not '" + callObj->getCall() + "'"); answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress' and not '" + callObj->getCall() + "'");
return; return;
@ -127,14 +126,14 @@ void appl::ClientInterface::onClientData(ememory::SharedPtr<zeus::Buffer> _value
} }
} }
void appl::ClientInterface::send(ememory::SharedPtr<zeus::Buffer> _data) { void appl::ClientInterface::send(ememory::SharedPtr<zeus::Message> _data) {
if (_data == nullptr) { if (_data == nullptr) {
return; return;
} }
m_interfaceClient.writeBinary(_data); m_interfaceClient.writeBinary(_data);
/* /*
if (_data->getType() == zeus::Buffer::typeMessage::ctrl) { if (_data->getType() == zeus::Message::type::ctrl) {
std::string value = static_cast<zeus::BufferCtrl*>(_data.get())->getCtrl(); std::string value = static_cast<zeus::MessageCtrl*>(_data.get())->getCtrl();
if (value == "DISCONNECT") { if (value == "DISCONNECT") {
m_interfaceClient.disconnect(true); m_interfaceClient.disconnect(true);
return; return;

View File

@ -26,8 +26,8 @@ namespace appl {
virtual ~ClientInterface(); virtual ~ClientInterface();
void start(); void start();
void stop(); void stop();
void onClientData(ememory::SharedPtr<zeus::Buffer> _value); void onClientData(ememory::SharedPtr<zeus::Message> _value);
void send(ememory::SharedPtr<zeus::Buffer> _data); void send(ememory::SharedPtr<zeus::Message> _data);
bool checkId(uint16_t _id) const { bool checkId(uint16_t _id) const {
return m_uid == _id; return m_uid == _id;
} }

View File

@ -73,7 +73,7 @@ void appl::GateWayInterface::stop() {
} }
void appl::GateWayInterface::send(ememory::SharedPtr<zeus::Buffer> _data) { void appl::GateWayInterface::send(ememory::SharedPtr<zeus::Message> _data) {
m_interfaceClient.writeBinary(_data); m_interfaceClient.writeBinary(_data);
} }
@ -93,14 +93,14 @@ void appl::GateWayInterface::rmClient(ememory::SharedPtr<appl::ClientInterface>
} }
} }
void appl::GateWayInterface::onServiceData(ememory::SharedPtr<zeus::Buffer> _value) { void appl::GateWayInterface::onServiceData(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
if (m_name == "") { if (m_name == "") {
uint32_t transactionId = _value->getTransactionId(); uint32_t transactionId = _value->getTransactionId();
if (_value->getType() == zeus::Buffer::typeMessage::call) { if (_value->getType() == zeus::message::type::call) {
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value); ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
std::string callFunction = callObj->getCall(); std::string callFunction = callObj->getCall();
if (callFunction == "connect-service") { if (callFunction == "connect-service") {
if (m_name != "") { if (m_name != "") {

View File

@ -24,11 +24,11 @@ namespace appl {
virtual ~GateWayInterface(); virtual ~GateWayInterface();
void start(); void start();
void stop(); void stop();
void onServiceData(ememory::SharedPtr<zeus::Buffer> _value); void onServiceData(ememory::SharedPtr<zeus::Message> _value);
public: public:
uint16_t addClient(ememory::SharedPtr<appl::ClientInterface> _value); uint16_t addClient(ememory::SharedPtr<appl::ClientInterface> _value);
void rmClient(ememory::SharedPtr<appl::ClientInterface> _value); void rmClient(ememory::SharedPtr<appl::ClientInterface> _value);
void send(ememory::SharedPtr<zeus::Buffer> _data); void send(ememory::SharedPtr<zeus::Message> _data);
const std::string& getName() { const std::string& getName() {
return m_name; return m_name;
} }

View File

@ -18,7 +18,7 @@ namespace zeus {
*/ */
bool checkOrderFunctionParameter(); bool checkOrderFunctionParameter();
/** /**
* @brief Interface to store a function and call it after with a @ref zeus::Buffer * @brief Interface to store a function and call it after with a @ref zeus::Message
*/ */
class AbstractFunction { class AbstractFunction {
protected: protected:
@ -129,7 +129,7 @@ namespace zeus {
* @param[in] _class Pointer on the object that might be call (note: brut cast) * @param[in] _class Pointer on the object that might be call (note: brut cast)
*/ */
virtual void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient, virtual void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
ememory::SharedPtr<zeus::BufferCall> _obj, ememory::SharedPtr<zeus::message::Call> _obj,
void* _class=nullptr) = 0; void* _class=nullptr) = 0;
}; };
} }

View File

@ -15,13 +15,13 @@ namespace zeus {
/** /**
* @brief Execute a call on the function with a return value * @brief Execute a call on the function with a return value
* @param[in] _interfaceClient Web interface to send data * @param[in] _interfaceClient Web interface to send data
* @param[in] _obj Buffer input call (that have parameter already check) * @param[in] _obj Message input call (that have parameter already check)
* @param[in] _pointer Pointer on the class to call * @param[in] _pointer Pointer on the class to call
* @param[in] _func pointer on the function to call * @param[in] _func pointer on the function to call
*/ */
template <class ZEUS_CLASS_TYPE, class ZEUS_RETURN, class... ZEUS_TYPES> template <class ZEUS_CLASS_TYPE, class ZEUS_RETURN, class... ZEUS_TYPES>
void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient, void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
ememory::SharedPtr<zeus::BufferParameter> _obj, ememory::SharedPtr<zeus::message::Parameter> _obj,
ZEUS_CLASS_TYPE* _pointer, ZEUS_CLASS_TYPE* _pointer,
ZEUS_RETURN (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) { ZEUS_RETURN (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) {
if (_obj == nullptr) { if (_obj == nullptr) {
@ -49,13 +49,13 @@ namespace zeus {
/** /**
* @brief Execute a call on the function with NO return value * @brief Execute a call on the function with NO return value
* @param[in] _interfaceClient Web interface to send data * @param[in] _interfaceClient Web interface to send data
* @param[in] _obj Buffer input call (that have parameter already check) * @param[in] _obj Message input call (that have parameter already check)
* @param[in] _pointer Pointer on the class to call * @param[in] _pointer Pointer on the class to call
* @param[in] _func pointer on the function to call * @param[in] _func pointer on the function to call
*/ */
template <class ZEUS_CLASS_TYPE, class... ZEUS_TYPES> template <class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient, void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
ememory::SharedPtr<zeus::BufferParameter> _obj, ememory::SharedPtr<zeus::message::Parameter> _obj,
ZEUS_CLASS_TYPE* _pointer, ZEUS_CLASS_TYPE* _pointer,
void (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) { void (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) {
if (_obj == nullptr) { if (_obj == nullptr) {
@ -85,8 +85,8 @@ namespace zeus {
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES> template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
class AbstractFunctionTypeClass: public zeus::AbstractFunction { class AbstractFunctionTypeClass: public zeus::AbstractFunction {
protected: protected:
static const ParamType m_returnType; static const zeus::message::ParamType m_returnType;
static const ParamType m_paramType[sizeof...(ZEUS_TYPES)]; static const zeus::message::ParamType m_paramType[sizeof...(ZEUS_TYPES)];
public: public:
using functionType = ZEUS_RETURN (ZEUS_CLASS_TYPE::*)(ZEUS_TYPES...); using functionType = ZEUS_RETURN (ZEUS_CLASS_TYPE::*)(ZEUS_TYPES...);
functionType m_function; functionType m_function;
@ -110,7 +110,7 @@ namespace zeus {
return out; return out;
} }
void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient, void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
ememory::SharedPtr<zeus::BufferCall> _obj, ememory::SharedPtr<zeus::message::Call> _obj,
void* _class) override { void* _class) override {
if (_obj == nullptr) { if (_obj == nullptr) {
return; return;
@ -157,10 +157,10 @@ namespace zeus {
}; };
// specialization // specialization
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES> template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
const ParamType AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_returnType = createType<ZEUS_RETURN>(); const zeus::message::ParamType AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_returnType = zeus::message::createType<ZEUS_RETURN>();
// specialization // specialization
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES> template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
const ParamType AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_paramType[sizeof...(ZEUS_TYPES)] = {createType<ZEUS_TYPES>()...}; const zeus::message::ParamType AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_paramType[sizeof...(ZEUS_TYPES)] = {zeus::message::createType<ZEUS_TYPES>()...};
/** /**
* @brief Create a function information with the function type * @brief Create a function information with the function type
* @param[in] _name Name of the function * @param[in] _name Name of the function

View File

@ -12,12 +12,12 @@ namespace zeus {
/** /**
* @brief Execute a call on the global function with a return value * @brief Execute a call on the global function with a return value
* @param[in] _interfaceClient Web interface to send data * @param[in] _interfaceClient Web interface to send data
* @param[in] _obj Buffer input call (that have parameter already check) * @param[in] _obj Message input call (that have parameter already check)
* @param[in] _func pointer on the function to call * @param[in] _func pointer on the function to call
*/ */
template <class ZEUS_RETURN, class... ZEUS_TYPES> template <class ZEUS_RETURN, class... ZEUS_TYPES>
void executeCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient, void executeCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
ememory::SharedPtr<zeus::BufferParameter> _obj, ememory::SharedPtr<zeus::message::Parameter> _obj,
ZEUS_RETURN (*_func)(ZEUS_TYPES...)) { ZEUS_RETURN (*_func)(ZEUS_TYPES...)) {
if (_obj == nullptr) { if (_obj == nullptr) {
return; return;
@ -44,12 +44,12 @@ namespace zeus {
/** /**
* @brief Execute a call on the global function with NO return value * @brief Execute a call on the global function with NO return value
* @param[in] _interfaceClient Web interface to send data * @param[in] _interfaceClient Web interface to send data
* @param[in] _obj Buffer input call (that have parameter already check) * @param[in] _obj Message input call (that have parameter already check)
* @param[in] _func pointer on the function to call * @param[in] _func pointer on the function to call
*/ */
template <class... ZEUS_TYPES> template <class... ZEUS_TYPES>
void executeCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient, void executeCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
ememory::SharedPtr<zeus::BufferParameter> _obj, ememory::SharedPtr<zeus::message::Parameter> _obj,
void (*_func)(ZEUS_TYPES...)) { void (*_func)(ZEUS_TYPES...)) {
if (_obj == nullptr) { if (_obj == nullptr) {
return; return;
@ -79,8 +79,8 @@ namespace zeus {
template <class ZEUS_RETURN, class... ZEUS_TYPES> template <class ZEUS_RETURN, class... ZEUS_TYPES>
class AbstractFunctionTypeDirect: public zeus::AbstractFunction { class AbstractFunctionTypeDirect: public zeus::AbstractFunction {
protected: protected:
static const ParamType m_returnType; static const zeus::message::ParamType m_returnType;
static const ParamType m_paramType[sizeof...(ZEUS_TYPES)]; static const zeus::message::ParamType m_paramType[sizeof...(ZEUS_TYPES)];
public: public:
using functionType = ZEUS_RETURN (*)(ZEUS_TYPES...); using functionType = ZEUS_RETURN (*)(ZEUS_TYPES...);
functionType m_function; functionType m_function;
@ -104,7 +104,7 @@ namespace zeus {
return out; return out;
} }
void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient, void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
ememory::SharedPtr<zeus::BufferCall> _obj, ememory::SharedPtr<zeus::message::Call> _obj,
void* _class) override { void* _class) override {
if (_obj == nullptr) { if (_obj == nullptr) {
return; return;
@ -145,10 +145,10 @@ namespace zeus {
}; };
// specialization // specialization
template <class ZEUS_RETURN, class... ZEUS_TYPES> template <class ZEUS_RETURN, class... ZEUS_TYPES>
const ParamType AbstractFunctionTypeDirect<ZEUS_RETURN, ZEUS_TYPES...>::m_returnType = createType<ZEUS_RETURN>(); const zeus::message::ParamType AbstractFunctionTypeDirect<ZEUS_RETURN, ZEUS_TYPES...>::m_returnType = zeus::message::createType<ZEUS_RETURN>();
// specialization // specialization
template <class ZEUS_RETURN, class... ZEUS_TYPES> template <class ZEUS_RETURN, class... ZEUS_TYPES>
const ParamType AbstractFunctionTypeDirect<ZEUS_RETURN, ZEUS_TYPES...>::m_paramType[sizeof...(ZEUS_TYPES)] = {createType<ZEUS_TYPES>()...}; const zeus::message::ParamType AbstractFunctionTypeDirect<ZEUS_RETURN, ZEUS_TYPES...>::m_paramType[sizeof...(ZEUS_TYPES)] = {zeus::message::createType<ZEUS_TYPES>()...};
/** /**
* @brief Create a function information with the function type * @brief Create a function information with the function type
* @param[in] _name Name of the function * @param[in] _name Name of the function

View File

@ -27,7 +27,7 @@ zeus::Client::~Client() {
} }
void zeus::Client::onClientData(ememory::SharedPtr<zeus::Buffer> _value) { void zeus::Client::onClientData(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
@ -60,8 +60,8 @@ void zeus::Client::onClientData(ememory::SharedPtr<zeus::Buffer> _value) {
return; return;
} }
if (_value->getDestinationObjectId() == ZEUS_ID_GATEWAY_OBJECT) { if (_value->getDestinationObjectId() == ZEUS_ID_GATEWAY_OBJECT) {
if (_value->getType() == zeus::Buffer::typeMessage::call) { if (_value->getType() == zeus::message::type::call) {
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value); ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
std::string callFunction = callObj->getCall(); std::string callFunction = callObj->getCall();
if ( callFunction != "link" if ( callFunction != "link"
&& callFunction != "unlink") { && callFunction != "unlink") {

View File

@ -102,7 +102,7 @@ namespace zeus {
* @brief When receive data from the websocket ... call this ... * @brief When receive data from the websocket ... call this ...
* @param[in] _value New input buffer * @param[in] _value New input buffer
*/ */
void onClientData(ememory::SharedPtr<zeus::Buffer> _value); void onClientData(ememory::SharedPtr<zeus::Message> _value);
public: public:
/** /**
* @brief Create a call on the interface gateway (threw the router) * @brief Create a call on the interface gateway (threw the router)
@ -116,7 +116,7 @@ namespace zeus {
const std::string& _functionName, const std::string& _functionName,
_ARGS&&... _args) { _ARGS&&... _args) {
if (m_interfaceWeb == nullptr) { if (m_interfaceWeb == nullptr) {
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create(nullptr); // TODO : This is really a bad case ... ememory::SharedPtr<zeus::message::Answer> ret = zeus::message::Answer::create(nullptr); // TODO : This is really a bad case ...
ret->addError("NULLPTR", "call " + _functionName + " with no interface open"); ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
return zeus::FutureBase(0, ret); return zeus::FutureBase(0, ret);
} }

View File

@ -14,339 +14,339 @@ namespace zeus {
template<> template<>
bool zeus::Future<bool>::get() { bool zeus::Future<bool>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return false; return false;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return false; return false;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<bool>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<bool>();
} }
template<> template<>
int64_t zeus::Future<int64_t>::get() { int64_t zeus::Future<int64_t>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0; return 0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<bool>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<bool>();
} }
template<> template<>
int32_t zeus::Future<int32_t>::get() { int32_t zeus::Future<int32_t>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0; return 0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<int32_t>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<int32_t>();
} }
template<> template<>
int16_t zeus::Future<int16_t>::get() { int16_t zeus::Future<int16_t>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0; return 0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<int16_t>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<int16_t>();
} }
template<> template<>
int8_t zeus::Future<int8_t>::get() { int8_t zeus::Future<int8_t>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0; return 0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<int8_t>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<int8_t>();
} }
template<> template<>
uint64_t zeus::Future<uint64_t>::get() { uint64_t zeus::Future<uint64_t>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0; return 0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<int64_t>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<int64_t>();
} }
template<> template<>
uint32_t zeus::Future<uint32_t>::get() { uint32_t zeus::Future<uint32_t>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0; return 0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<uint32_t>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<uint32_t>();
} }
template<> template<>
uint16_t zeus::Future<uint16_t>::get() { uint16_t zeus::Future<uint16_t>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0; return 0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<uint16_t>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<uint16_t>();
} }
template<> template<>
uint8_t zeus::Future<uint8_t>::get() { uint8_t zeus::Future<uint8_t>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0; return 0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<uint8_t>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<uint8_t>();
} }
template<> template<>
double zeus::Future<double>::get() { double zeus::Future<double>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0; return 0;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0.0; return 0.0;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<double>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<double>();
} }
template<> template<>
float zeus::Future<float>::get() { float zeus::Future<float>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return 0.0f; return 0.0f;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return 0.0f; return 0.0f;
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<float>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<float>();
} }
template<> template<>
std::string zeus::Future<std::string>::get() { std::string zeus::Future<std::string>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return ""; return "";
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return ""; return "";
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::string>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::string>();
} }
template<> template<>
std::vector<int64_t> zeus::Future<std::vector<int64_t>>::get() { std::vector<int64_t> zeus::Future<std::vector<int64_t>>::get() {
std::vector<int64_t> out; std::vector<int64_t> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<int64_t>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<int64_t>>();
return out; return out;
} }
template<> template<>
std::vector<int32_t> zeus::Future<std::vector<int32_t>>::get() { std::vector<int32_t> zeus::Future<std::vector<int32_t>>::get() {
std::vector<int32_t> out; std::vector<int32_t> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<int32_t>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<int32_t>>();
return out; return out;
} }
template<> template<>
std::vector<int16_t> zeus::Future<std::vector<int16_t>>::get() { std::vector<int16_t> zeus::Future<std::vector<int16_t>>::get() {
std::vector<int16_t> out; std::vector<int16_t> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<int16_t>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<int16_t>>();
return out; return out;
} }
template<> template<>
std::vector<int8_t> zeus::Future<std::vector<int8_t>>::get() { std::vector<int8_t> zeus::Future<std::vector<int8_t>>::get() {
std::vector<int8_t> out; std::vector<int8_t> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<int8_t>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<int8_t>>();
return out; return out;
} }
template<> template<>
std::vector<uint64_t> zeus::Future<std::vector<uint64_t>>::get() { std::vector<uint64_t> zeus::Future<std::vector<uint64_t>>::get() {
std::vector<uint64_t> out; std::vector<uint64_t> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<uint64_t>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<uint64_t>>();
return out; return out;
} }
template<> template<>
std::vector<uint32_t> zeus::Future<std::vector<uint32_t>>::get() { std::vector<uint32_t> zeus::Future<std::vector<uint32_t>>::get() {
std::vector<uint32_t> out; std::vector<uint32_t> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<uint32_t>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<uint32_t>>();
return out; return out;
} }
template<> template<>
std::vector<uint16_t> zeus::Future<std::vector<uint16_t>>::get() { std::vector<uint16_t> zeus::Future<std::vector<uint16_t>>::get() {
std::vector<uint16_t> out; std::vector<uint16_t> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<uint16_t>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<uint16_t>>();
return out; return out;
} }
template<> template<>
std::vector<uint8_t> zeus::Future<std::vector<uint8_t>>::get() { std::vector<uint8_t> zeus::Future<std::vector<uint8_t>>::get() {
std::vector<uint8_t> out; std::vector<uint8_t> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<uint8_t>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<uint8_t>>();
return out; return out;
} }
template<> template<>
std::vector<double> zeus::Future<std::vector<double>>::get() { std::vector<double> zeus::Future<std::vector<double>>::get() {
std::vector<double> out; std::vector<double> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<double>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<double>>();
return out; return out;
} }
template<> template<>
std::vector<float> zeus::Future<std::vector<float>>::get() { std::vector<float> zeus::Future<std::vector<float>>::get() {
std::vector<float> out; std::vector<float> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<float>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<float>>();
return out; return out;
} }
template<> template<>
std::vector<std::string> zeus::Future<std::vector<std::string>>::get() { std::vector<std::string> zeus::Future<std::vector<std::string>>::get() {
std::vector<std::string> out; std::vector<std::string> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<std::string>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<std::string>>();
return out; return out;
} }
template<> template<>
std::vector<bool> zeus::Future<std::vector<bool>>::get() { std::vector<bool> zeus::Future<std::vector<bool>>::get() {
std::vector<bool> out; std::vector<bool> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<std::vector<bool>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<std::vector<bool>>();
return out; return out;
} }
template<> template<>
zeus::Raw zeus::Future<zeus::Raw>::get() { zeus::Raw zeus::Future<zeus::Raw>::get() {
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return zeus::Raw(); return zeus::Raw();
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return zeus::Raw(); return zeus::Raw();
} }
return static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<zeus::Raw>(); return static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<zeus::Raw>();
} }
template<> template<>
ememory::SharedPtr<zeus::ObjectRemoteBase> zeus::Future<ememory::SharedPtr<zeus::ObjectRemoteBase>>::get() { ememory::SharedPtr<zeus::ObjectRemoteBase> zeus::Future<ememory::SharedPtr<zeus::ObjectRemoteBase>>::get() {
ememory::SharedPtr<zeus::ObjectRemoteBase> out; ememory::SharedPtr<zeus::ObjectRemoteBase> out;
if ( m_promise == nullptr if ( m_promise == nullptr
|| m_promise->m_message == nullptr) { || m_promise->getRaw() == nullptr) {
return out; return out;
} }
if (m_promise->m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_promise->getRaw()->getType() != zeus::message::type::answer) {
ZEUS_WARNING("No Return value ..."); ZEUS_WARNING("No Return value ...");
return out; return out;
} }
out = static_cast<zeus::message::Answer*>(m_promise->m_message.get())->getAnswer<ememory::SharedPtr<zeus::ObjectRemoteBase>>(); out = static_cast<zeus::message::Answer*>(m_promise->getRaw().get())->getAnswer<ememory::SharedPtr<zeus::ObjectRemoteBase>>();
return out; return out;
} }
} }

View File

@ -21,14 +21,18 @@ zeus::FutureBase::FutureBase(uint32_t _transactionId, uint32_t _source) {
m_promise = ememory::makeShared<zeus::Promise>(_transactionId, _source); m_promise = ememory::makeShared<zeus::Promise>(_transactionId, _source);
} }
ememory::SharedPtr<zeus::message::Message> zeus::FutureBase::getRaw() { zeus::FutureBase::FutureBase(ememory::SharedPtr<zeus::Promise> _promise) {
m_promise = _promise;
}
ememory::SharedPtr<zeus::Message> zeus::FutureBase::getRaw() {
if (m_promise == nullptr) { if (m_promise == nullptr) {
return nullptr; return nullptr;
} }
return m_promise->getRaw(); return m_promise->getRaw();
} }
zeus::FutureBase::FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::message::Message> _returnData, uint32_t _source) { zeus::FutureBase::FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::Message> _returnData, uint32_t _source) {
m_promise = ememory::makeShared<zeus::Promise>(_transactionId, _returnData, _source); m_promise = ememory::makeShared<zeus::Promise>(_transactionId, _returnData, _source);
} }
@ -66,12 +70,12 @@ zeus::FutureBase zeus::FutureBase::operator= (const zeus::FutureBase& _base) {
return *this; return *this;
} }
bool zeus::FutureBase::setBuffer(ememory::SharedPtr<zeus::message::Message> _value) { bool zeus::FutureBase::setMessage(ememory::SharedPtr<zeus::Message> _value) {
if (m_promise == nullptr) { if (m_promise == nullptr) {
ZEUS_ERROR(" Not a valid future ..."); ZEUS_ERROR(" Not a valid future ...");
return true; return true;
} }
return m_promise->setBuffer(_value); return m_promise->setMessage(_value);
} }
uint32_t zeus::FutureBase::getTransactionId() const { uint32_t zeus::FutureBase::getTransactionId() const {
@ -106,7 +110,7 @@ std::string zeus::FutureBase::getErrorHelp() const {
if (m_promise == nullptr) { if (m_promise == nullptr) {
return "This is a nullptr future"; return "This is a nullptr future";
} }
m_promise->getErrorHelp(); return m_promise->getErrorHelp();
} }
bool zeus::FutureBase::isValid() const { bool zeus::FutureBase::isValid() const {
@ -124,7 +128,7 @@ const zeus::FutureBase& zeus::FutureBase::wait() const {
if (m_promise == nullptr) { if (m_promise == nullptr) {
return *this; return *this;
} }
m_promise.waitFor(echrono::seconds(5)); m_promise->waitFor(echrono::seconds(5));
return *this; return *this;
} }
@ -132,7 +136,7 @@ const zeus::FutureBase& zeus::FutureBase::waitFor(echrono::Duration _delta) cons
if (m_promise == nullptr) { if (m_promise == nullptr) {
return *this; return *this;
} }
m_promise.waitFor(_delta); m_promise->waitFor(_delta);
return *this; return *this;
} }
@ -140,7 +144,7 @@ const zeus::FutureBase& zeus::FutureBase::waitUntil(echrono::Steady _endTime) co
if (m_promise == nullptr) { if (m_promise == nullptr) {
return *this; return *this;
} }
m_promise.waitUntil(_endTime); m_promise->waitUntil(_endTime);
return *this; return *this;
} }

View File

@ -20,6 +20,11 @@ namespace zeus {
* @param[in] _base the FutureBase to copy * @param[in] _base the FutureBase to copy
*/ */
FutureBase(const zeus::FutureBase& _base); FutureBase(const zeus::FutureBase& _base);
/**
* @brief Copy contructor of a FutureBase
* @param[in] _base the FutureBase to copy
*/
FutureBase(ememory::SharedPtr<zeus::Promise> _promise);
/** /**
* @brief contructor of a FutureBase * @brief contructor of a FutureBase
*/ */
@ -37,7 +42,7 @@ namespace zeus {
* @param[in] _returnData Set return value * @param[in] _returnData Set return value
* @param[in] _source Source that is waiting for answer * @param[in] _source Source that is waiting for answer
*/ */
FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::message::Message> _returnData, uint32_t _source=0); FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::Message> _returnData, uint32_t _source=0);
/** /**
* @brief Attach callback on all return type of value * @brief Attach callback on all return type of value
* @param[in] _callback Handle on the function to call in all case * @param[in] _callback Handle on the function to call in all case
@ -71,7 +76,7 @@ namespace zeus {
* @param[in] _returnValue Returned buffer * @param[in] _returnValue Returned buffer
* @return return true if an error occured * @return return true if an error occured
*/ */
bool setBuffer(ememory::SharedPtr<zeus::message::Message> _returnValue); bool setMessage(ememory::SharedPtr<zeus::Message> _returnValue);
/** /**
* @brief Get the transaction Id of the Future * @brief Get the transaction Id of the Future
* @return Transaction Id requested or 0 * @return Transaction Id requested or 0
@ -125,10 +130,10 @@ namespace zeus {
*/ */
const FutureBase& waitUntil(echrono::Steady _endTime) const; const FutureBase& waitUntil(echrono::Steady _endTime) const;
/** /**
* @brief Get the Buffer receive * @brief Get the Message receive
* @return pointer on the receive data * @return pointer on the receive data
*/ */
ememory::SharedPtr<zeus::message::Message> getRaw(); ememory::SharedPtr<zeus::Message> getRaw();
/** /**
* @brief Get duration of the current trasaction take * @brief Get duration of the current trasaction take
* @return Tile in nanosecond to wait answer * @return Tile in nanosecond to wait answer

View File

@ -23,7 +23,7 @@ zeus::Object::~Object() {
} }
void zeus::Object::receive(ememory::SharedPtr<zeus::Buffer> _value) { void zeus::Object::receive(ememory::SharedPtr<zeus::Message> _value) {
if (_value == nullptr) { if (_value == nullptr) {
return; return;
} }
@ -41,20 +41,20 @@ void zeus::Object::receive(ememory::SharedPtr<zeus::Buffer> _value) {
} }
} }
void zeus::Object::callBinary(ememory::SharedPtr<zeus::Buffer> _obj) { void zeus::Object::callBinary(ememory::SharedPtr<zeus::Message> _obj) {
if (_obj == nullptr) { if (_obj == nullptr) {
return; return;
} }
if (_obj->getType() == zeus::Buffer::typeMessage::event) { if (_obj->getType() == zeus::message::type::event) {
ZEUS_ERROR("Unknow event: '...'"); ZEUS_ERROR("Unknow event: '...'");
return; return;
} }
if (_obj->getType() == zeus::Buffer::typeMessage::answer) { if (_obj->getType() == zeus::message::type::answer) {
ZEUS_ERROR("Local Answer: '...'"); ZEUS_ERROR("Local Answer: '...'");
return; return;
} }
if (_obj->getType() == zeus::Buffer::typeMessage::call) { if (_obj->getType() == zeus::message::type::call) {
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_obj); ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_obj);
uint32_t source = callObj->getSource(); uint32_t source = callObj->getSource();
uint32_t sourceId = callObj->getSourceId(); uint32_t sourceId = callObj->getSourceId();
std::string callFunction = callObj->getCall(); std::string callFunction = callObj->getCall();

View File

@ -44,20 +44,20 @@ namespace zeus {
*/ */
virtual ~Object(); virtual ~Object();
public: public:
void receive(ememory::SharedPtr<zeus::Buffer> _value); void receive(ememory::SharedPtr<zeus::Message> _value);
private: private:
/** /**
* @brief * @brief
* @param[in] * @param[in]
* @return * @return
*/ */
void callBinary(ememory::SharedPtr<zeus::Buffer> _obj); void callBinary(ememory::SharedPtr<zeus::Message> _obj);
/** /**
* @brief * @brief
* @param[in] * @param[in]
* @return * @return
*/ */
virtual void callBinary2(const std::string& _call, ememory::SharedPtr<zeus::BufferCall> _obj) = 0; virtual void callBinary2(const std::string& _call, ememory::SharedPtr<zeus::message::Call> _obj) = 0;
public: public:
/** /**
* @brief * @brief
@ -163,7 +163,7 @@ namespace zeus {
* @param[in] * @param[in]
* @return * @return
*/ */
void callBinary2(const std::string& _call, ememory::SharedPtr<zeus::BufferCall> _obj) { void callBinary2(const std::string& _call, ememory::SharedPtr<zeus::message::Call> _obj) {
for (auto &it2 : m_listFunction) { for (auto &it2 : m_listFunction) {
if (it2 == nullptr) { if (it2 == nullptr) {
continue; continue;

View File

@ -4,42 +4,42 @@
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#include <zeus/SystemProxy.hpp> #include <zeus/ObjectIntrospect.hpp>
zeus::SystemProxy::SystemProxy(zeus::ObjectRemote& _srv): zeus::ObjectIntrospect::ObjectIntrospect(zeus::ObjectRemote& _srv):
m_srv(_srv) { m_srv(_srv) {
} }
zeus::Future<std::string> zeus::SystemProxy::getDescription() { zeus::Future<std::string> zeus::ObjectIntrospect::getDescription() {
return m_srv.call("sys.getDescription"); return m_srv.call("sys.getDescription");
} }
zeus::Future<std::string> zeus::SystemProxy::getVersion() { zeus::Future<std::string> zeus::ObjectIntrospect::getVersion() {
return m_srv.call("sys.getVersion"); return m_srv.call("sys.getVersion");
} }
zeus::Future<std::string> zeus::SystemProxy::getType() { zeus::Future<std::string> zeus::ObjectIntrospect::getType() {
return m_srv.call("sys.getType"); return m_srv.call("sys.getType");
} }
zeus::Future<std::vector<std::string>> zeus::SystemProxy::getExtention() { zeus::Future<std::vector<std::string>> zeus::ObjectIntrospect::getExtention() {
return m_srv.call("sys.getExtention"); return m_srv.call("sys.getExtention");
} }
zeus::Future<std::vector<std::string>> zeus::SystemProxy::getAuthors() { zeus::Future<std::vector<std::string>> zeus::ObjectIntrospect::getAuthors() {
return m_srv.call("sys.getAuthors"); return m_srv.call("sys.getAuthors");
} }
zeus::Future<std::vector<std::string>> zeus::SystemProxy::getFunctions() { zeus::Future<std::vector<std::string>> zeus::ObjectIntrospect::getFunctions() {
return m_srv.call("sys.getFunctions"); return m_srv.call("sys.getFunctions");
} }
zeus::Future<std::string> zeus::SystemProxy::getFunctionPrototype(std::string _functionName) { zeus::Future<std::string> zeus::ObjectIntrospect::getFunctionPrototype(std::string _functionName) {
return m_srv.call("sys.getFunctionPrototype", _functionName); return m_srv.call("sys.getFunctionPrototype", _functionName);
} }
zeus::Future<std::string> zeus::SystemProxy::getFunctionDescription(std::string _functionName) { zeus::Future<std::string> zeus::ObjectIntrospect::getFunctionDescription(std::string _functionName) {
return m_srv.call("sys.getFunctionDescription", _functionName); return m_srv.call("sys.getFunctionDescription", _functionName);
} }

View File

@ -8,11 +8,11 @@
#include <zeus/ObjectRemote.hpp> #include <zeus/ObjectRemote.hpp>
namespace zeus { namespace zeus {
class SystemProxy { class ObjectIntrospect {
protected: protected:
zeus::ObjectRemote& m_srv; //!< Service instance handle zeus::ObjectRemote& m_srv; //!< Service instance handle
public: public:
SystemProxy(zeus::ObjectRemote& _srv); ObjectIntrospect(zeus::ObjectRemote& _srv);
zeus::Future<std::string> getDescription(); zeus::Future<std::string> getDescription();
zeus::Future<std::string> getVersion(); zeus::Future<std::string> getVersion();
zeus::Future<std::string> getType(); zeus::Future<std::string> getType();

View File

@ -99,7 +99,7 @@ namespace zeus {
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) { zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
if ( m_interface == nullptr if ( m_interface == nullptr
|| m_interface->m_interfaceWeb == nullptr) { || m_interface->m_interfaceWeb == nullptr) {
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create(nullptr); // TODO : This is a real bad case ... ememory::SharedPtr<zeus::message::Answer> ret = zeus::message::Answer::create(nullptr); // TODO : This is a real bad case ...
if (ret != nullptr) { if (ret != nullptr) {
ret->addError("NULLPTR", "call " + _functionName + " with no interface open"); ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
} }

View File

@ -4,6 +4,7 @@
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#include <zeus/Promise.hpp> #include <zeus/Promise.hpp>
#include <zeus/FutureBase.hpp>
#include <zeus/message/Answer.hpp> #include <zeus/message/Answer.hpp>
#include <zeus/debug.hpp> #include <zeus/debug.hpp>
@ -14,11 +15,11 @@ zeus::Promise::Promise(uint32_t _transactionId, uint32_t _source) {
m_source = _source; m_source = _source;
} }
ememory::SharedPtr<zeus::message::Message> zeus::Promise::getRaw() { ememory::SharedPtr<zeus::Message> zeus::Promise::getRaw() {
return m_message; return m_message;
} }
zeus::Promise::Promise(uint32_t _transactionId, ememory::SharedPtr<zeus::message::Message> _returnData, uint32_t _source) { zeus::Promise::Promise(uint32_t _transactionId, ememory::SharedPtr<zeus::Message> _returnData, uint32_t _source) {
m_sendTime = echrono::Steady::now(); m_sendTime = echrono::Steady::now();
m_transactionId = _transactionId; m_transactionId = _transactionId;
m_source = _source; m_source = _source;
@ -37,11 +38,11 @@ void zeus::Promise::andAll(zeus::Promise::Observer _callback) {
} }
if (hasError() == false) { if (hasError() == false) {
if (m_callbackThen != nullptr) { if (m_callbackThen != nullptr) {
m_callbackThen(*this); m_callbackThen(zeus::FutureBase(sharedFromThis()));
} }
} else { } else {
if (m_callbackElse != nullptr) { if (m_callbackElse != nullptr) {
m_callbackElse(*this); m_callbackElse(zeus::FutureBase(sharedFromThis()));
} }
} }
} }
@ -58,7 +59,7 @@ void zeus::Promise::andThen(zeus::Promise::Observer _callback) {
if (m_callbackThen == nullptr) { if (m_callbackThen == nullptr) {
return; return;
} }
m_callbackThen(*this); m_callbackThen(zeus::FutureBase(sharedFromThis()));
} }
void zeus::Promise::andElse(zeus::Promise::Observer _callback) { void zeus::Promise::andElse(zeus::Promise::Observer _callback) {
@ -73,7 +74,7 @@ void zeus::Promise::andElse(zeus::Promise::Observer _callback) {
if (m_callbackElse == nullptr) { if (m_callbackElse == nullptr) {
return; return;
} }
m_callbackElse(*this); m_callbackElse(zeus::FutureBase(sharedFromThis()));
} }
@ -84,7 +85,7 @@ echrono::Duration zeus::Promise::getTransmitionTime() const {
return m_receiveTime - m_sendTime; return m_receiveTime - m_sendTime;
} }
bool zeus::Promise::setBuffer(ememory::SharedPtr<zeus::message::Message> _value) { bool zeus::Promise::setMessage(ememory::SharedPtr<zeus::Message> _value) {
m_receiveTime = echrono::Steady::now(); m_receiveTime = echrono::Steady::now();
m_message = _value; m_message = _value;
if (m_message == nullptr) { if (m_message == nullptr) {
@ -96,11 +97,11 @@ bool zeus::Promise::setBuffer(ememory::SharedPtr<zeus::message::Message> _value)
} }
if (hasError() == false) { if (hasError() == false) {
if (m_callbackThen != nullptr) { if (m_callbackThen != nullptr) {
return m_callbackThen(*this); return m_callbackThen(zeus::FutureBase(sharedFromThis()));
} }
} else { } else {
if (m_callbackElse != nullptr) { if (m_callbackElse != nullptr) {
return m_callbackElse(*this); return m_callbackElse(zeus::FutureBase(sharedFromThis()));
} }
} }
return true; return true;
@ -118,7 +119,7 @@ bool zeus::Promise::hasError() const {
if (m_message == nullptr) { if (m_message == nullptr) {
return true; return true;
} }
if (m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_message->getType() != zeus::message::type::answer) {
return true; return true;
} }
return static_cast<const zeus::message::Answer*>(m_message.get())->hasError(); return static_cast<const zeus::message::Answer*>(m_message.get())->hasError();
@ -128,7 +129,7 @@ std::string zeus::Promise::getErrorType() const {
if (m_message == nullptr) { if (m_message == nullptr) {
return "NULL_PTR"; return "NULL_PTR";
} }
if (m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_message->getType() != zeus::message::type::answer) {
return "NOT_ANSWER_MESSAGE"; return "NOT_ANSWER_MESSAGE";
} }
return static_cast<const zeus::message::Answer*>(m_message.get())->getError(); return static_cast<const zeus::message::Answer*>(m_message.get())->getError();
@ -138,7 +139,7 @@ std::string zeus::Promise::getErrorHelp() const {
if (m_message == nullptr) { if (m_message == nullptr) {
return "This is a nullptr future"; return "This is a nullptr future";
} }
if (m_message->getType() != zeus::message::Message::typeMessage::answer) { if (m_message->getType() != zeus::message::type::answer) {
return "This answer is not a anwser type"; return "This answer is not a anwser type";
} }
return static_cast<const zeus::message::Answer*>(m_message.get())->getErrorHelp(); return static_cast<const zeus::message::Answer*>(m_message.get())->getErrorHelp();
@ -153,15 +154,14 @@ bool zeus::Promise::isFinished() const {
return m_message->getPartFinish(); return m_message->getPartFinish();
} }
const zeus::Promise& zeus::Promise::wait() const { void zeus::Promise::wait() const {
while (isFinished() == false) { while (isFinished() == false) {
// TODO : Do it better ... like messaging/mutex_locked ... // TODO : Do it better ... like messaging/mutex_locked ...
std::this_thread::sleep_for(echrono::milliseconds(10)); std::this_thread::sleep_for(echrono::milliseconds(10));
} }
return *this;
} }
const zeus::Promise& zeus::Promise::waitFor(echrono::Duration _delta) const { void zeus::Promise::waitFor(echrono::Duration _delta) const {
echrono::Steady start = echrono::Steady::now(); echrono::Steady start = echrono::Steady::now();
while ( echrono::Steady::now() - start < _delta while ( echrono::Steady::now() - start < _delta
&& isFinished() == false) { && isFinished() == false) {
@ -169,15 +169,13 @@ const zeus::Promise& zeus::Promise::waitFor(echrono::Duration _delta) const {
std::this_thread::sleep_for(echrono::milliseconds(10)); std::this_thread::sleep_for(echrono::milliseconds(10));
start = echrono::Steady::now(); start = echrono::Steady::now();
} }
return *this;
} }
const zeus::Promise& zeus::Promise::waitUntil(echrono::Steady _endTime) const { void zeus::Promise::waitUntil(echrono::Steady _endTime) const {
while ( echrono::Steady::now() < _endTime while ( echrono::Steady::now() < _endTime
&& isFinished() == false) { && isFinished() == false) {
// TODO : Do it better ... like messaging/mutex_locked ... // TODO : Do it better ... like messaging/mutex_locked ...
std::this_thread::sleep_for(echrono::milliseconds(10)); std::this_thread::sleep_for(echrono::milliseconds(10));
} }
return *this;
} }

View File

@ -9,6 +9,8 @@
#include <zeus/message/Message.hpp> #include <zeus/message/Message.hpp>
#include <functional> #include <functional>
#include <ememory/memory.hpp> #include <ememory/memory.hpp>
#include <echrono/Steady.hpp>
#include <echrono/Duration.hpp>
namespace zeus { namespace zeus {
@ -16,13 +18,13 @@ namespace zeus {
/** /**
* @brief Data interface of the future (the future can be copied, but the data need to stay... * @brief Data interface of the future (the future can be copied, but the data need to stay...
*/ */
class Promise { class Promise : public ememory::EnableSharedFromThis<zeus::Promise> {
public: public:
using Observer = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer using Observer = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer
private: private:
uint32_t m_transactionId; //!< waiting answer data uint32_t m_transactionId; //!< waiting answer data
uint32_t m_source; //!< Source of the message. uint32_t m_source; //!< Source of the message.
ememory::SharedPtr<zeus::message::Message> m_message; //!< all buffer concatenate or last buffer if synchronous ememory::SharedPtr<zeus::Message> m_message; //!< all buffer concatenate or last buffer if synchronous
Observer m_callbackThen; //!< observer callback When data arrive and NO error appear Observer m_callbackThen; //!< observer callback When data arrive and NO error appear
Observer m_callbackElse; //!< observer callback When data arrive and AN error appear Observer m_callbackElse; //!< observer callback When data arrive and AN error appear
//Observer m_callbackAbort; //!< observer callback When Action is abort by user //Observer m_callbackAbort; //!< observer callback When Action is abort by user
@ -42,7 +44,7 @@ namespace zeus {
* @param[in] _returnData Set return value * @param[in] _returnData Set return value
* @param[in] _source Source that is waiting for answer * @param[in] _source Source that is waiting for answer
*/ */
Promise(uint32_t _transactionId, ememory::SharedPtr<zeus::message::Message> _returnData, uint32_t _source=0); Promise(uint32_t _transactionId, ememory::SharedPtr<zeus::Message> _returnData, uint32_t _source=0);
/** /**
* @brief Attach callback on all return type of value * @brief Attach callback on all return type of value
* @param[in] _callback Handle on the function to call in all case * @param[in] _callback Handle on the function to call in all case
@ -70,7 +72,7 @@ namespace zeus {
* @param[in] _returnValue Returned buffer * @param[in] _returnValue Returned buffer
* @return return true if an error occured * @return return true if an error occured
*/ */
bool setBuffer(ememory::SharedPtr<zeus::message::Message> _returnValue); bool setMessage(ememory::SharedPtr<zeus::Message> _returnValue);
/** /**
* @brief Get the transaction Id of the Future * @brief Get the transaction Id of the Future
* @return Transaction Id requested or 0 * @return Transaction Id requested or 0
@ -105,24 +107,24 @@ namespace zeus {
* @brief Wait the Future receive data * @brief Wait the Future receive data
* @return reference on the current futur * @return reference on the current futur
*/ */
const FutureBase& wait() const; void wait() const;
/** /**
* @brief Wait the Future receive data * @brief Wait the Future receive data
* @param[in] _delta delay to wait the data arrive * @param[in] _delta delay to wait the data arrive
* @return reference on the current futur * @return reference on the current futur
*/ */
const FutureBase& waitFor(echrono::Duration _delta = echrono::seconds(30)) const; void waitFor(echrono::Duration _delta = echrono::seconds(30)) const;
/** /**
* @brief Wait the Future receive data * @brief Wait the Future receive data
* @param[in] _endTime tiem to wait the data * @param[in] _endTime tiem to wait the data
* @return reference on the current futur * @return reference on the current futur
*/ */
const FutureBase& waitUntil(echrono::Steady _endTime) const; void waitUntil(echrono::Steady _endTime) const;
/** /**
* @brief Get the Buffer receive * @brief Get the Message receive
* @return pointer on the receive data * @return pointer on the receive data
*/ */
ememory::SharedPtr<zeus::message::Message> getRaw(); ememory::SharedPtr<zeus::Message> getRaw();
/** /**
* @brief Get duration of the current trasaction take * @brief Get duration of the current trasaction take
* @return Tile in nanosecond to wait answer * @return Tile in nanosecond to wait answer

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <zeus/ObjectRemote.hpp> #include <zeus/ObjectRemote.hpp>
#include <zeus/ObjectIntrospection.hpp> #include <zeus/ObjectIntrospect.hpp>
namespace zeus { namespace zeus {
/** /**
@ -16,7 +16,7 @@ namespace zeus {
protected: protected:
zeus::ObjectRemote m_obj; //!< Service instance handle zeus::ObjectRemote m_obj; //!< Service instance handle
public: public:
zeus::ObjectIntrospection sys; zeus::ObjectIntrospect sys;
public: public:
const Proxy& operator= (const zeus::ObjectRemote& _srv); const Proxy& operator= (const zeus::ObjectRemote& _srv);
Proxy(); Proxy();

View File

@ -9,7 +9,7 @@
namespace zeus { namespace zeus {
/** /**
* @brief Raw data Buffer * @brief Raw data Message
*/ */
class Raw { class Raw {
private: private:

View File

@ -26,7 +26,7 @@ namespace zeus {
uint32_t getFullId() { uint32_t getFullId() {
return (uint32_t(m_id) << 16 ) + m_objectId; return (uint32_t(m_id) << 16 ) + m_objectId;
} }
virtual void receive(ememory::SharedPtr<zeus::Buffer> _value) { virtual void receive(ememory::SharedPtr<zeus::Message> _value) {
ZEUS_ERROR("Receive a message ==> not implemented magaging ..." << _value); ZEUS_ERROR("Receive a message ==> not implemented magaging ..." << _value);
} }

View File

@ -8,11 +8,10 @@
#include <ethread/tools.hpp> #include <ethread/tools.hpp>
#include <zeus/message/Data.hpp> #include <zeus/message/Data.hpp>
#include <zeus/message/Ctrl.hpp>
ememory::SharedPtr<zeus::BufferCall> zeus::createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName) { ememory::SharedPtr<zeus::message::Call> zeus::createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName) {
ememory::SharedPtr<zeus::BufferCall> obj = zeus::BufferCall::create(_iface); ememory::SharedPtr<zeus::message::Call> obj = zeus::message::Call::create(_iface);
if (obj == nullptr) { if (obj == nullptr) {
return nullptr; return nullptr;
} }
@ -23,7 +22,7 @@ ememory::SharedPtr<zeus::BufferCall> zeus::createBaseCall(const ememory::SharedP
return obj; return obj;
} }
void zeus::createParam(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _paramId, ememory::SharedPtr<zeus::BufferCall> _obj) { void zeus::createParam(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _paramId, ememory::SharedPtr<zeus::message::Call> _obj) {
// Finish recursive parse ... // Finish recursive parse ...
} }
@ -73,10 +72,18 @@ void zeus::WebServer::setInterface(enet::Tcp _connection, bool _isServer, const
} }
zeus::WebServer::~WebServer() { zeus::WebServer::~WebServer() {
ZEUS_WARNING("destroy WebServer ... [START]");
ZEUS_INFO("disconnect ...");
disconnect(); disconnect();
ZEUS_WARNING("disconnect (done) ");
ZEUS_INFO("stop thread pool ...");
m_processingPool.stop(); m_processingPool.stop();
ZEUS_INFO("stop thread pool (done)");
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // TODO : Remove this ... std::this_thread::sleep_for(std::chrono::milliseconds(100)); // TODO : Remove this ...
ZEUS_INFO("stop thread join ...");
m_processingPool.join(); m_processingPool.join();
ZEUS_INFO("stop thread join (done)");
ZEUS_WARNING("destroy WebServer ... [STOP]");
} }
void zeus::WebServer::setInterfaceName(const std::string& _name) { void zeus::WebServer::setInterfaceName(const std::string& _name) {
@ -160,7 +167,7 @@ class SendAsyncBinary {
m_partId++; m_partId++;
} }
if (m_async.size() == 0) { if (m_async.size() == 0) {
ememory::SharedPtr<zeus::BufferData> obj = zeus::BufferData::create(_interface->sharedFromThis()); ememory::SharedPtr<zeus::message::Data> obj = zeus::message::Data::create(_interface->sharedFromThis());
if (obj == nullptr) { if (obj == nullptr) {
return true; return true;
} }
@ -181,7 +188,7 @@ class SendAsyncBinary {
//#define ZEUS_LOG_INPUT_OUTPUT ZEUS_VERBOSE //#define ZEUS_LOG_INPUT_OUTPUT ZEUS_VERBOSE
int32_t zeus::WebServer::writeBinary(ememory::SharedPtr<zeus::Buffer> _obj) { int32_t zeus::WebServer::writeBinary(ememory::SharedPtr<zeus::Message> _obj) {
if (m_connection.isAlive() == false) { if (m_connection.isAlive() == false) {
return -2; return -2;
} }
@ -225,9 +232,9 @@ void zeus::WebServer::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary
disconnect(true); disconnect(true);
return; return;
} }
ememory::SharedPtr<zeus::Buffer> dataRaw = zeus::Buffer::create(sharedFromThis(), _frame); ememory::SharedPtr<zeus::Message> dataRaw = zeus::Message::create(sharedFromThis(), _frame);
if (dataRaw == nullptr) { if (dataRaw == nullptr) {
ZEUS_ERROR("Buffer Allocation ERROR ... "); ZEUS_ERROR("Message Allocation ERROR ... ");
disconnect(true); disconnect(true);
return; return;
} }
@ -239,14 +246,14 @@ void zeus::WebServer::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary
return; return;
} }
dataRaw->setInterfaceId(m_interfaceId); dataRaw->setInterfaceId(m_interfaceId);
newBuffer(dataRaw); newMessage(dataRaw);
} }
void zeus::WebServer::ping() { void zeus::WebServer::ping() {
m_connection.controlPing(); m_connection.controlPing();
} }
void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) { void zeus::WebServer::newMessage(ememory::SharedPtr<zeus::Message> _buffer) {
ZEUS_LOG_INPUT_OUTPUT("Receive :" << _buffer); ZEUS_LOG_INPUT_OUTPUT("Receive :" << _buffer);
// if an adress id different ... just transmit it ... // if an adress id different ... just transmit it ...
if (m_localAddress != _buffer->getDestinationId()) { if (m_localAddress != _buffer->getDestinationId()) {
@ -262,16 +269,16 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
return; return;
} }
if ( _buffer->getPartFinish() == false if ( _buffer->getPartFinish() == false
&& _buffer->getType() != zeus::Buffer::typeMessage::data) { && _buffer->getType() != zeus::message::type::data) {
m_listPartialBuffer.push_back(_buffer); m_listPartialMessage.push_back(_buffer);
return; return;
} }
if (_buffer->getType() == zeus::Buffer::typeMessage::data) { if (_buffer->getType() == zeus::message::type::data) {
// Add data in a previous buffer... // Add data in a previous buffer...
auto it = m_listPartialBuffer.begin(); auto it = m_listPartialMessage.begin();
while (it != m_listPartialBuffer.end()) { while (it != m_listPartialMessage.end()) {
if (*it == nullptr) { if (*it == nullptr) {
it = m_listPartialBuffer.erase(it); it = m_listPartialMessage.erase(it);
continue; continue;
} }
if ((*it)->getDestination() != _buffer->getDestination()) { if ((*it)->getDestination() != _buffer->getDestination()) {
@ -279,13 +286,13 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
continue; continue;
} }
if ((*it)->getTransactionId() == _buffer->getTransactionId()) { if ((*it)->getTransactionId() == _buffer->getTransactionId()) {
(*it)->appendBuffer(_buffer); (*it)->appendMessage(_buffer);
if (_buffer->getPartFinish() != true) { if (_buffer->getPartFinish() != true) {
return; return;
} }
(*it)->setPartFinish(true); (*it)->setPartFinish(true);
_buffer = *it; _buffer = *it;
it = m_listPartialBuffer.erase(it); it = m_listPartialMessage.erase(it);
break; break;
} }
} }
@ -299,8 +306,8 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
zeus::FutureBase future; zeus::FutureBase future;
uint64_t tid = _buffer->getTransactionId(); uint64_t tid = _buffer->getTransactionId();
// TODO : Check the UDI reaaly utility ... // TODO : Check the UDI reaaly utility ...
if ( _buffer->getType() == zeus::Buffer::typeMessage::answer if ( _buffer->getType() == zeus::message::type::answer
|| _buffer->getType() == zeus::Buffer::typeMessage::data) { || _buffer->getType() == zeus::message::type::data) {
std::unique_lock<std::mutex> lock(m_pendingCallMutex); std::unique_lock<std::mutex> lock(m_pendingCallMutex);
auto it = m_pendingCall.begin(); auto it = m_pendingCall.begin();
while (it != m_pendingCall.end()) { while (it != m_pendingCall.end()) {
@ -351,7 +358,7 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
zeus::FutureBase fut = future; zeus::FutureBase fut = future;
ZEUS_INFO("PROCESS FUTURE : " << _buffer); ZEUS_INFO("PROCESS FUTURE : " << _buffer);
// add data ... // add data ...
bool ret = fut.setBuffer(_buffer); bool ret = fut.setMessage(_buffer);
if (ret == true) { if (ret == true) {
std::unique_lock<std::mutex> lock(m_pendingCallMutex); std::unique_lock<std::mutex> lock(m_pendingCallMutex);
auto it = m_pendingCall.begin(); auto it = m_pendingCall.begin();
@ -412,11 +419,11 @@ void zeus::WebServer::threadAsyncCallback() {
zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId, zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId,
ememory::SharedPtr<zeus::Buffer> _obj, ememory::SharedPtr<zeus::Message> _obj,
const uint32_t& _destination) { const uint32_t& _destination) {
if (isActive() == false) { if (isActive() == false) {
ZEUS_ERROR("Send [STOP] ==> not connected (no TCP)"); ZEUS_ERROR("Send [STOP] ==> not connected (no TCP)");
ememory::SharedPtr<zeus::BufferAnswer> obj = zeus::BufferAnswer::create(sharedFromThis()); ememory::SharedPtr<zeus::message::Answer> obj = zeus::message::Answer::create(sharedFromThis());
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)"); obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
return zeus::FutureBase(_transactionId, obj); return zeus::FutureBase(_transactionId, obj);
} }
@ -431,7 +438,7 @@ zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId,
/* /*
void zeus::WebServer::sendCtrl(uint32_t _source, uint32_t _destination, const std::string& _ctrlValue) { void zeus::WebServer::sendCtrl(uint32_t _source, uint32_t _destination, const std::string& _ctrlValue) {
auto ctrl = zeus::BufferCtrl::create(sharedFromThis()); auto ctrl = zeus::MessageCtrl::create(sharedFromThis());
if (ctrl == nullptr) { if (ctrl == nullptr) {
return; return;
} }
@ -444,7 +451,7 @@ void zeus::WebServer::sendCtrl(uint32_t _source, uint32_t _destination, const st
*/ */
void zeus::WebServer::answerError(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, const std::string& _errorValue, const std::string& _errorHelp) { void zeus::WebServer::answerError(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, const std::string& _errorValue, const std::string& _errorHelp) {
auto answer = zeus::BufferAnswer::create(sharedFromThis()); auto answer = zeus::message::Answer::create(sharedFromThis());
if (answer == nullptr) { if (answer == nullptr) {
return; return;
} }
@ -457,7 +464,7 @@ void zeus::WebServer::answerError(uint32_t _clientTransactionId, uint32_t _sourc
void zeus::WebServer::answerVoid(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination) { void zeus::WebServer::answerVoid(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination) {
auto answer = zeus::BufferAnswer::create(sharedFromThis()); auto answer = zeus::message::Answer::create(sharedFromThis());
if (answer == nullptr) { if (answer == nullptr) {
return; return;
} }

View File

@ -30,7 +30,7 @@ namespace zeus {
* @param[in] * @param[in]
* @return * @return
*/ */
ememory::SharedPtr<zeus::BufferCall> createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface, ememory::SharedPtr<zeus::message::Call> createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface,
uint64_t _transactionId, uint64_t _transactionId,
const uint32_t& _source, const uint32_t& _source,
const uint32_t& _destination, const uint32_t& _destination,
@ -42,7 +42,7 @@ namespace zeus {
*/ */
void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface, void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface,
int32_t _paramId, int32_t _paramId,
ememory::SharedPtr<zeus::BufferCall> _obj); ememory::SharedPtr<zeus::message::Call> _obj);
/** /**
* @brief * @brief
@ -52,7 +52,7 @@ namespace zeus {
template<class ZEUS_TYPE, class... _ARGS> template<class ZEUS_TYPE, class... _ARGS>
void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface, void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface,
int32_t _paramId, int32_t _paramId,
ememory::SharedPtr<zeus::BufferCall> _obj, ememory::SharedPtr<zeus::message::Call> _obj,
const ZEUS_TYPE& _param, const ZEUS_TYPE& _param,
_ARGS&&... _args) { _ARGS&&... _args) {
_obj->addParameter<ZEUS_TYPE>(_iface, _param); _obj->addParameter<ZEUS_TYPE>(_iface, _param);
@ -68,7 +68,7 @@ namespace zeus {
template<class... _ARGS> template<class... _ARGS>
void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface, void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface,
int32_t _paramId, int32_t _paramId,
ememory::SharedPtr<zeus::BufferCall> _obj, ememory::SharedPtr<zeus::message::Call> _obj,
const char* _param, const char* _param,
_ARGS&&... _args) { _ARGS&&... _args) {
createParam(_iface, _paramId, _obj, std::string(_param), std::forward<_ARGS>(_args)...); createParam(_iface, _paramId, _obj, std::string(_param), std::forward<_ARGS>(_args)...);
@ -79,8 +79,8 @@ namespace zeus {
* @return * @return
*/ */
template<class... _ARGS> template<class... _ARGS>
ememory::SharedPtr<zeus::BufferCall> createCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) { ememory::SharedPtr<zeus::message::Call> createCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) {
ememory::SharedPtr<zeus::BufferCall> callElem = createBaseCall(_iface, _transactionId, _source, _destination, _functionName); ememory::SharedPtr<zeus::message::Call> callElem = createBaseCall(_iface, _transactionId, _source, _destination, _functionName);
if (callElem == nullptr) { if (callElem == nullptr) {
return nullptr; return nullptr;
} }
@ -97,7 +97,7 @@ namespace zeus {
private: private:
enet::WebSocket m_connection; enet::WebSocket m_connection;
ethread::Pool m_processingPool; ethread::Pool m_processingPool;
std::vector<ememory::SharedPtr<zeus::Buffer>> m_listPartialBuffer; std::vector<ememory::SharedPtr<zeus::Message>> m_listPartialMessage;
uint16_t m_localAddress; uint16_t m_localAddress;
uint16_t m_licalIdObjectIncrement; //!< attribute a unique ID for an object uint16_t m_licalIdObjectIncrement; //!< attribute a unique ID for an object
public: public:
@ -123,7 +123,7 @@ namespace zeus {
std::mutex m_pendingCallMutex; std::mutex m_pendingCallMutex;
std::vector<std::pair<uint64_t, zeus::FutureBase>> m_pendingCall; std::vector<std::pair<uint64_t, zeus::FutureBase>> m_pendingCall;
public: public:
using Observer = std::function<void(ememory::SharedPtr<zeus::Buffer>)>; //!< Define an Observer: function pointer using Observer = std::function<void(ememory::SharedPtr<zeus::Message>)>; //!< Define an Observer: function pointer
Observer m_observerElement; Observer m_observerElement;
/** /**
* @brief Connect an function member on the signal with the shared_ptr object. * @brief Connect an function member on the signal with the shared_ptr object.
@ -131,8 +131,8 @@ namespace zeus {
* @param[in] _func Function to call. * @param[in] _func Function to call.
*/ */
template<class CLASS_TYPE> template<class CLASS_TYPE>
void connect(CLASS_TYPE* _class, void (CLASS_TYPE::*_func)(ememory::SharedPtr<zeus::Buffer>)) { void connect(CLASS_TYPE* _class, void (CLASS_TYPE::*_func)(ememory::SharedPtr<zeus::Message>)) {
m_observerElement = [=](ememory::SharedPtr<zeus::Buffer> _value){ m_observerElement = [=](ememory::SharedPtr<zeus::Message> _value){
(*_class.*_func)(_value); (*_class.*_func)(_value);
}; };
} }
@ -210,7 +210,7 @@ namespace zeus {
* @param[in] * @param[in]
* @return * @return
*/ */
int32_t writeBinary(ememory::SharedPtr<zeus::Buffer> _data); int32_t writeBinary(ememory::SharedPtr<zeus::Message> _data);
/** /**
* @brief * @brief
* @param[in] * @param[in]
@ -234,7 +234,7 @@ namespace zeus {
* @param[in] * @param[in]
* @return * @return
*/ */
void newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer); void newMessage(ememory::SharedPtr<zeus::Message> _buffer);
public: public:
/** /**
* @brief * @brief
@ -280,7 +280,7 @@ namespace zeus {
* @return * @return
*/ */
zeus::FutureBase callBinary(uint64_t _transactionId, zeus::FutureBase callBinary(uint64_t _transactionId,
ememory::SharedPtr<zeus::Buffer> _obj, ememory::SharedPtr<zeus::Message> _obj,
const uint32_t& _service=0); const uint32_t& _service=0);
public: public:
/** /**
@ -291,7 +291,7 @@ namespace zeus {
template<class... _ARGS> template<class... _ARGS>
zeus::FutureBase call(const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) { zeus::FutureBase call(const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) {
uint16_t id = getId(); uint16_t id = getId();
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCall(sharedFromThis(), id, _source, _destination, _functionName, std::forward<_ARGS>(_args)...); ememory::SharedPtr<zeus::message::Call> callElem = zeus::createCall(sharedFromThis(), id, _source, _destination, _functionName, std::forward<_ARGS>(_args)...);
return callBinary(id, callElem); return callBinary(id, callElem);
} }
public: public:
@ -302,7 +302,7 @@ namespace zeus {
* @return * @return
*/ */
zeus::FutureBase callForward(uint32_t _source, zeus::FutureBase callForward(uint32_t _source,
ememory::SharedPtr<zeus::Buffer> _Buffer, ememory::SharedPtr<zeus::Message> _Message,
uint64_t _singleReferenceId); uint64_t _singleReferenceId);
/** /**
* @brief * @brief
@ -310,7 +310,7 @@ namespace zeus {
* @return * @return
*/ */
void callForwardMultiple(uint32_t _source, void callForwardMultiple(uint32_t _source,
ememory::SharedPtr<zeus::Buffer> _Buffer, ememory::SharedPtr<zeus::Message> _Message,
uint64_t _singleReferenceId); uint64_t _singleReferenceId);
#endif #endif
public: // answers ... public: // answers ...
@ -329,7 +329,7 @@ namespace zeus {
*/ */
template<class ZEUS_ARG> template<class ZEUS_ARG>
void answerValue(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, ZEUS_ARG _value) { void answerValue(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, ZEUS_ARG _value) {
ememory::SharedPtr<zeus::BufferAnswer> answer = zeus::BufferAnswer::create(sharedFromThis()); ememory::SharedPtr<zeus::message::Answer> answer = zeus::message::Answer::create(sharedFromThis());
answer->setTransactionId(_clientTransactionId); answer->setTransactionId(_clientTransactionId);
answer->setSource(_source); answer->setSource(_source);
answer->setDestination(_destination); answer->setDestination(_destination);

View File

@ -11,7 +11,7 @@
#include <zeus/message/Answer.hpp> #include <zeus/message/Answer.hpp>
void zeus::message::Answer::generateDisplay(std::ostream& _os) const { void zeus::message::Answer::generateDisplay(std::ostream& _os) const {
zeus::Buffer::generateDisplay(_os); zeus::Message::generateDisplay(_os);
if (getNumberParameter() != 0) { if (getNumberParameter() != 0) {
_os << " '" + simpleStringParam(0) + "'"; _os << " '" + simpleStringParam(0) + "'";
} }
@ -40,12 +40,12 @@ void zeus::message::Answer::addError(const std::string& _value, const std::strin
} }
bool zeus::message::Answer::writeOn(enet::WebSocket& _interface) { bool zeus::message::Answer::writeOn(enet::WebSocket& _interface) {
zeus::Buffer::writeOn(_interface); zeus::Message::writeOn(_interface);
_interface.writeData((uint8_t*)m_errorType.c_str(), m_errorType.size() + 1); _interface.writeData((uint8_t*)m_errorType.c_str(), m_errorType.size() + 1);
if (m_errorType.size() != 0) { if (m_errorType.size() != 0) {
_interface.writeData((uint8_t*)m_errorHelp.c_str(), m_errorHelp.size() + 1); _interface.writeData((uint8_t*)m_errorHelp.c_str(), m_errorHelp.size() + 1);
} }
return BufferParameter::writeOn(_interface); return message::Parameter::writeOn(_interface);
} }
void zeus::message::Answer::composeWith(const uint8_t* _buffer, uint32_t _lenght) { void zeus::message::Answer::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
@ -69,11 +69,11 @@ void zeus::message::Answer::composeWith(const uint8_t* _buffer, uint32_t _lenght
pos++; pos++;
} }
// parse parameters: // parse parameters:
BufferParameter::composeWith(&_buffer[pos], _lenght-pos); message::Parameter::composeWith(&_buffer[pos], _lenght-pos);
} }
void zeus::message::Answer::appendBufferData(ememory::SharedPtr<zeus::message::Data> _obj) { void zeus::message::Answer::appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) {
parameterAppendBufferData(_obj); parameterAppendMessageData(_obj);
} }
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------

View File

@ -14,28 +14,28 @@ namespace zeus {
namespace message { namespace message {
class Answer : class Answer :
public message::Parameter { public message::Parameter {
friend class zeus::message::Message; friend class zeus::Message;
protected: protected:
std::string m_errorType; std::string m_errorType;
std::string m_errorHelp; std::string m_errorHelp;
protected: protected:
/** /**
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::Answer::create * @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::message::Answer::create
*/ */
Answer(ememory::SharedPtr<zeus::WebServer> _iface): Answer(ememory::SharedPtr<zeus::WebServer> _iface):
zeus::message::Parameter(_iface) { zeus::message::Parameter(_iface) {
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::answer); m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::answer);
}; };
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
void appendBufferData(ememory::SharedPtr<zeus::message::Data> _obj) override; void appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) override;
bool writeOn(enet::WebSocket& _interface) override; bool writeOn(enet::WebSocket& _interface) override;
void generateDisplay(std::ostream& _os) const override; void generateDisplay(std::ostream& _os) const override;
public: public:
/** /**
* @brief Create a shared pointer on the Answer * @brief Create a shared pointer on the Answer
* @return Allocated Buffer. * @return Allocated Message.
*/ */
static ememory::SharedPtr<zeus::Answer> create(ememory::SharedPtr<zeus::WebServer> _iface); static ememory::SharedPtr<zeus::message::Answer> create(ememory::SharedPtr<zeus::WebServer> _iface);
public: public:
enum zeus::message::type getType() const override { enum zeus::message::type getType() const override {
return zeus::message::type::answer; return zeus::message::type::answer;

View File

@ -11,7 +11,7 @@
#include <zeus/message/Call.hpp> #include <zeus/message/Call.hpp>
void zeus::message::Call::generateDisplay(std::ostream& _os) const { void zeus::message::Call::generateDisplay(std::ostream& _os) const {
zeus::Buffer::generateDisplay(_os); zeus::Message::generateDisplay(_os);
_os << " '" + m_callName + "'"; _os << " '" + m_callName + "'";
_os << " nbParam=" + etk::to_string(getNumberParameter()); _os << " nbParam=" + etk::to_string(getNumberParameter());
if (getNumberParameter() != 0) { if (getNumberParameter() != 0) {
@ -35,9 +35,9 @@ void zeus::message::Call::setCall(const std::string& _value) {
} }
bool zeus::message::Call::writeOn(enet::WebSocket& _interface) { bool zeus::message::Call::writeOn(enet::WebSocket& _interface) {
zeus::Buffer::writeOn(_interface); zeus::Message::writeOn(_interface);
_interface.writeData((uint8_t*)m_callName.c_str(), m_callName.size() + 1); _interface.writeData((uint8_t*)m_callName.c_str(), m_callName.size() + 1);
return BufferParameter::writeOn(_interface); return message::Parameter::writeOn(_interface);
} }
void zeus::message::Call::composeWith(const uint8_t* _buffer, uint32_t _lenght) { void zeus::message::Call::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
@ -52,11 +52,11 @@ void zeus::message::Call::composeWith(const uint8_t* _buffer, uint32_t _lenght)
} }
pos++; pos++;
// parse parameters: // parse parameters:
BufferParameter::composeWith(&_buffer[pos], _lenght-pos); message::Parameter::composeWith(&_buffer[pos], _lenght-pos);
} }
void zeus::message::Call::appendBufferData(ememory::SharedPtr<zeus::message::Data> _obj) { void zeus::message::Call::appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) {
parameterAppendBufferData(_obj); parameterAppendMessageData(_obj);
} }
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------

View File

@ -11,29 +11,29 @@
namespace zeus { namespace zeus {
namespace message { namespace message {
class BufferCall : class Call :
public BufferParameter { public message::Parameter {
friend class zeus::Buffer; friend class zeus::Message;
protected: protected:
std::string m_callName; std::string m_callName;
protected: protected:
/** /**
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferCall::create * @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::message::Call::create
*/ */
BufferCall(ememory::SharedPtr<zeus::WebServer> _iface): Call(ememory::SharedPtr<zeus::WebServer> _iface):
zeus::BufferParameter(_iface) { zeus::message::Parameter(_iface) {
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::call); m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::call);
}; };
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
void appendBufferData(ememory::SharedPtr<zeus::message::Data> _obj) override; void appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) override;
bool writeOn(enet::WebSocket& _interface) override; bool writeOn(enet::WebSocket& _interface) override;
void generateDisplay(std::ostream& _os) const override; void generateDisplay(std::ostream& _os) const override;
public: public:
/** /**
* @brief Create a shared pointer on the BufferCall * @brief Create a shared pointer on the MessageCall
* @return Allocated Buffer. * @return Allocated Message.
*/ */
static ememory::SharedPtr<zeus::BufferCall> create(ememory::SharedPtr<zeus::WebServer> _iface); static ememory::SharedPtr<zeus::message::Call> create(ememory::SharedPtr<zeus::WebServer> _iface);
public: public:
enum zeus::message::type getType() const override { enum zeus::message::type getType() const override {
return zeus::message::type::call; return zeus::message::type::call;

View File

@ -11,7 +11,7 @@
#include <zeus/message/Data.hpp> #include <zeus/message/Data.hpp>
void zeus::message::Data::generateDisplay(std::ostream& _os) const { void zeus::message::Data::generateDisplay(std::ostream& _os) const {
zeus::Buffer::generateDisplay(_os); zeus::Message::generateDisplay(_os);
_os << " paramId=" << etk::to_string(m_parameterId); _os << " paramId=" << etk::to_string(m_parameterId);
_os << " part=" << etk::to_string(m_partId); _os << " part=" << etk::to_string(m_partId);
_os << " nbData=" << etk::to_string(m_data.size()); _os << " nbData=" << etk::to_string(m_data.size());
@ -37,7 +37,7 @@ void zeus::message::Data::setPartId(uint32_t _value) {
} }
bool zeus::message::Data::writeOn(enet::WebSocket& _interface) { bool zeus::message::Data::writeOn(enet::WebSocket& _interface) {
zeus::Buffer::writeOn(_interface); zeus::Message::writeOn(_interface);
_interface.writeData((uint8_t*)&m_partId, sizeof(uint32_t)); _interface.writeData((uint8_t*)&m_partId, sizeof(uint32_t));
_interface.writeData((uint8_t*)&m_parameterId, sizeof(uint16_t)); _interface.writeData((uint8_t*)&m_parameterId, sizeof(uint16_t));
_interface.writeData((uint8_t*)&m_data[0], m_data.size()); _interface.writeData((uint8_t*)&m_data[0], m_data.size());

View File

@ -5,22 +5,22 @@
*/ */
#pragma once #pragma once
#include <etk/types.hpp> #include <etk/types.hpp>
#include <enet/WebSocket.hpp> #include <zeus/WebServer.hpp>
#include <zeus/message/ParamType.hpp> #include <zeus/message/ParamType.hpp>
#include <zeus/message/Message.hpp> #include <zeus/message/Message.hpp>
namespace zeus { namespace zeus {
class WebServer;
namespace message { namespace message {
class BufferData: class Data: public zeus::Message {
public Buffer { friend class zeus::Message;
friend class zeus::Buffer;
protected: protected:
uint32_t m_partId; uint32_t m_partId;
uint16_t m_parameterId; uint16_t m_parameterId;
std::vector<uint8_t> m_data; std::vector<uint8_t> m_data;
protected: protected:
/** /**
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferData::create * @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::message::Data::create
*/ */
Data(ememory::SharedPtr<zeus::WebServer> _iface): Data(ememory::SharedPtr<zeus::WebServer> _iface):
zeus::Message(_iface), zeus::Message(_iface),
@ -28,13 +28,13 @@ namespace zeus {
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::data); m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::data);
}; };
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
// TODO :... void appendBufferData(ememory::SharedPtr<zeus::BufferData> _obj) override; // TODO :... void appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) override;
bool writeOn(enet::WebSocket& _interface) override; bool writeOn(enet::WebSocket& _interface) override;
void generateDisplay(std::ostream& _os) const override; void generateDisplay(std::ostream& _os) const override;
public: public:
/** /**
* @brief Create a shared pointer on the BufferData * @brief Create a shared pointer on the MessageData
* @return Allocated Buffer. * @return Allocated Message.
*/ */
static ememory::SharedPtr<zeus::message::Data> create(ememory::SharedPtr<zeus::WebServer> _iface); static ememory::SharedPtr<zeus::message::Data> create(ememory::SharedPtr<zeus::WebServer> _iface);
public: public:

View File

@ -4,7 +4,7 @@
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#include <etk/types.hpp> #include <etk/types.hpp>
#include <zeus/message/Buffer.hpp> #include <zeus/message/Message.hpp>
#include <zeus/debug.hpp> #include <zeus/debug.hpp>
#include <zeus/message/ParamType.hpp> #include <zeus/message/ParamType.hpp>
#include <etk/stdTools.hpp> #include <etk/stdTools.hpp>
@ -15,8 +15,8 @@
// -- Factory // -- Factory
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
ememory::SharedPtr<zeus::BufferEvent> zeus::BufferEvent::create() { ememory::SharedPtr<zeus::MessageEvent> zeus::MessageEvent::create() {
return ememory::SharedPtr<zeus::BufferEvent>(new zeus::BufferEvent); return ememory::SharedPtr<zeus::MessageEvent>(new zeus::MessageEvent);
} }
*/ */

View File

@ -11,24 +11,24 @@
namespace zeus { namespace zeus {
namespace message { namespace message {
/* /*
class BufferEvent : class MessageEvent :
public BufferParameter { public message::Parameter {
friend class zeus::Buffer; friend class zeus::Message;
protected: protected:
/ ** / **
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferEvent::create * @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::MessageEvent::create
* / * /
BufferEvent() { MessageEvent() {
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::event); m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::event);
}; };
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
void appendBufferData(ememory::SharedPtr<zeus::BufferData> _obj) override; void appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) override;
public: public:
/ ** / **
* @brief Create a shared pointer on the BufferEvent * @brief Create a shared pointer on the MessageEvent
* @return Allocated Buffer. * @return Allocated Message.
* / * /
static ememory::SharedPtr<zeus::BufferEvent> create(); static ememory::SharedPtr<zeus::MessageEvent> create();
public: public:
enum zeus::message::type getType() const override { enum zeus::message::type getType() const override {
return zeus::message::type::event; return zeus::message::type::event;

View File

@ -15,8 +15,8 @@
// -- Factory // -- Factory
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
ememory::SharedPtr<zeus::BufferFlow> zeus::BufferFlow::create() { ememory::SharedPtr<zeus::MessageFlow> zeus::MessageFlow::create() {
return ememory::SharedPtr<zeus::BufferFlow>(new zeus::BufferFlow); return ememory::SharedPtr<zeus::MessageFlow>(new zeus::MessageFlow);
} }
*/ */

View File

@ -11,23 +11,23 @@
namespace zeus { namespace zeus {
namespace message { namespace message {
/* /*
class BufferFlow: class MessageFlow:
public Buffer { public Message {
friend class zeus::Buffer; friend class zeus::Message;
protected: protected:
/ ** / **
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferFlow::create * @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::MessageFlow::create
* / * /
BufferFlow() { MessageFlow() {
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::flow); m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::flow);
}; };
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
public: public:
/ ** / **
* @brief Create a shared pointer on the BufferFlow * @brief Create a shared pointer on the MessageFlow
* @return Allocated Buffer. * @return Allocated Message.
* / * /
static ememory::SharedPtr<zeus::BufferFlow> create(); static ememory::SharedPtr<zeus::MessageFlow> create();
public: public:
enum zeus::message::type getType() const override { enum zeus::message::type getType() const override {
return zeus::message::type::flow; return zeus::message::type::flow;

View File

@ -18,16 +18,16 @@
#include <zeus/WebServer.hpp> #include <zeus/WebServer.hpp>
zeus::message::Message(ememory::SharedPtr<zeus::WebServer> _iface): zeus::Message::Message(ememory::SharedPtr<zeus::WebServer> _iface):
m_iface(_iface) { m_iface(_iface) {
clear(); clear();
} }
void zeus::message::appendBufferData(ememory::SharedPtr<zeus::MessageData> _obj) { void zeus::Message::appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) {
ZEUS_ERROR("Can not append datas ... Not managed"); ZEUS_ERROR("Can not append datas ... Not managed");
} }
void zeus::message::appendBuffer(ememory::SharedPtr<zeus::Message> _obj) { void zeus::Message::appendMessage(ememory::SharedPtr<zeus::Message> _obj) {
if (_obj == nullptr) { if (_obj == nullptr) {
return; return;
} }
@ -39,23 +39,23 @@ void zeus::message::appendBuffer(ememory::SharedPtr<zeus::Message> _obj) {
return; return;
} }
setPartFinish(_obj->getPartFinish()); setPartFinish(_obj->getPartFinish());
appendBufferData(ememory::staticPointerCast<zeus::MessageData>(_obj)); appendMessageData(ememory::staticPointerCast<zeus::message::Data>(_obj));
} }
bool zeus::message::writeOn(enet::WebSocket& _interface) { bool zeus::Message::writeOn(enet::WebSocket& _interface) {
if (_interface.configHeader(false) == false) { if (_interface.configHeader(false) == false) {
return false; return false;
} }
_interface.writeData((uint8_t*)&m_header, sizeof(headerBin)); _interface.writeData((uint8_t*)&m_header, sizeof(zeus::message::headerBin));
return true; return true;
} }
void zeus::message::composeWith(const uint8_t* _buffer, uint32_t _lenght) { void zeus::Message::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
// impossible case // impossible case
} }
void zeus::message::clear() { void zeus::Message::clear() {
m_header.transactionId = 1; m_header.transactionId = 1;
m_header.sourceId = 0; m_header.sourceId = 0;
m_header.sourceObjectId = 0; m_header.sourceObjectId = 0;
@ -73,7 +73,7 @@ std::ostream& zeus::operator <<(std::ostream& _os, ememory::SharedPtr<zeus::Mess
} }
return _os; return _os;
} }
void zeus::message::generateDisplay(std::ostream& _os) const { void zeus::Message::generateDisplay(std::ostream& _os) const {
//out += " v=" + etk::to_string(m_header.versionProtocol); // set it in the websocket //out += " v=" + etk::to_string(m_header.versionProtocol); // set it in the websocket
_os << " if=" << etk::to_string(getInterfaceId()); _os << " if=" << etk::to_string(getInterfaceId());
_os << " tr-id=" << etk::to_string(getTransactionId()); _os << " tr-id=" << etk::to_string(getTransactionId());
@ -87,9 +87,6 @@ void zeus::message::generateDisplay(std::ostream& _os) const {
case zeus::message::type::unknow: case zeus::message::type::unknow:
_os << " -UNKNOW-"; _os << " -UNKNOW-";
break; break;
case zeus::message::type::ctrl:
_os << " -CTRL-";
break;
case zeus::message::type::call: case zeus::message::type::call:
_os << " -CALL-"; _os << " -CALL-";
break; break;
@ -105,77 +102,77 @@ void zeus::message::generateDisplay(std::ostream& _os) const {
} }
} }
uint32_t zeus::message::getInterfaceId() const { uint32_t zeus::Message::getInterfaceId() const {
return m_interfaceID; return m_interfaceID;
} }
void zeus::message::setInterfaceId(uint32_t _value) { void zeus::Message::setInterfaceId(uint32_t _value) {
m_interfaceID = _value; m_interfaceID = _value;
} }
uint32_t zeus::message::getTransactionId() const { uint32_t zeus::Message::getTransactionId() const {
return m_header.transactionId; return m_header.transactionId;
} }
void zeus::message::setTransactionId(uint32_t _value) { void zeus::Message::setTransactionId(uint32_t _value) {
m_header.transactionId = _value; m_header.transactionId = _value;
} }
uint32_t zeus::message::getSource() const { uint32_t zeus::Message::getSource() const {
return (uint32_t(m_header.sourceId) << 16) + m_header.sourceObjectId; return (uint32_t(m_header.sourceId) << 16) + m_header.sourceObjectId;
} }
void zeus::message::setSource(uint32_t _value) { void zeus::Message::setSource(uint32_t _value) {
m_header.sourceId = _value >> 16; m_header.sourceId = _value >> 16;
m_header.sourceObjectId = _value & 0xFFFF; m_header.sourceObjectId = _value & 0xFFFF;
} }
uint16_t zeus::message::getSourceId() const { uint16_t zeus::Message::getSourceId() const {
return m_header.sourceId; return m_header.sourceId;
} }
void zeus::message::setSourceId(uint16_t _value) { void zeus::Message::setSourceId(uint16_t _value) {
m_header.sourceId = _value; m_header.sourceId = _value;
} }
uint16_t zeus::message::getSourceObjectId() const { uint16_t zeus::Message::getSourceObjectId() const {
return m_header.sourceObjectId; return m_header.sourceObjectId;
} }
void zeus::message::setSourceObjectId(uint16_t _value) { void zeus::Message::setSourceObjectId(uint16_t _value) {
m_header.sourceObjectId = _value; m_header.sourceObjectId = _value;
} }
uint32_t zeus::message::getDestination() const { uint32_t zeus::Message::getDestination() const {
return (uint32_t(m_header.destinationId) << 16) + m_header.destinationObjectId; return (uint32_t(m_header.destinationId) << 16) + m_header.destinationObjectId;
} }
void zeus::message::setDestination(uint32_t _value) { void zeus::Message::setDestination(uint32_t _value) {
m_header.destinationId = _value >> 16; m_header.destinationId = _value >> 16;
m_header.destinationObjectId = _value & 0xFFFF; m_header.destinationObjectId = _value & 0xFFFF;
} }
uint16_t zeus::message::getDestinationId() const { uint16_t zeus::Message::getDestinationId() const {
return m_header.destinationId; return m_header.destinationId;
} }
void zeus::message::setDestinationId(uint16_t _value) { void zeus::Message::setDestinationId(uint16_t _value) {
m_header.destinationId = _value; m_header.destinationId = _value;
} }
uint16_t zeus::message::getDestinationObjectId() const { uint16_t zeus::Message::getDestinationObjectId() const {
return m_header.destinationObjectId; return m_header.destinationObjectId;
} }
void zeus::message::setDestinationObjectId(uint16_t _value) { void zeus::Message::setDestinationObjectId(uint16_t _value) {
m_header.destinationObjectId = _value; m_header.destinationObjectId = _value;
} }
bool zeus::message::getPartFinish() const { bool zeus::Message::getPartFinish() const {
return (m_header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0; return (m_header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0;
} }
void zeus::message::setPartFinish(bool _value) { void zeus::Message::setPartFinish(bool _value) {
if (_value == true) { if (_value == true) {
m_header.flags = (m_header.flags & 0x7F) | ZEUS_BUFFER_FLAG_FINISH; m_header.flags = (m_header.flags & 0x7F) | ZEUS_BUFFER_FLAG_FINISH;
} else { } else {
@ -183,46 +180,30 @@ void zeus::message::setPartFinish(bool _value) {
} }
} }
enum zeus::message::type zeus::message::getType() const { enum zeus::message::type zeus::Message::getType() const {
return zeus::message::type::unknow; return zeus::message::type::unknow;
} }
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// -- Factory // -- Factory
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus::WebServer> _iface) { ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface) {
return ememory::SharedPtr<zeus::Message>(new zeus::Message(_iface)); return ememory::SharedPtr<zeus::Message>(new zeus::Message(_iface));
} }
ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer) { ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer) {
headerBin header; zeus::message::headerBin header;
if (_buffer.size() < sizeof(headerBin)) { if (_buffer.size() < sizeof(zeus::message::headerBin)) {
ZEUS_ERROR("wrong size of the buffer"); ZEUS_ERROR("wrong size of the buffer");
return nullptr; return nullptr;
} }
memcpy(reinterpret_cast<char*>(&header), &_buffer[0], sizeof(headerBin)); memcpy(reinterpret_cast<char*>(&header), &_buffer[0], sizeof(zeus::message::headerBin));
enum zeus::message::type type = getTypeType(uint16_t(header.flags & 0x07)); enum zeus::message::type type = zeus::message::getTypeFromInt(uint16_t(header.flags & 0x07));
switch (type) { switch (type) {
case zeus::message::type::unknow: case zeus::message::type::unknow:
return nullptr; return nullptr;
case zeus::message::type::ctrl: {
ememory::SharedPtr<zeus::MessageCtrl> value = zeus::MessageCtrl::create(_iface);
if (value == nullptr) {
return nullptr;
}
value->setTransactionId(header.transactionId);
value->setSourceId(header.sourceId);
value->setSourceObjectId(header.sourceObjectId);
value->setDestinationId(header.destinationId);
value->setDestinationObjectId(header.destinationObjectId);
value->setPartFinish((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0);
value->composeWith(&_buffer[sizeof(headerBin)],
_buffer.size() - sizeof(headerBin));
return value;
}
break;
case zeus::message::type::call: { case zeus::message::type::call: {
ememory::SharedPtr<zeus::MessageCall> value = zeus::MessageCall::create(_iface); ememory::SharedPtr<zeus::message::Call> value = zeus::message::Call::create(_iface);
if (value == nullptr) { if (value == nullptr) {
return nullptr; return nullptr;
} }
@ -232,13 +213,13 @@ ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus:
value->setDestinationId(header.destinationId); value->setDestinationId(header.destinationId);
value->setDestinationObjectId(header.destinationObjectId); value->setDestinationObjectId(header.destinationObjectId);
value->setPartFinish((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0); value->setPartFinish((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0);
value->composeWith(&_buffer[sizeof(headerBin)], value->composeWith(&_buffer[sizeof(zeus::message::headerBin)],
_buffer.size() - sizeof(headerBin)); _buffer.size() - sizeof(zeus::message::headerBin));
return value; return value;
} }
break; break;
case zeus::message::type::answer: { case zeus::message::type::answer: {
ememory::SharedPtr<zeus::MessageAnswer> value = zeus::MessageAnswer::create(_iface); ememory::SharedPtr<zeus::message::Answer> value = zeus::message::Answer::create(_iface);
if (value == nullptr) { if (value == nullptr) {
return nullptr; return nullptr;
} }
@ -248,13 +229,13 @@ ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus:
value->setDestinationId(header.destinationId); value->setDestinationId(header.destinationId);
value->setDestinationObjectId(header.destinationObjectId); value->setDestinationObjectId(header.destinationObjectId);
value->setPartFinish((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0); value->setPartFinish((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0);
value->composeWith(&_buffer[sizeof(headerBin)], value->composeWith(&_buffer[sizeof(zeus::message::headerBin)],
_buffer.size() - sizeof(headerBin)); _buffer.size() - sizeof(zeus::message::headerBin));
return value; return value;
} }
break; break;
case zeus::message::type::data: { case zeus::message::type::data: {
ememory::SharedPtr<zeus::MessageData> value = zeus::MessageData::create(_iface); ememory::SharedPtr<zeus::message::Data> value = zeus::message::Data::create(_iface);
if (value == nullptr) { if (value == nullptr) {
return nullptr; return nullptr;
} }
@ -264,8 +245,8 @@ ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus:
value->setDestinationId(header.destinationId); value->setDestinationId(header.destinationId);
value->setDestinationObjectId(header.destinationObjectId); value->setDestinationObjectId(header.destinationObjectId);
value->setPartFinish((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0); value->setPartFinish((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0);
value->composeWith(&_buffer[sizeof(headerBin)], value->composeWith(&_buffer[sizeof(zeus::message::headerBin)],
_buffer.size() - sizeof(headerBin)); _buffer.size() - sizeof(zeus::message::headerBin));
return value; return value;
} }
break; break;

View File

@ -121,13 +121,13 @@ namespace zeus {
virtual ~Message() = default; virtual ~Message() = default;
/** /**
* @brief Create a shared pointer on the buffer * @brief Create a shared pointer on the buffer
* @return Allocated Buffer. * @return Allocated Message.
*/ */
static ememory::SharedPtr<zeus::Message> create(ememory::SharedPtr<zeus::WebServer> _iface); static ememory::SharedPtr<zeus::Message> create(ememory::SharedPtr<zeus::WebServer> _iface);
/** /**
* @brief Create a shared pointer on the buffer * @brief Create a shared pointer on the buffer
* @param[in] _buffer Buffer on the data * @param[in] _buffer Message on the data
* @return Allocated Buffer. * @return Allocated Message.
*/ */
static ememory::SharedPtr<zeus::Message> create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer); static ememory::SharedPtr<zeus::Message> create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer);
protected: protected:
@ -151,10 +151,10 @@ namespace zeus {
} }
/** /**
* @brief When multiple frame buffer, they need to concatenate the data... call this function with the new data to append it ... * @brief When multiple frame buffer, they need to concatenate the data... call this function with the new data to append it ...
* @param[in] _obj Buffer to add * @param[in] _obj Message to add
*/ */
void appendBuffer(ememory::SharedPtr<zeus::Message> _obj); void appendMessage(ememory::SharedPtr<zeus::Message> _obj);
virtual void appendBufferData(ememory::SharedPtr<zeus::MessageData> _obj); virtual void appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj);
protected: protected:
/** /**
* @brief When receive new data form websocket, it might be added by this input (set all the frame ...) * @brief When receive new data form websocket, it might be added by this input (set all the frame ...)
@ -249,7 +249,7 @@ namespace zeus {
void setDestinationObjectId(uint16_t _value); void setDestinationObjectId(uint16_t _value);
/** /**
* @brief Check if it is the last packet of the buffer * @brief Check if it is the last packet of the buffer
* @return If "true" The Buffer wait no more datas * @return If "true" The Message wait no more datas
*/ */
bool getPartFinish() const; bool getPartFinish() const;
/** /**
@ -274,7 +274,7 @@ namespace zeus {
/** /**
* @brief generate a display of the typemessage * @brief generate a display of the typemessage
* @param[in] _os stream to add data * @param[in] _os stream to add data
* @value[in] _obj Buffer to display * @value[in] _obj Message to display
* @return a reference of the stream * @return a reference of the stream
*/ */
std::ostream& operator <<(std::ostream& _os, ememory::SharedPtr<zeus::Message> _obj); std::ostream& operator <<(std::ostream& _os, ememory::SharedPtr<zeus::Message> _obj);
@ -283,13 +283,13 @@ namespace zeus {
// internal: // internal:
/** /**
* @brief Add a parameter generic type in the buffer * @brief Add a parameter generic type in the buffer
* @param[in] _data Buffer to add type * @param[in] _data Message to add type
* @param[in] _type generic type to add * @param[in] _type generic type to add
*/ */
void addType(std::vector<uint8_t>& _data, zeus::ParamType _type); void addType(std::vector<uint8_t>& _data, zeus::message::ParamType _type);
/** /**
* @brief Add a parameter object type in the buffer * @brief Add a parameter object type in the buffer
* @param[in] _data Buffer to add type * @param[in] _data Message to add type
* @param[in] _type string of the type to add * @param[in] _type string of the type to add
*/ */
void addTypeObject(std::vector<uint8_t>& _data, const std::string _type); void addTypeObject(std::vector<uint8_t>& _data, const std::string _type);

View File

@ -93,10 +93,12 @@ bool zeus::message::ParamType::operator != (const uint16_t& _value) const {
#define generate_basic_type(_type, _name, _id, _num, _vect) \ #define generate_basic_type(_type, _name, _id, _num, _vect) \
namespace zeus { \ namespace zeus { \
namespace message { \
template<> const zeus::message::ParamType& createType<_type>() {\ template<> const zeus::message::ParamType& createType<_type>() {\
static zeus::message::ParamType type(_name, _id, _num, _vect); \ static zeus::message::ParamType type(_name, _id, _num, _vect); \
return type; \ return type; \
} \ } \
} \
} }
generate_basic_type(void, "void", 0x0001, false, false); generate_basic_type(void, "void", 0x0001, false, false);
@ -134,5 +136,5 @@ generate_basic_type(zeus::File, "file", 0x000E, false, false);
generate_basic_type(zeus::FileServer, "file", 0x000E, false, false); generate_basic_type(zeus::FileServer, "file", 0x000E, false, false);
#endif #endif
const uint16_t zeus::message::ParamTypeObject = 0xFFFF; const uint16_t zeus::message::paramTypeObject = 0xFFFF;

View File

@ -29,7 +29,7 @@ namespace zeus {
*/ */
ParamType(const char* _name = "", uint16_t _id=0, bool _isNumber=false, bool _isVector=false); ParamType(const char* _name = "", uint16_t _id=0, bool _isNumber=false, bool _isVector=false);
/** /**
* @copydoc zeus::ParamType::ParamType * @copydoc zeus::message::ParamType::ParamType
*/ */
ParamType(const std::string& _name, uint16_t _id, bool _isNumber=false, bool _isVector=false); ParamType(const std::string& _name, uint16_t _id, bool _isNumber=false, bool _isVector=false);
/** /**

View File

@ -13,7 +13,7 @@
#include <zeus/File.hpp> #include <zeus/File.hpp>
zeus::message::Parameter::Parameter(ememory::SharedPtr<zeus::WebServer> _iface): zeus::message::Parameter::Parameter(ememory::SharedPtr<zeus::WebServer> _iface):
Buffer(_iface) { Message(_iface) {
} }
@ -62,7 +62,7 @@ void zeus::message::Parameter::composeWith(const uint8_t* _buffer, uint32_t _len
} }
} }
zeus::ParamType zeus::message::Parameter::getParameterType(int32_t _id) const { zeus::message::ParamType zeus::message::Parameter::getParameterType(int32_t _id) const {
if (m_parameter.size() <= _id) { if (m_parameter.size() <= _id) {
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size()); ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size());
return createType<void>(); return createType<void>();
@ -111,11 +111,11 @@ zeus::ParamType zeus::message::Parameter::getParameterType(int32_t _id) const {
if (find == false) { if (find == false) {
ZEUS_ERROR("Request object with a name too big ==> error ..."); ZEUS_ERROR("Request object with a name too big ==> error ...");
m_parameter[_id].first = 0; m_parameter[_id].first = 0;
return zeus::ParamType("no-name", typeId); return zeus::message::ParamType("no-name", typeId);
} }
std::string type(tmp); std::string type(tmp);
m_parameter[_id].first = type.size() + sizeof(uint16_t) + 1; // add \0 m_parameter[_id].first = type.size() + sizeof(uint16_t) + 1; // add \0
return zeus::ParamType(type, typeId); return zeus::message::ParamType(type, typeId);
} }
ZEUS_ERROR("Can not get type of parameter ... "); ZEUS_ERROR("Can not get type of parameter ... ");
return createType<void>(); return createType<void>();
@ -151,7 +151,7 @@ uint16_t zeus::message::Parameter::getNumberParameter() const {
} }
std::string zeus::message::Parameter::simpleStringParam(uint32_t _id) const { std::string zeus::message::Parameter::simpleStringParam(uint32_t _id) const {
zeus::ParamType paramType = getParameterType(_id); zeus::message::ParamType paramType = getParameterType(_id);
if (paramType.isVector() == false) { if (paramType.isVector() == false) {
if (paramType.isNumber() == true) { if (paramType.isNumber() == true) {
return etk::to_string(getParameter<int64_t>(_id)); return etk::to_string(getParameter<int64_t>(_id));
@ -169,7 +169,7 @@ std::string zeus::message::Parameter::simpleStringParam(uint32_t _id) const {
return paramType.getName(); return paramType.getName();
} }
void zeus::message::Parameter::parameterAppendBufferData(ememory::SharedPtr<zeus::BufferData> _obj) { void zeus::message::Parameter::parameterAppendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) {
// At this point we just add data at the parameter value: // At this point we just add data at the parameter value:
uint16_t parameterID = _obj->getParameterId(); uint16_t parameterID = _obj->getParameterId();

View File

@ -13,7 +13,7 @@ namespace zeus {
class WebServer; class WebServer;
namespace message { namespace message {
class Parameter: class Parameter:
public Buffer { public Message {
protected: protected:
mutable std::vector<std::pair<int32_t,std::vector<uint8_t>>> m_parameter; //!< list of the parameter (offset of start data and buffer of data (subprotocol...) mutable std::vector<std::pair<int32_t,std::vector<uint8_t>>> m_parameter; //!< list of the parameter (offset of start data and buffer of data (subprotocol...)
public: public:
@ -40,7 +40,7 @@ namespace zeus {
* @param[in] _id Number of the parameter * @param[in] _id Number of the parameter
* @return type of the parameter * @return type of the parameter
*/ */
zeus::ParamType getParameterType(int32_t _id) const; zeus::message::ParamType getParameterType(int32_t _id) const;
/** /**
* @brief Get the start pointer of the parameter * @brief Get the start pointer of the parameter
* @param[in] _id Number of the parameter * @param[in] _id Number of the parameter
@ -87,7 +87,7 @@ namespace zeus {
void addParameter(const ememory::SharedPtr<zeus::WebServer>& _iface, const ZEUS_TYPE_DATA& _value) { void addParameter(const ememory::SharedPtr<zeus::WebServer>& _iface, const ZEUS_TYPE_DATA& _value) {
addParameter(_iface, m_parameter.size(), _value); addParameter(_iface, m_parameter.size(), _value);
} }
void parameterAppendBufferData(ememory::SharedPtr<zeus::BufferData> _obj); void parameterAppendMessageData(ememory::SharedPtr<zeus::message::Data> _obj);
}; };
} }
} }

View File

@ -16,12 +16,12 @@
#include <zeus/WebServer.hpp> #include <zeus/WebServer.hpp>
void zeus::addType(std::vector<uint8_t>& _data, zeus::message::ParamType _type) { void zeus::message::addType(std::vector<uint8_t>& _data, zeus::message::ParamType _type) {
_data.push_back(uint8_t(_type.getId()>>8)); _data.push_back(uint8_t(_type.getId()>>8));
_data.push_back(uint8_t(_type.getId())); _data.push_back(uint8_t(_type.getId()));
} }
void zeus::addTypeObject(std::vector<uint8_t>& _data, const std::string _type) { void zeus::message::addTypeObject(std::vector<uint8_t>& _data, const std::string _type) {
_data.push_back(uint8_t(zeus::message::paramTypeObject>>8)); _data.push_back(uint8_t(zeus::message::paramTypeObject>>8));
_data.push_back(uint8_t(zeus::message::paramTypeObject)); _data.push_back(uint8_t(zeus::message::paramTypeObject));
for (auto &it : _type) { for (auto &it : _type) {
@ -31,12 +31,12 @@ void zeus::addTypeObject(std::vector<uint8_t>& _data, const std::string _type) {
} }
void zeus::Parameter::addParameter() { void zeus::message::Parameter::addParameter() {
std::vector<uint8_t> data; std::vector<uint8_t> data;
addType(data, createType<void>()); addType(data, createType<void>());
m_parameter.push_back(std::make_pair(2,data)); m_parameter.push_back(std::make_pair(2,data));
} }
void zeus::Parameter::addParameterEmptyVector() { void zeus::message::Parameter::addParameterEmptyVector() {
// special case of json change mode // special case of json change mode
std::vector<uint8_t> data; std::vector<uint8_t> data;
addType(data, createType<std::vector<void>>()); addType(data, createType<std::vector<void>>());
@ -326,7 +326,7 @@ namespace zeus {
uint32_t _destination, uint32_t _destination,
uint32_t _transactionId, uint32_t _transactionId,
uint32_t _partId) { uint32_t _partId) {
ememory::SharedPtr<zeus::BufferData> answer = zeus::BufferData::create(_interface->sharedFromThis()); ememory::SharedPtr<zeus::message::Data> answer = zeus::message::Data::create(_interface->sharedFromThis());
answer->setTransactionId(_transactionId); answer->setTransactionId(_transactionId);
answer->setSource(_source); answer->setSource(_source);
answer->setDestination(_destination); answer->setDestination(_destination);
@ -357,7 +357,7 @@ namespace zeus {
data.resize(data.size()+_value.size()); data.resize(data.size()+_value.size());
memcpy(&data[currentOffset], _value.data(), _value.size()); memcpy(&data[currentOffset], _value.data(), _value.size());
} else { } else {
m_multipleSend.push_back(zeus::SendData(_value, _paramId)); m_multipleSend.push_back(zeus::message::SendData(_value, _paramId));
} }
} }
m_parameter.push_back(std::make_pair(2,data)); m_parameter.push_back(std::make_pair(2,data));

View File

@ -16,7 +16,7 @@ namespace zeus {
namespace message { namespace message {
template<> template<>
bool Parameter::getParameter<bool>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { bool Parameter::getParameter<bool>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
if (createType<bool>() != type) { if (createType<bool>() != type) {
@ -34,7 +34,7 @@ namespace zeus {
template<> template<>
std::string Parameter::getParameter<std::string>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::string Parameter::getParameter<std::string>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::string out; std::string out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
out.resize(dataSize, 0); out.resize(dataSize, 0);
@ -45,7 +45,7 @@ namespace zeus {
template<> template<>
uint8_t Parameter::getParameter<uint8_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { uint8_t Parameter::getParameter<uint8_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -85,7 +85,7 @@ namespace zeus {
} }
template<> template<>
uint16_t Parameter::getParameter<uint16_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { uint16_t Parameter::getParameter<uint16_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -126,7 +126,7 @@ namespace zeus {
template<> template<>
uint32_t Parameter::getParameter<uint32_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { uint32_t Parameter::getParameter<uint32_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -167,7 +167,7 @@ namespace zeus {
template<> template<>
uint64_t Parameter::getParameter<uint64_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { uint64_t Parameter::getParameter<uint64_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -215,7 +215,7 @@ namespace zeus {
#endif #endif
template<> template<>
int8_t Parameter::getParameter<int8_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { int8_t Parameter::getParameter<int8_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -256,7 +256,7 @@ namespace zeus {
template<> template<>
int16_t Parameter::getParameter<int16_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { int16_t Parameter::getParameter<int16_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -297,7 +297,7 @@ namespace zeus {
template<> template<>
int32_t Parameter::getParameter<int32_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { int32_t Parameter::getParameter<int32_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -338,7 +338,7 @@ namespace zeus {
template<> template<>
int64_t Parameter::getParameter<int64_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { int64_t Parameter::getParameter<int64_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -379,7 +379,7 @@ namespace zeus {
template<> template<>
float Parameter::getParameter<float>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { float Parameter::getParameter<float>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -419,7 +419,7 @@ namespace zeus {
} }
template<> template<>
double Parameter::getParameter<double>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { double Parameter::getParameter<double>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -484,7 +484,7 @@ namespace zeus {
template<> template<>
std::vector<uint8_t> Parameter::getParameter<std::vector<uint8_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<uint8_t> Parameter::getParameter<std::vector<uint8_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<uint8_t> out; std::vector<uint8_t> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -574,7 +574,7 @@ namespace zeus {
template<> template<>
std::vector<uint16_t> Parameter::getParameter<std::vector<uint16_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<uint16_t> Parameter::getParameter<std::vector<uint16_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<uint16_t> out; std::vector<uint16_t> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -665,7 +665,7 @@ namespace zeus {
template<> template<>
std::vector<uint32_t> Parameter::getParameter<std::vector<uint32_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<uint32_t> Parameter::getParameter<std::vector<uint32_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<uint32_t> out; std::vector<uint32_t> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -756,7 +756,7 @@ namespace zeus {
template<> template<>
std::vector<uint64_t> Parameter::getParameter<std::vector<uint64_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<uint64_t> Parameter::getParameter<std::vector<uint64_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<uint64_t> out; std::vector<uint64_t> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -847,7 +847,7 @@ namespace zeus {
template<> template<>
std::vector<int8_t> Parameter::getParameter<std::vector<int8_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<int8_t> Parameter::getParameter<std::vector<int8_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<int8_t> out; std::vector<int8_t> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -938,7 +938,7 @@ namespace zeus {
template<> template<>
std::vector<int16_t> Parameter::getParameter<std::vector<int16_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<int16_t> Parameter::getParameter<std::vector<int16_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<int16_t> out; std::vector<int16_t> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -1029,7 +1029,7 @@ namespace zeus {
template<> template<>
std::vector<int32_t> Parameter::getParameter<std::vector<int32_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<int32_t> Parameter::getParameter<std::vector<int32_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<int32_t> out; std::vector<int32_t> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -1120,7 +1120,7 @@ namespace zeus {
template<> template<>
std::vector<int64_t> Parameter::getParameter<std::vector<int64_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<int64_t> Parameter::getParameter<std::vector<int64_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<int64_t> out; std::vector<int64_t> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -1211,7 +1211,7 @@ namespace zeus {
template<> template<>
std::vector<float> Parameter::getParameter<std::vector<float>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<float> Parameter::getParameter<std::vector<float>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<float> out; std::vector<float> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -1302,7 +1302,7 @@ namespace zeus {
template<> template<>
std::vector<double> Parameter::getParameter<std::vector<double>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<double> Parameter::getParameter<std::vector<double>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<double> out; std::vector<double> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -1393,7 +1393,7 @@ namespace zeus {
template<> template<>
std::vector<bool> Parameter::getParameter<std::vector<bool>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<bool> Parameter::getParameter<std::vector<bool>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<bool> out; std::vector<bool> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -1415,7 +1415,7 @@ namespace zeus {
template<> template<>
std::vector<std::string> Parameter::getParameter<std::vector<std::string>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { std::vector<std::string> Parameter::getParameter<std::vector<std::string>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
std::vector<std::string> out; std::vector<std::string> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
if (type == createType<std::vector<void>>()) { if (type == createType<std::vector<void>>()) {
@ -1438,7 +1438,7 @@ namespace zeus {
} }
template<> template<>
zeus::Raw Parameter::getParameter<zeus::Raw>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { zeus::Raw Parameter::getParameter<zeus::Raw>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
@ -1454,11 +1454,11 @@ namespace zeus {
template<> template<>
ememory::SharedPtr<zeus::ObjectRemoteBase> Parameter::getParameter<ememory::SharedPtr<zeus::ObjectRemoteBase>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const { ememory::SharedPtr<zeus::ObjectRemoteBase> Parameter::getParameter<ememory::SharedPtr<zeus::ObjectRemoteBase>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
ememory::SharedPtr<zeus::ObjectRemoteBase> out; ememory::SharedPtr<zeus::ObjectRemoteBase> out;
zeus::ParamType type = getParameterType(_id); zeus::message::ParamType type = getParameterType(_id);
const uint8_t* pointer = getParameterPointer(_id); const uint8_t* pointer = getParameterPointer(_id);
uint32_t dataSize = getParameterSize(_id); uint32_t dataSize = getParameterSize(_id);
// TODO : Check size ... // TODO : Check size ...
if (type.getId() == zeus::paramTypeObject) { if (type.getId() == zeus::message::paramTypeObject) {
// Get the type string of the parameter: // Get the type string of the parameter:
ZEUS_VERBOSE("Get type : " << type.getName()); ZEUS_VERBOSE("Get type : " << type.getName());
ZEUS_VERBOSE("Get id : " << getSourceId() << "/" << getSourceObjectId()); ZEUS_VERBOSE("Get id : " << getSourceId() << "/" << getSourceObjectId());

View File

@ -24,12 +24,12 @@ namespace etk {
return "???"; return "???";
} }
} }
std::ostream& zeus::operator <<(std::ostream& _os, enum zeus::message::type _value) { std::ostream& zeus::message::operator <<(std::ostream& _os, enum zeus::message::type _value) {
_os << etk::to_string(_value); _os << etk::to_string(_value);
return _os; return _os;
} }
static enum zeus::message::type getTypeType(uint16_t _value) { enum zeus::message::type zeus::message::getTypeFromInt(uint16_t _value) {
switch (_value) { switch (_value) {
case 0: case 0:
return zeus::message::type::unknow; return zeus::message::type::unknow;

View File

@ -27,6 +27,8 @@ namespace zeus {
* @return a reference of the stream * @return a reference of the stream
*/ */
std::ostream& operator <<(std::ostream& _os, enum zeus::message::type _value); std::ostream& operator <<(std::ostream& _os, enum zeus::message::type _value);
enum zeus::message::type getTypeFromInt(uint16_t _value);
} }
} }

View File

@ -4,7 +4,7 @@
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#include <zeus/FileImpl.hpp> #include <zeus/zeus-File.impl.hpp>
#include <zeus/mineType.hpp> #include <zeus/mineType.hpp>
#include "debug.hpp" #include "debug.hpp"