[DEBUG/DEV] Buffer to message naming is OK, correct disconnection and add router optionnal for the gateway
This commit is contained in:
parent
f1937e97d1
commit
0619e613eb
@ -432,33 +432,34 @@ class ServiceDefinition:
|
||||
out += "#include <" + register_filename + ">\n"
|
||||
out += "#include <" + register_filename_proxy + ">\n"
|
||||
out += "#include <etk/types.hpp>\n"
|
||||
out += "#include <zeus/debug.hpp>\n"
|
||||
out += "#include <zeus/message/Message.hpp>\n"
|
||||
out += "#include <zeus/message/Data.hpp>\n"
|
||||
out += "#include <zeus/debug.hpp>\n"
|
||||
out += "#include <zeus/ParamType.hpp>\n"
|
||||
out += "#include <zeus/message/ParamType.hpp>\n"
|
||||
out += "#include <zeus/message/Parameter.hpp>\n"
|
||||
out += "#include <etk/stdTools.hpp>\n"
|
||||
out += "#include <zeus/AbstractFunction.hpp>\n"
|
||||
out += "#include <climits>\n"
|
||||
out += "#include <etk/os/FSNode.hpp>\n"
|
||||
out += "#include <zeus/message/Parameter.hpp>\n"
|
||||
out += "#include <zeus/WebServer.hpp>\n"
|
||||
out += "#include <zeus/Object.hpp>\n"
|
||||
out += "\n"
|
||||
|
||||
# now gebnerate the get and set parameter object ...
|
||||
out += "namespace zeus {\n"
|
||||
out += " template<> const zeus::ParamType& createType<ememory::SharedPtr<" + class_name + ">>() {\n"
|
||||
out += " static zeus::ParamType type(\"obj:" + class_name + "\", zeus::paramTypeObject, false, false);\n"
|
||||
out += " namespace message {\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 += " }\n"
|
||||
out += " \n"
|
||||
out += " template<> const zeus::ParamType& createType<" + class_name_proxy + ">() {\n"
|
||||
out += " static zeus::ParamType type(\"obj:" + class_name + "\", zeus::paramTypeObject, false, false);\n"
|
||||
out += " template<> const zeus::message::ParamType& createType<" + class_name_proxy + ">() {\n"
|
||||
out += " static zeus::message::ParamType type(\"obj:" + class_name + "\", zeus::message::paramTypeObject, false, false);\n"
|
||||
out += " return type;\n"
|
||||
out += " }\n"
|
||||
out += " \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 += " addType(data, createType<" + class_name + ">());\n"
|
||||
@ -486,11 +487,12 @@ class ServiceDefinition:
|
||||
out += " }\n"
|
||||
out += " \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 += " 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 += " }\n"
|
||||
out += " }\n"
|
||||
out += "}\n"
|
||||
|
||||
return [filename, out]
|
||||
@ -656,7 +658,7 @@ class ServiceDefinition:
|
||||
out += "#pragma once\n"
|
||||
out += "\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 <string>\n"
|
||||
out += "#include <vector>\n"
|
||||
@ -677,7 +679,7 @@ class ServiceDefinition:
|
||||
out += space + " * authors:" + elem + "\n"
|
||||
out += space + " */\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 += " "
|
||||
out += space + "public:\n"
|
||||
out += space + " const Proxy" + self.name[-1] + "& operator= (const zeus::ObjectRemote& _srv) {\n"
|
||||
@ -697,7 +699,7 @@ class ServiceDefinition:
|
||||
out += " {}\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:
|
||||
out += ",\n"
|
||||
out += space + " " + elem.name + "(m_obj, \"" + elem.name + "\")"
|
||||
|
@ -28,6 +28,8 @@ appl::DirectInterface::~DirectInterface() {
|
||||
APPL_INFO("--------------------------");
|
||||
APPL_INFO("-- DELETE Direct Client --");
|
||||
APPL_INFO("--------------------------");
|
||||
m_interfaceWeb.disconnect();
|
||||
APPL_INFO("--------------------------");
|
||||
}
|
||||
/*
|
||||
void appl::clientSpecificInterface::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) {
|
||||
@ -69,7 +71,7 @@ bool appl::DirectInterface::start(appl::GateWay* _gateway) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void appl::DirectInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) {
|
||||
void appl::DirectInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
if (_value == nullptr) {
|
||||
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 ...
|
||||
if (m_uid == 0) {
|
||||
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'");
|
||||
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") {
|
||||
answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress' and not '" + callObj->getCall() + "'");
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -16,15 +16,16 @@ namespace appl {
|
||||
zeus::WebServer m_interfaceWeb;
|
||||
public:
|
||||
DirectInterface(enet::Tcp _connection);
|
||||
~DirectInterface();
|
||||
virtual ~DirectInterface();
|
||||
bool start(appl::GateWay* _gateway);
|
||||
void receive(ememory::SharedPtr<zeus::Buffer> _data);
|
||||
void send(ememory::SharedPtr<zeus::Buffer> _data);
|
||||
void receive(ememory::SharedPtr<zeus::Message> _data);
|
||||
void send(ememory::SharedPtr<zeus::Message> _data);
|
||||
bool requestURI(const std::string& _uri);
|
||||
//void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
|
||||
zeus::WebServer* getInterface() {
|
||||
return &m_interfaceWeb;
|
||||
}
|
||||
bool isConnected() { return m_interfaceWeb.isActive(); };
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -56,22 +56,23 @@ namespace appl {
|
||||
// READ section data:
|
||||
enet::Tcp data = std::move(m_interface.waitNext());
|
||||
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)");
|
||||
ememory::SharedPtr<appl::DirectInterface> tmp = ememory::makeShared<appl::DirectInterface>(std::move(_connection));
|
||||
tmp->start(this);
|
||||
m_listIODirect.push_back(tmp);
|
||||
m_listTemporaryIO.push_back(tmp);
|
||||
}
|
||||
|
||||
appl::GateWay::GateWay() :
|
||||
m_idIncrement(10),
|
||||
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),
|
||||
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),
|
||||
@ -86,6 +87,16 @@ appl::GateWay::~GateWay() {
|
||||
|
||||
void appl::GateWay::addIO(const ememory::SharedPtr<appl::IOInterface>& _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) {
|
||||
@ -104,13 +115,20 @@ uint16_t appl::GateWay::getId() {
|
||||
}
|
||||
|
||||
void appl::GateWay::start() {
|
||||
if (*propertyRouterNo == false) {
|
||||
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);
|
||||
}
|
||||
|
||||
void appl::GateWay::stop() {
|
||||
m_routerClient.reset();
|
||||
m_listTemporaryIO.clear();
|
||||
m_listIO.clear();
|
||||
}
|
||||
|
||||
bool appl::GateWay::serviceExist(const std::string& _service) {
|
||||
@ -141,20 +159,6 @@ uint16_t appl::GateWay::serviceClientIdGet(const std::string& _service) {
|
||||
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> 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();
|
||||
uint16_t id = _data->getDestinationId();
|
||||
while (it != m_listIO.end()) {
|
||||
@ -188,25 +192,48 @@ bool appl::GateWay::send(ememory::SharedPtr<zeus::Buffer> _data) {
|
||||
}
|
||||
|
||||
void appl::GateWay::cleanIO() {
|
||||
APPL_VERBOSE("Check if something need to be clean ...");
|
||||
/*
|
||||
auto it = m_listIODirect.begin();
|
||||
while (it != m_listIODirect.end()) {
|
||||
APPL_INFO("Check if something need to be clean ...");
|
||||
std::vector<uint16_t> tmpIDToRemove;
|
||||
// Clean all IOs...
|
||||
{
|
||||
auto it = m_listIO.begin();
|
||||
while (it != m_listIO.end()) {
|
||||
if (*it != nullptr) {
|
||||
if ((*it)->isAlive() == false) {
|
||||
it = m_listIODirect.erase(it);
|
||||
if ((*it)->isConnected() == false) {
|
||||
tmpIDToRemove.push_back((*it)->getId());
|
||||
it = m_listIO.erase(it);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
it = m_listIODirect.erase(it);
|
||||
it = m_listIO.erase(it);
|
||||
continue;
|
||||
}
|
||||
++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) {
|
||||
m_routerClient->clean();
|
||||
}
|
||||
if (tmpIDToRemove.size() != 0) {
|
||||
APPL_TODO("Remove Ids ... " << tmpIDToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
void appl::GateWay::onClientConnect(const bool& _value) {
|
||||
|
@ -19,13 +19,14 @@ namespace appl {
|
||||
ememory::SharedPtr<appl::TcpServerInput> m_interfaceNewService;
|
||||
public:
|
||||
eproperty::Value<std::string> propertyUserName;
|
||||
eproperty::Value<bool> propertyRouterNo;
|
||||
eproperty::Value<std::string> propertyRouterIp;
|
||||
eproperty::Value<uint16_t> propertyRouterPort;
|
||||
eproperty::Value<std::string> propertyServiceIp;
|
||||
eproperty::Value<uint16_t> propertyServicePort;
|
||||
eproperty::Value<uint16_t> propertyServiceMax;
|
||||
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;
|
||||
void addIO(const ememory::SharedPtr<appl::IOInterface>& _io);
|
||||
void removeIO(const ememory::SharedPtr<appl::IOInterface>& _io);
|
||||
@ -37,8 +38,8 @@ namespace appl {
|
||||
void stop();
|
||||
//ememory::SharedPtr<appl::ServiceInterface> get(const std::string& _serviceName);
|
||||
std::vector<std::string> getAllServiceName();
|
||||
bool send(ememory::SharedPtr<zeus::Buffer> _data);
|
||||
void newService(enet::Tcp _connection);
|
||||
bool send(ememory::SharedPtr<zeus::Message> _data);
|
||||
void newDirectInterface(enet::Tcp _connection);
|
||||
void cleanIO();
|
||||
private:
|
||||
void onPropertyChangeClientIp();
|
||||
|
@ -55,7 +55,7 @@ const std::vector<std::string>& appl::IOInterface::getServiceList() {
|
||||
return m_listService;
|
||||
}
|
||||
|
||||
void appl::IOInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) {
|
||||
void appl::IOInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
if (_value == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -69,12 +69,12 @@ void appl::IOInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) {
|
||||
// Check if we are the destinated Of this message
|
||||
if ( _value->getDestinationId() == ZEUS_ID_GATEWAY
|
||||
&& _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'");
|
||||
answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'");
|
||||
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();
|
||||
switch (m_state) {
|
||||
case appl::clientState::disconnect:
|
||||
|
@ -31,9 +31,9 @@ namespace appl {
|
||||
virtual ~IOInterface();
|
||||
bool start(appl::GateWay* _gateway, uint16_t _id);
|
||||
// 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
|
||||
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
|
||||
bool checkId(uint16_t _id) const {
|
||||
return m_uid == _id;
|
||||
@ -43,6 +43,7 @@ namespace appl {
|
||||
}
|
||||
void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
|
||||
virtual zeus::WebServer* getInterface() = 0;
|
||||
virtual bool isConnected() { return false; };
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,12 @@ bool appl::clientSpecificInterface::start(appl::GateWay* _gateway, zeus::WebServ
|
||||
return true;
|
||||
}
|
||||
|
||||
void appl::clientSpecificInterface::send(ememory::SharedPtr<zeus::Buffer> _value) {
|
||||
void appl::clientSpecificInterface::send(ememory::SharedPtr<zeus::Message> _value) {
|
||||
m_interfaceWeb->writeBinary(_value);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Buffer> _value) {
|
||||
void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
if (_value == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -58,7 +58,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Buffer> _va
|
||||
answerProtocolError(transactionId, "missing parameter: 'id'");
|
||||
return;
|
||||
}
|
||||
if (_value->getType() == zeus::Buffer::typeMessage::data) {
|
||||
if (_value->getType() == zeus::Message::type::data) {
|
||||
// TRANSMIT DATA ...
|
||||
if (m_state != appl::clientState::clientIdentify) {
|
||||
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));
|
||||
return;
|
||||
}
|
||||
if (_value->getType() != zeus::Buffer::typeMessage::call) {
|
||||
if (_value->getType() != zeus::Message::type::call) {
|
||||
APPL_ERROR("Protocol error ==>missing 'call'");
|
||||
answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'");
|
||||
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();
|
||||
switch (m_state) {
|
||||
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));
|
||||
fut.andAll([=](zeus::FutureBase _ret) {
|
||||
ememory::SharedPtr<zeus::Buffer> tmpp = _ret.getRaw();
|
||||
ememory::SharedPtr<zeus::Message> tmpp = _ret.getRaw();
|
||||
if (tmpp == nullptr) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -382,7 +382,7 @@ void appl::RouterInterface::onClientData(ememory::SharedPtr<zeus::Buffer> _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);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace appl {
|
||||
clientSpecificInterface();
|
||||
~clientSpecificInterface();
|
||||
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);
|
||||
zeus::WebServer* getInterface() {
|
||||
return m_interfaceWeb;
|
||||
@ -37,10 +37,11 @@ namespace appl {
|
||||
RouterInterface(const std::string& _ip, uint16_t _port, std::string _userName, appl::GateWay* _gateway);
|
||||
virtual ~RouterInterface();
|
||||
void stop();
|
||||
void onClientData(ememory::SharedPtr<zeus::Buffer> _value);
|
||||
void onClientData(ememory::SharedPtr<zeus::Message> _value);
|
||||
bool isAlive();
|
||||
void send(const ememory::SharedPtr<zeus::Buffer>& _data);
|
||||
void send(const ememory::SharedPtr<zeus::Message>& _data);
|
||||
void clean();
|
||||
bool isConnected() { return m_interfaceWeb.isActive(); };
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
uint32_t transactionId = _value->getTransactionId();
|
||||
//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) {
|
||||
// No need to have a user ID ...
|
||||
@ -103,8 +103,8 @@ void appl::ServiceInterface::onServiceData(ememory::SharedPtr<zeus::Buffer> _val
|
||||
*/
|
||||
return;
|
||||
}
|
||||
if (_value->getType() == zeus::Buffer::typeMessage::call) {
|
||||
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value);
|
||||
if (_value->getType() == zeus::Message::type::call) {
|
||||
ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
|
||||
std::string callFunction = callObj->getCall();
|
||||
if (callFunction == "getUserName") {
|
||||
m_interfaceClient.answerValue(transactionId, _value->getClientId(), _value->getServiceId(), *m_gatewayInterface->propertyUserName);
|
||||
|
@ -24,10 +24,10 @@ namespace appl {
|
||||
virtual ~ServiceInterface();
|
||||
void start();
|
||||
void stop();
|
||||
void onServiceData(ememory::SharedPtr<zeus::Buffer> _value);
|
||||
void onServiceData(ememory::SharedPtr<zeus::Message> _value);
|
||||
bool requestURI(const std::string& _uri);
|
||||
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() {
|
||||
return m_name;
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ int main(int _argc, const char *_argv[]) {
|
||||
std::string data = _argv[iii];
|
||||
if (etk::start_with(data, "--user=") == true) {
|
||||
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) {
|
||||
basicGateway.propertyRouterIp.set(std::string(&data[12]));
|
||||
} 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(" " << _argv[0] << " [options]");
|
||||
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-port=XXX Router connection PORT (default: 1984)");
|
||||
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("==================================");
|
||||
basicGateway.start();
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
|
||||
basicGateway.cleanIO();
|
||||
}
|
||||
basicGateway.stop();
|
||||
|
@ -88,7 +88,7 @@ static int32_t nextP2(int32_t _value) {
|
||||
return val;
|
||||
}
|
||||
|
||||
void appl::BufferElementVideo::setSize(const ivec2& _size) {
|
||||
void appl::MessageElementVideo::setSize(const ivec2& _size) {
|
||||
if (m_imagerealSize != _size) {
|
||||
// Resize the buffer:
|
||||
m_imagerealSize = _size;
|
||||
@ -97,7 +97,7 @@ void appl::BufferElementVideo::setSize(const ivec2& _size) {
|
||||
//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:
|
||||
m_buffer.resize(_nbSample*_nbChannel*audio::getFormatBytes(_format));
|
||||
m_format = _format;
|
||||
@ -243,7 +243,7 @@ int appl::MediaDecoder::decode_packet(int *_gotFrame, int _cached) {
|
||||
if (format == audio::format_unknow) {
|
||||
APPL_ERROR("Unsupported audio format :" << m_frame->format << " ...");
|
||||
} else {
|
||||
// configure Buffer:
|
||||
// configure Message:
|
||||
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) {
|
||||
for (int32_t ccc=0; ccc<m_frame->channels; ++ccc) {
|
||||
@ -467,7 +467,7 @@ void appl::MediaDecoder::stop() {
|
||||
m_stopRequested = true;
|
||||
}
|
||||
|
||||
void appl::MediaDecoder::flushBuffer() {
|
||||
void appl::MediaDecoder::flushMessage() {
|
||||
// flush all decoders ...
|
||||
avcodec_flush_buffers(m_audioStream->codec);
|
||||
avcodec_flush_buffers(m_videoStream->codec);
|
||||
@ -483,7 +483,7 @@ void appl::MediaDecoder::flushBuffer() {
|
||||
|
||||
void appl::MediaDecoder::applySeek(echrono::Duration _time) {
|
||||
APPL_INFO("Apply seek : " << _time);
|
||||
flushBuffer();
|
||||
flushMessage();
|
||||
int64_t seekPos = int64_t(_time.toSeconds() * double(AV_TIME_BASE));
|
||||
|
||||
int32_t id = -1;
|
||||
|
@ -19,32 +19,32 @@ extern "C" {
|
||||
}
|
||||
|
||||
namespace appl {
|
||||
class BufferElement {
|
||||
class MessageElement {
|
||||
public:
|
||||
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)
|
||||
bool m_isUsed; //!< This buffer is used
|
||||
BufferElement():
|
||||
MessageElement():
|
||||
m_id(0),
|
||||
m_isUsed(false) {
|
||||
|
||||
}
|
||||
virtual ~BufferElement() = default;
|
||||
virtual ~MessageElement() = default;
|
||||
};
|
||||
// class that contain all the element needed for a buffer image transfert:
|
||||
class BufferElementVideo : public appl::BufferElement {
|
||||
class MessageElementVideo : public appl::BufferElement {
|
||||
public:
|
||||
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.
|
||||
int32_t m_lineSize; //!< Size of a single line (in byte)
|
||||
void setSize(const ivec2& _newSize);
|
||||
BufferElementVideo():
|
||||
MessageElementVideo():
|
||||
m_image(ivec2(32,32), egami::colorType::RGB8) {
|
||||
|
||||
}
|
||||
};
|
||||
class BufferElementAudio : public appl::BufferElement {
|
||||
class MessageElementAudio : public appl::BufferElement {
|
||||
public:
|
||||
std::vector<uint8_t> m_buffer; //!< raw audio data
|
||||
audio::format m_format; //!< Audio format buffer
|
||||
@ -66,9 +66,9 @@ namespace appl {
|
||||
return m_duration;
|
||||
}
|
||||
public:
|
||||
std::vector<BufferElementAudio> m_audioPool;
|
||||
std::vector<MessageElementAudio> m_audioPool;
|
||||
echrono::Duration m_currentAudioTime;
|
||||
std::vector<BufferElementVideo> m_videoPool;
|
||||
std::vector<MessageElementVideo> m_videoPool;
|
||||
echrono::Duration m_currentVideoTime;
|
||||
bool m_updateVideoTimeStampAfterSeek;
|
||||
int32_t audioGetOlderSlot();
|
||||
@ -126,7 +126,7 @@ namespace appl {
|
||||
void seek(const echrono::Duration& _time) {
|
||||
m_seek = _time;
|
||||
}
|
||||
void flushBuffer();
|
||||
void flushMessage();
|
||||
|
||||
void stop() override;
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ void appl::widget::VideoDisplay::init() {
|
||||
// set call all time (sample ...).
|
||||
getObjectManager().periodicCall.connect(sharedFromThis(), &appl::widget::VideoDisplay::periodicEvent);
|
||||
// Create the VBO:
|
||||
m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO);
|
||||
m_VBO = gale::resource::VirtualMessageObject::create(NB_VBO);
|
||||
if (m_VBO == nullptr) {
|
||||
APPL_ERROR("can not instanciate VBO ...");
|
||||
return;
|
||||
@ -181,41 +181,41 @@ void appl::widget::VideoDisplay::printPart(const vec2& _size,
|
||||
//EWOL_ERROR("Debug image " << m_filename << " ==> " << m_position << " " << _size << " " << _sourcePosStart << " " << _sourcePosStop);
|
||||
vec3 point = m_position;
|
||||
vec2 tex(_sourcePosStart.x(),_sourcePosStop.y());
|
||||
m_VBO->pushOnBuffer(m_vboIdCoord, point);
|
||||
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
|
||||
m_VBO->pushOnMessage(m_vboIdCoord, point);
|
||||
m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnMessage(m_vboIdColor, m_color);
|
||||
|
||||
tex.setValue(_sourcePosStop.x(),_sourcePosStop.y());
|
||||
point.setX(m_position.x() + _size.x());
|
||||
point.setY(m_position.y());
|
||||
m_VBO->pushOnBuffer(m_vboIdCoord, point);
|
||||
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
|
||||
m_VBO->pushOnMessage(m_vboIdCoord, point);
|
||||
m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnMessage(m_vboIdColor, m_color);
|
||||
|
||||
tex.setValue(_sourcePosStop.x(),_sourcePosStart.y());
|
||||
point.setX(m_position.x() + _size.x());
|
||||
point.setY(m_position.y() + _size.y());
|
||||
m_VBO->pushOnBuffer(m_vboIdCoord, point);
|
||||
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
|
||||
m_VBO->pushOnMessage(m_vboIdCoord, point);
|
||||
m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnMessage(m_vboIdColor, m_color);
|
||||
|
||||
m_VBO->pushOnBuffer(m_vboIdCoord, point);
|
||||
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
|
||||
m_VBO->pushOnMessage(m_vboIdCoord, point);
|
||||
m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnMessage(m_vboIdColor, m_color);
|
||||
|
||||
tex.setValue(_sourcePosStart.x(),_sourcePosStart.y());
|
||||
point.setX(m_position.x());
|
||||
point.setY(m_position.y() + _size.y());
|
||||
m_VBO->pushOnBuffer(m_vboIdCoord, point);
|
||||
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
|
||||
m_VBO->pushOnMessage(m_vboIdCoord, point);
|
||||
m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnMessage(m_vboIdColor, m_color);
|
||||
|
||||
tex.setValue(_sourcePosStart.x(),_sourcePosStop.y());
|
||||
point.setX(m_position.x());
|
||||
point.setY(m_position.y());
|
||||
m_VBO->pushOnBuffer(m_vboIdCoord, point);
|
||||
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
|
||||
m_VBO->pushOnMessage(m_vboIdCoord, point);
|
||||
m_VBO->pushOnMessage(m_vboIdCoordTex, tex);
|
||||
m_VBO->pushOnMessage(m_vboIdColor, m_color);
|
||||
m_VBO->flush();
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
|
||||
m_currentTime = m_decoder->m_seekApply;
|
||||
m_decoder->m_seekApply = echrono::Duration(-1);
|
||||
if (m_audioInterface != nullptr) {
|
||||
m_audioInterface->clearInternalBuffer();
|
||||
m_audioInterface->clearInternalMessage();
|
||||
}
|
||||
}
|
||||
// SET AUDIO:
|
||||
|
@ -45,7 +45,7 @@ namespace appl {
|
||||
static const int32_t m_vboIdCoord;
|
||||
static const int32_t m_vboIdCoordTex;
|
||||
static const int32_t m_vboIdColor;
|
||||
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_VBO;
|
||||
ememory::SharedPtr<gale::resource::VirtualMessageObject> m_VBO;
|
||||
protected:
|
||||
etk::Color<float,4> m_color;
|
||||
vec3 m_position;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <appl/ClientInterface.hpp>
|
||||
#include <zeus/Future.hpp>
|
||||
#include <appl/Router.hpp>
|
||||
#include <zeus/message/Ctrl.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) {
|
||||
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 ...
|
||||
if (m_uid == 0) {
|
||||
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'");
|
||||
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") {
|
||||
answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress' and not '" + callObj->getCall() + "'");
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
m_interfaceClient.writeBinary(_data);
|
||||
/*
|
||||
if (_data->getType() == zeus::Buffer::typeMessage::ctrl) {
|
||||
std::string value = static_cast<zeus::BufferCtrl*>(_data.get())->getCtrl();
|
||||
if (_data->getType() == zeus::Message::type::ctrl) {
|
||||
std::string value = static_cast<zeus::MessageCtrl*>(_data.get())->getCtrl();
|
||||
if (value == "DISCONNECT") {
|
||||
m_interfaceClient.disconnect(true);
|
||||
return;
|
||||
|
@ -26,8 +26,8 @@ namespace appl {
|
||||
virtual ~ClientInterface();
|
||||
void start();
|
||||
void stop();
|
||||
void onClientData(ememory::SharedPtr<zeus::Buffer> _value);
|
||||
void send(ememory::SharedPtr<zeus::Buffer> _data);
|
||||
void onClientData(ememory::SharedPtr<zeus::Message> _value);
|
||||
void send(ememory::SharedPtr<zeus::Message> _data);
|
||||
bool checkId(uint16_t _id) const {
|
||||
return m_uid == _id;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
return;
|
||||
}
|
||||
if (m_name == "") {
|
||||
uint32_t transactionId = _value->getTransactionId();
|
||||
if (_value->getType() == zeus::Buffer::typeMessage::call) {
|
||||
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value);
|
||||
if (_value->getType() == zeus::message::type::call) {
|
||||
ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
|
||||
std::string callFunction = callObj->getCall();
|
||||
if (callFunction == "connect-service") {
|
||||
if (m_name != "") {
|
||||
|
@ -24,11 +24,11 @@ namespace appl {
|
||||
virtual ~GateWayInterface();
|
||||
void start();
|
||||
void stop();
|
||||
void onServiceData(ememory::SharedPtr<zeus::Buffer> _value);
|
||||
void onServiceData(ememory::SharedPtr<zeus::Message> _value);
|
||||
public:
|
||||
uint16_t addClient(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() {
|
||||
return m_name;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace zeus {
|
||||
*/
|
||||
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 {
|
||||
protected:
|
||||
@ -129,7 +129,7 @@ namespace zeus {
|
||||
* @param[in] _class Pointer on the object that might be call (note: brut cast)
|
||||
*/
|
||||
virtual void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||
ememory::SharedPtr<zeus::BufferCall> _obj,
|
||||
ememory::SharedPtr<zeus::message::Call> _obj,
|
||||
void* _class=nullptr) = 0;
|
||||
};
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ namespace zeus {
|
||||
/**
|
||||
* @brief Execute a call on the function with a return value
|
||||
* @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] _func pointer on the function to call
|
||||
*/
|
||||
template <class ZEUS_CLASS_TYPE, class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||
void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||
ememory::SharedPtr<zeus::BufferParameter> _obj,
|
||||
ememory::SharedPtr<zeus::message::Parameter> _obj,
|
||||
ZEUS_CLASS_TYPE* _pointer,
|
||||
ZEUS_RETURN (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) {
|
||||
if (_obj == nullptr) {
|
||||
@ -49,13 +49,13 @@ namespace zeus {
|
||||
/**
|
||||
* @brief Execute a call on the function with NO return value
|
||||
* @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] _func pointer on the function to call
|
||||
*/
|
||||
template <class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||
void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||
ememory::SharedPtr<zeus::BufferParameter> _obj,
|
||||
ememory::SharedPtr<zeus::message::Parameter> _obj,
|
||||
ZEUS_CLASS_TYPE* _pointer,
|
||||
void (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) {
|
||||
if (_obj == nullptr) {
|
||||
@ -85,8 +85,8 @@ namespace zeus {
|
||||
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||
class AbstractFunctionTypeClass: public zeus::AbstractFunction {
|
||||
protected:
|
||||
static const ParamType m_returnType;
|
||||
static const ParamType m_paramType[sizeof...(ZEUS_TYPES)];
|
||||
static const zeus::message::ParamType m_returnType;
|
||||
static const zeus::message::ParamType m_paramType[sizeof...(ZEUS_TYPES)];
|
||||
public:
|
||||
using functionType = ZEUS_RETURN (ZEUS_CLASS_TYPE::*)(ZEUS_TYPES...);
|
||||
functionType m_function;
|
||||
@ -110,7 +110,7 @@ namespace zeus {
|
||||
return out;
|
||||
}
|
||||
void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||
ememory::SharedPtr<zeus::BufferCall> _obj,
|
||||
ememory::SharedPtr<zeus::message::Call> _obj,
|
||||
void* _class) override {
|
||||
if (_obj == nullptr) {
|
||||
return;
|
||||
@ -157,10 +157,10 @@ namespace zeus {
|
||||
};
|
||||
// specialization
|
||||
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
|
||||
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
|
||||
* @param[in] _name Name of the function
|
||||
|
@ -12,12 +12,12 @@ namespace zeus {
|
||||
/**
|
||||
* @brief Execute a call on the global function with a return value
|
||||
* @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
|
||||
*/
|
||||
template <class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||
void executeCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||
ememory::SharedPtr<zeus::BufferParameter> _obj,
|
||||
ememory::SharedPtr<zeus::message::Parameter> _obj,
|
||||
ZEUS_RETURN (*_func)(ZEUS_TYPES...)) {
|
||||
if (_obj == nullptr) {
|
||||
return;
|
||||
@ -44,12 +44,12 @@ namespace zeus {
|
||||
/**
|
||||
* @brief Execute a call on the global function with NO return value
|
||||
* @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
|
||||
*/
|
||||
template <class... ZEUS_TYPES>
|
||||
void executeCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||
ememory::SharedPtr<zeus::BufferParameter> _obj,
|
||||
ememory::SharedPtr<zeus::message::Parameter> _obj,
|
||||
void (*_func)(ZEUS_TYPES...)) {
|
||||
if (_obj == nullptr) {
|
||||
return;
|
||||
@ -79,8 +79,8 @@ namespace zeus {
|
||||
template <class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||
class AbstractFunctionTypeDirect: public zeus::AbstractFunction {
|
||||
protected:
|
||||
static const ParamType m_returnType;
|
||||
static const ParamType m_paramType[sizeof...(ZEUS_TYPES)];
|
||||
static const zeus::message::ParamType m_returnType;
|
||||
static const zeus::message::ParamType m_paramType[sizeof...(ZEUS_TYPES)];
|
||||
public:
|
||||
using functionType = ZEUS_RETURN (*)(ZEUS_TYPES...);
|
||||
functionType m_function;
|
||||
@ -104,7 +104,7 @@ namespace zeus {
|
||||
return out;
|
||||
}
|
||||
void execute(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||
ememory::SharedPtr<zeus::BufferCall> _obj,
|
||||
ememory::SharedPtr<zeus::message::Call> _obj,
|
||||
void* _class) override {
|
||||
if (_obj == nullptr) {
|
||||
return;
|
||||
@ -145,10 +145,10 @@ namespace zeus {
|
||||
};
|
||||
// specialization
|
||||
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
|
||||
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
|
||||
* @param[in] _name Name of the function
|
||||
|
@ -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) {
|
||||
return;
|
||||
}
|
||||
@ -60,8 +60,8 @@ void zeus::Client::onClientData(ememory::SharedPtr<zeus::Buffer> _value) {
|
||||
return;
|
||||
}
|
||||
if (_value->getDestinationObjectId() == ZEUS_ID_GATEWAY_OBJECT) {
|
||||
if (_value->getType() == zeus::Buffer::typeMessage::call) {
|
||||
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_value);
|
||||
if (_value->getType() == zeus::message::type::call) {
|
||||
ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
|
||||
std::string callFunction = callObj->getCall();
|
||||
if ( callFunction != "link"
|
||||
&& callFunction != "unlink") {
|
||||
|
@ -102,7 +102,7 @@ namespace zeus {
|
||||
* @brief When receive data from the websocket ... call this ...
|
||||
* @param[in] _value New input buffer
|
||||
*/
|
||||
void onClientData(ememory::SharedPtr<zeus::Buffer> _value);
|
||||
void onClientData(ememory::SharedPtr<zeus::Message> _value);
|
||||
public:
|
||||
/**
|
||||
* @brief Create a call on the interface gateway (threw the router)
|
||||
@ -116,7 +116,7 @@ namespace zeus {
|
||||
const std::string& _functionName,
|
||||
_ARGS&&... _args) {
|
||||
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");
|
||||
return zeus::FutureBase(0, ret);
|
||||
}
|
||||
|
156
zeus/Future.cpp
156
zeus/Future.cpp
@ -14,339 +14,339 @@ namespace zeus {
|
||||
template<>
|
||||
bool zeus::Future<bool>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
int64_t zeus::Future<int64_t>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
int32_t zeus::Future<int32_t>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
int16_t zeus::Future<int16_t>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
int8_t zeus::Future<int8_t>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
uint64_t zeus::Future<uint64_t>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
uint32_t zeus::Future<uint32_t>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
uint16_t zeus::Future<uint16_t>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
uint8_t zeus::Future<uint8_t>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
double zeus::Future<double>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
float zeus::Future<float>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
std::string zeus::Future<std::string>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
std::vector<int64_t> zeus::Future<std::vector<int64_t>>::get() {
|
||||
std::vector<int64_t> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<int32_t> zeus::Future<std::vector<int32_t>>::get() {
|
||||
std::vector<int32_t> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<int16_t> zeus::Future<std::vector<int16_t>>::get() {
|
||||
std::vector<int16_t> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<int8_t> zeus::Future<std::vector<int8_t>>::get() {
|
||||
std::vector<int8_t> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint64_t> zeus::Future<std::vector<uint64_t>>::get() {
|
||||
std::vector<uint64_t> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint32_t> zeus::Future<std::vector<uint32_t>>::get() {
|
||||
std::vector<uint32_t> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint16_t> zeus::Future<std::vector<uint16_t>>::get() {
|
||||
std::vector<uint16_t> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint8_t> zeus::Future<std::vector<uint8_t>>::get() {
|
||||
std::vector<uint8_t> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<double> zeus::Future<std::vector<double>>::get() {
|
||||
std::vector<double> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<float> zeus::Future<std::vector<float>>::get() {
|
||||
std::vector<float> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<std::string> zeus::Future<std::vector<std::string>>::get() {
|
||||
std::vector<std::string> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
std::vector<bool> zeus::Future<std::vector<bool>>::get() {
|
||||
std::vector<bool> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
template<>
|
||||
zeus::Raw zeus::Future<zeus::Raw>::get() {
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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<>
|
||||
ememory::SharedPtr<zeus::ObjectRemoteBase> zeus::Future<ememory::SharedPtr<zeus::ObjectRemoteBase>>::get() {
|
||||
ememory::SharedPtr<zeus::ObjectRemoteBase> out;
|
||||
if ( m_promise == nullptr
|
||||
|| m_promise->m_message == nullptr) {
|
||||
|| m_promise->getRaw() == nullptr) {
|
||||
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 ...");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,18 @@ zeus::FutureBase::FutureBase(uint32_t _transactionId, uint32_t _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) {
|
||||
return nullptr;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@ -66,12 +70,12 @@ zeus::FutureBase zeus::FutureBase::operator= (const zeus::FutureBase& _base) {
|
||||
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) {
|
||||
ZEUS_ERROR(" Not a valid future ...");
|
||||
return true;
|
||||
}
|
||||
return m_promise->setBuffer(_value);
|
||||
return m_promise->setMessage(_value);
|
||||
}
|
||||
|
||||
uint32_t zeus::FutureBase::getTransactionId() const {
|
||||
@ -106,7 +110,7 @@ std::string zeus::FutureBase::getErrorHelp() const {
|
||||
if (m_promise == nullptr) {
|
||||
return "This is a nullptr future";
|
||||
}
|
||||
m_promise->getErrorHelp();
|
||||
return m_promise->getErrorHelp();
|
||||
}
|
||||
|
||||
bool zeus::FutureBase::isValid() const {
|
||||
@ -124,7 +128,7 @@ const zeus::FutureBase& zeus::FutureBase::wait() const {
|
||||
if (m_promise == nullptr) {
|
||||
return *this;
|
||||
}
|
||||
m_promise.waitFor(echrono::seconds(5));
|
||||
m_promise->waitFor(echrono::seconds(5));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -132,7 +136,7 @@ const zeus::FutureBase& zeus::FutureBase::waitFor(echrono::Duration _delta) cons
|
||||
if (m_promise == nullptr) {
|
||||
return *this;
|
||||
}
|
||||
m_promise.waitFor(_delta);
|
||||
m_promise->waitFor(_delta);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -140,7 +144,7 @@ const zeus::FutureBase& zeus::FutureBase::waitUntil(echrono::Steady _endTime) co
|
||||
if (m_promise == nullptr) {
|
||||
return *this;
|
||||
}
|
||||
m_promise.waitUntil(_endTime);
|
||||
m_promise->waitUntil(_endTime);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,11 @@ namespace zeus {
|
||||
* @param[in] _base the FutureBase to copy
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -37,7 +42,7 @@ namespace zeus {
|
||||
* @param[in] _returnData Set return value
|
||||
* @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
|
||||
* @param[in] _callback Handle on the function to call in all case
|
||||
@ -71,7 +76,7 @@ namespace zeus {
|
||||
* @param[in] _returnValue Returned buffer
|
||||
* @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
|
||||
* @return Transaction Id requested or 0
|
||||
@ -125,10 +130,10 @@ namespace zeus {
|
||||
*/
|
||||
const FutureBase& waitUntil(echrono::Steady _endTime) const;
|
||||
/**
|
||||
* @brief Get the Buffer receive
|
||||
* @brief Get the Message receive
|
||||
* @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
|
||||
* @return Tile in nanosecond to wait answer
|
||||
|
@ -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) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
if (_obj->getType() == zeus::Buffer::typeMessage::event) {
|
||||
if (_obj->getType() == zeus::message::type::event) {
|
||||
ZEUS_ERROR("Unknow event: '...'");
|
||||
return;
|
||||
}
|
||||
if (_obj->getType() == zeus::Buffer::typeMessage::answer) {
|
||||
if (_obj->getType() == zeus::message::type::answer) {
|
||||
ZEUS_ERROR("Local Answer: '...'");
|
||||
return;
|
||||
}
|
||||
if (_obj->getType() == zeus::Buffer::typeMessage::call) {
|
||||
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_obj);
|
||||
if (_obj->getType() == zeus::message::type::call) {
|
||||
ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_obj);
|
||||
uint32_t source = callObj->getSource();
|
||||
uint32_t sourceId = callObj->getSourceId();
|
||||
std::string callFunction = callObj->getCall();
|
||||
|
@ -44,20 +44,20 @@ namespace zeus {
|
||||
*/
|
||||
virtual ~Object();
|
||||
public:
|
||||
void receive(ememory::SharedPtr<zeus::Buffer> _value);
|
||||
void receive(ememory::SharedPtr<zeus::Message> _value);
|
||||
private:
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
void callBinary(ememory::SharedPtr<zeus::Buffer> _obj);
|
||||
void callBinary(ememory::SharedPtr<zeus::Message> _obj);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @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:
|
||||
/**
|
||||
* @brief
|
||||
@ -163,7 +163,7 @@ namespace zeus {
|
||||
* @param[in]
|
||||
* @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) {
|
||||
if (it2 == nullptr) {
|
||||
continue;
|
||||
|
@ -4,42 +4,42 @@
|
||||
* @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) {
|
||||
|
||||
}
|
||||
|
||||
zeus::Future<std::string> zeus::SystemProxy::getDescription() {
|
||||
zeus::Future<std::string> zeus::ObjectIntrospect::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");
|
||||
}
|
||||
|
||||
zeus::Future<std::string> zeus::SystemProxy::getType() {
|
||||
zeus::Future<std::string> zeus::ObjectIntrospect::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");
|
||||
}
|
||||
|
||||
zeus::Future<std::vector<std::string>> zeus::SystemProxy::getAuthors() {
|
||||
zeus::Future<std::vector<std::string>> zeus::ObjectIntrospect::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");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include <zeus/ObjectRemote.hpp>
|
||||
|
||||
namespace zeus {
|
||||
class SystemProxy {
|
||||
class ObjectIntrospect {
|
||||
protected:
|
||||
zeus::ObjectRemote& m_srv; //!< Service instance handle
|
||||
public:
|
||||
SystemProxy(zeus::ObjectRemote& _srv);
|
||||
ObjectIntrospect(zeus::ObjectRemote& _srv);
|
||||
zeus::Future<std::string> getDescription();
|
||||
zeus::Future<std::string> getVersion();
|
||||
zeus::Future<std::string> getType();
|
||||
|
@ -99,7 +99,7 @@ namespace zeus {
|
||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||
if ( m_interface == 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) {
|
||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <zeus/Promise.hpp>
|
||||
#include <zeus/FutureBase.hpp>
|
||||
#include <zeus/message/Answer.hpp>
|
||||
#include <zeus/debug.hpp>
|
||||
|
||||
@ -14,11 +15,11 @@ zeus::Promise::Promise(uint32_t _transactionId, uint32_t _source) {
|
||||
m_source = _source;
|
||||
}
|
||||
|
||||
ememory::SharedPtr<zeus::message::Message> zeus::Promise::getRaw() {
|
||||
ememory::SharedPtr<zeus::Message> zeus::Promise::getRaw() {
|
||||
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_transactionId = _transactionId;
|
||||
m_source = _source;
|
||||
@ -37,11 +38,11 @@ void zeus::Promise::andAll(zeus::Promise::Observer _callback) {
|
||||
}
|
||||
if (hasError() == false) {
|
||||
if (m_callbackThen != nullptr) {
|
||||
m_callbackThen(*this);
|
||||
m_callbackThen(zeus::FutureBase(sharedFromThis()));
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
m_callbackThen(*this);
|
||||
m_callbackThen(zeus::FutureBase(sharedFromThis()));
|
||||
}
|
||||
|
||||
void zeus::Promise::andElse(zeus::Promise::Observer _callback) {
|
||||
@ -73,7 +74,7 @@ void zeus::Promise::andElse(zeus::Promise::Observer _callback) {
|
||||
if (m_callbackElse == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_callbackElse(*this);
|
||||
m_callbackElse(zeus::FutureBase(sharedFromThis()));
|
||||
}
|
||||
|
||||
|
||||
@ -84,7 +85,7 @@ echrono::Duration zeus::Promise::getTransmitionTime() const {
|
||||
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_message = _value;
|
||||
if (m_message == nullptr) {
|
||||
@ -96,11 +97,11 @@ bool zeus::Promise::setBuffer(ememory::SharedPtr<zeus::message::Message> _value)
|
||||
}
|
||||
if (hasError() == false) {
|
||||
if (m_callbackThen != nullptr) {
|
||||
return m_callbackThen(*this);
|
||||
return m_callbackThen(zeus::FutureBase(sharedFromThis()));
|
||||
}
|
||||
} else {
|
||||
if (m_callbackElse != nullptr) {
|
||||
return m_callbackElse(*this);
|
||||
return m_callbackElse(zeus::FutureBase(sharedFromThis()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -118,7 +119,7 @@ bool zeus::Promise::hasError() const {
|
||||
if (m_message == nullptr) {
|
||||
return true;
|
||||
}
|
||||
if (m_message->getType() != zeus::message::Message::typeMessage::answer) {
|
||||
if (m_message->getType() != zeus::message::type::answer) {
|
||||
return true;
|
||||
}
|
||||
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) {
|
||||
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 static_cast<const zeus::message::Answer*>(m_message.get())->getError();
|
||||
@ -138,7 +139,7 @@ std::string zeus::Promise::getErrorHelp() const {
|
||||
if (m_message == nullptr) {
|
||||
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 static_cast<const zeus::message::Answer*>(m_message.get())->getErrorHelp();
|
||||
@ -153,15 +154,14 @@ bool zeus::Promise::isFinished() const {
|
||||
return m_message->getPartFinish();
|
||||
}
|
||||
|
||||
const zeus::Promise& zeus::Promise::wait() const {
|
||||
void zeus::Promise::wait() const {
|
||||
while (isFinished() == false) {
|
||||
// TODO : Do it better ... like messaging/mutex_locked ...
|
||||
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();
|
||||
while ( echrono::Steady::now() - start < _delta
|
||||
&& isFinished() == false) {
|
||||
@ -169,15 +169,13 @@ const zeus::Promise& zeus::Promise::waitFor(echrono::Duration _delta) const {
|
||||
std::this_thread::sleep_for(echrono::milliseconds(10));
|
||||
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
|
||||
&& isFinished() == false) {
|
||||
// TODO : Do it better ... like messaging/mutex_locked ...
|
||||
std::this_thread::sleep_for(echrono::milliseconds(10));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <zeus/message/Message.hpp>
|
||||
#include <functional>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <echrono/Duration.hpp>
|
||||
|
||||
|
||||
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...
|
||||
*/
|
||||
class Promise {
|
||||
class Promise : public ememory::EnableSharedFromThis<zeus::Promise> {
|
||||
public:
|
||||
using Observer = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer
|
||||
private:
|
||||
uint32_t m_transactionId; //!< waiting answer data
|
||||
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_callbackElse; //!< observer callback When data arrive and AN error appear
|
||||
//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] _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
|
||||
* @param[in] _callback Handle on the function to call in all case
|
||||
@ -70,7 +72,7 @@ namespace zeus {
|
||||
* @param[in] _returnValue Returned buffer
|
||||
* @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
|
||||
* @return Transaction Id requested or 0
|
||||
@ -105,24 +107,24 @@ namespace zeus {
|
||||
* @brief Wait the Future receive data
|
||||
* @return reference on the current futur
|
||||
*/
|
||||
const FutureBase& wait() const;
|
||||
void wait() const;
|
||||
/**
|
||||
* @brief Wait the Future receive data
|
||||
* @param[in] _delta delay to wait the data arrive
|
||||
* @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
|
||||
* @param[in] _endTime tiem to wait the data
|
||||
* @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
|
||||
*/
|
||||
ememory::SharedPtr<zeus::message::Message> getRaw();
|
||||
ememory::SharedPtr<zeus::Message> getRaw();
|
||||
/**
|
||||
* @brief Get duration of the current trasaction take
|
||||
* @return Tile in nanosecond to wait answer
|
||||
|
@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <zeus/ObjectRemote.hpp>
|
||||
#include <zeus/ObjectIntrospection.hpp>
|
||||
#include <zeus/ObjectIntrospect.hpp>
|
||||
|
||||
namespace zeus {
|
||||
/**
|
||||
@ -16,7 +16,7 @@ namespace zeus {
|
||||
protected:
|
||||
zeus::ObjectRemote m_obj; //!< Service instance handle
|
||||
public:
|
||||
zeus::ObjectIntrospection sys;
|
||||
zeus::ObjectIntrospect sys;
|
||||
public:
|
||||
const Proxy& operator= (const zeus::ObjectRemote& _srv);
|
||||
Proxy();
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
namespace zeus {
|
||||
/**
|
||||
* @brief Raw data Buffer
|
||||
* @brief Raw data Message
|
||||
*/
|
||||
class Raw {
|
||||
private:
|
||||
|
@ -26,7 +26,7 @@ namespace zeus {
|
||||
uint32_t getFullId() {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,10 @@
|
||||
#include <ethread/tools.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::BufferCall> obj = zeus::BufferCall::create(_iface);
|
||||
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::message::Call> obj = zeus::message::Call::create(_iface);
|
||||
if (obj == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -23,7 +22,7 @@ ememory::SharedPtr<zeus::BufferCall> zeus::createBaseCall(const ememory::SharedP
|
||||
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 ...
|
||||
}
|
||||
|
||||
@ -73,10 +72,18 @@ void zeus::WebServer::setInterface(enet::Tcp _connection, bool _isServer, const
|
||||
}
|
||||
|
||||
zeus::WebServer::~WebServer() {
|
||||
ZEUS_WARNING("destroy WebServer ... [START]");
|
||||
ZEUS_INFO("disconnect ...");
|
||||
disconnect();
|
||||
ZEUS_WARNING("disconnect (done) ");
|
||||
ZEUS_INFO("stop thread pool ...");
|
||||
m_processingPool.stop();
|
||||
ZEUS_INFO("stop thread pool (done)");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // TODO : Remove this ...
|
||||
ZEUS_INFO("stop thread join ...");
|
||||
m_processingPool.join();
|
||||
ZEUS_INFO("stop thread join (done)");
|
||||
ZEUS_WARNING("destroy WebServer ... [STOP]");
|
||||
}
|
||||
|
||||
void zeus::WebServer::setInterfaceName(const std::string& _name) {
|
||||
@ -160,7 +167,7 @@ class SendAsyncBinary {
|
||||
m_partId++;
|
||||
}
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
@ -181,7 +188,7 @@ class SendAsyncBinary {
|
||||
//#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) {
|
||||
return -2;
|
||||
}
|
||||
@ -225,9 +232,9 @@ void zeus::WebServer::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary
|
||||
disconnect(true);
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<zeus::Buffer> dataRaw = zeus::Buffer::create(sharedFromThis(), _frame);
|
||||
ememory::SharedPtr<zeus::Message> dataRaw = zeus::Message::create(sharedFromThis(), _frame);
|
||||
if (dataRaw == nullptr) {
|
||||
ZEUS_ERROR("Buffer Allocation ERROR ... ");
|
||||
ZEUS_ERROR("Message Allocation ERROR ... ");
|
||||
disconnect(true);
|
||||
return;
|
||||
}
|
||||
@ -239,14 +246,14 @@ void zeus::WebServer::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary
|
||||
return;
|
||||
}
|
||||
dataRaw->setInterfaceId(m_interfaceId);
|
||||
newBuffer(dataRaw);
|
||||
newMessage(dataRaw);
|
||||
}
|
||||
|
||||
void zeus::WebServer::ping() {
|
||||
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);
|
||||
// if an adress id different ... just transmit it ...
|
||||
if (m_localAddress != _buffer->getDestinationId()) {
|
||||
@ -262,16 +269,16 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
|
||||
return;
|
||||
}
|
||||
if ( _buffer->getPartFinish() == false
|
||||
&& _buffer->getType() != zeus::Buffer::typeMessage::data) {
|
||||
m_listPartialBuffer.push_back(_buffer);
|
||||
&& _buffer->getType() != zeus::message::type::data) {
|
||||
m_listPartialMessage.push_back(_buffer);
|
||||
return;
|
||||
}
|
||||
if (_buffer->getType() == zeus::Buffer::typeMessage::data) {
|
||||
if (_buffer->getType() == zeus::message::type::data) {
|
||||
// Add data in a previous buffer...
|
||||
auto it = m_listPartialBuffer.begin();
|
||||
while (it != m_listPartialBuffer.end()) {
|
||||
auto it = m_listPartialMessage.begin();
|
||||
while (it != m_listPartialMessage.end()) {
|
||||
if (*it == nullptr) {
|
||||
it = m_listPartialBuffer.erase(it);
|
||||
it = m_listPartialMessage.erase(it);
|
||||
continue;
|
||||
}
|
||||
if ((*it)->getDestination() != _buffer->getDestination()) {
|
||||
@ -279,13 +286,13 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
|
||||
continue;
|
||||
}
|
||||
if ((*it)->getTransactionId() == _buffer->getTransactionId()) {
|
||||
(*it)->appendBuffer(_buffer);
|
||||
(*it)->appendMessage(_buffer);
|
||||
if (_buffer->getPartFinish() != true) {
|
||||
return;
|
||||
}
|
||||
(*it)->setPartFinish(true);
|
||||
_buffer = *it;
|
||||
it = m_listPartialBuffer.erase(it);
|
||||
it = m_listPartialMessage.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -299,8 +306,8 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
|
||||
zeus::FutureBase future;
|
||||
uint64_t tid = _buffer->getTransactionId();
|
||||
// TODO : Check the UDI reaaly utility ...
|
||||
if ( _buffer->getType() == zeus::Buffer::typeMessage::answer
|
||||
|| _buffer->getType() == zeus::Buffer::typeMessage::data) {
|
||||
if ( _buffer->getType() == zeus::message::type::answer
|
||||
|| _buffer->getType() == zeus::message::type::data) {
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
auto it = m_pendingCall.begin();
|
||||
while (it != m_pendingCall.end()) {
|
||||
@ -351,7 +358,7 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
|
||||
zeus::FutureBase fut = future;
|
||||
ZEUS_INFO("PROCESS FUTURE : " << _buffer);
|
||||
// add data ...
|
||||
bool ret = fut.setBuffer(_buffer);
|
||||
bool ret = fut.setMessage(_buffer);
|
||||
if (ret == true) {
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
auto it = m_pendingCall.begin();
|
||||
@ -412,11 +419,11 @@ void zeus::WebServer::threadAsyncCallback() {
|
||||
|
||||
|
||||
zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId,
|
||||
ememory::SharedPtr<zeus::Buffer> _obj,
|
||||
ememory::SharedPtr<zeus::Message> _obj,
|
||||
const uint32_t& _destination) {
|
||||
if (isActive() == false) {
|
||||
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)");
|
||||
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) {
|
||||
auto ctrl = zeus::BufferCtrl::create(sharedFromThis());
|
||||
auto ctrl = zeus::MessageCtrl::create(sharedFromThis());
|
||||
if (ctrl == nullptr) {
|
||||
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) {
|
||||
auto answer = zeus::BufferAnswer::create(sharedFromThis());
|
||||
auto answer = zeus::message::Answer::create(sharedFromThis());
|
||||
if (answer == nullptr) {
|
||||
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) {
|
||||
auto answer = zeus::BufferAnswer::create(sharedFromThis());
|
||||
auto answer = zeus::message::Answer::create(sharedFromThis());
|
||||
if (answer == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace zeus {
|
||||
* @param[in]
|
||||
* @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,
|
||||
const uint32_t& _source,
|
||||
const uint32_t& _destination,
|
||||
@ -42,7 +42,7 @@ namespace zeus {
|
||||
*/
|
||||
void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
||||
int32_t _paramId,
|
||||
ememory::SharedPtr<zeus::BufferCall> _obj);
|
||||
ememory::SharedPtr<zeus::message::Call> _obj);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@ -52,7 +52,7 @@ namespace zeus {
|
||||
template<class ZEUS_TYPE, class... _ARGS>
|
||||
void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
||||
int32_t _paramId,
|
||||
ememory::SharedPtr<zeus::BufferCall> _obj,
|
||||
ememory::SharedPtr<zeus::message::Call> _obj,
|
||||
const ZEUS_TYPE& _param,
|
||||
_ARGS&&... _args) {
|
||||
_obj->addParameter<ZEUS_TYPE>(_iface, _param);
|
||||
@ -68,7 +68,7 @@ namespace zeus {
|
||||
template<class... _ARGS>
|
||||
void createParam(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
||||
int32_t _paramId,
|
||||
ememory::SharedPtr<zeus::BufferCall> _obj,
|
||||
ememory::SharedPtr<zeus::message::Call> _obj,
|
||||
const char* _param,
|
||||
_ARGS&&... _args) {
|
||||
createParam(_iface, _paramId, _obj, std::string(_param), std::forward<_ARGS>(_args)...);
|
||||
@ -79,8 +79,8 @@ namespace zeus {
|
||||
* @return
|
||||
*/
|
||||
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::BufferCall> callElem = createBaseCall(_iface, _transactionId, _source, _destination, _functionName);
|
||||
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::message::Call> callElem = createBaseCall(_iface, _transactionId, _source, _destination, _functionName);
|
||||
if (callElem == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -97,7 +97,7 @@ namespace zeus {
|
||||
private:
|
||||
enet::WebSocket m_connection;
|
||||
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_licalIdObjectIncrement; //!< attribute a unique ID for an object
|
||||
public:
|
||||
@ -123,7 +123,7 @@ namespace zeus {
|
||||
std::mutex m_pendingCallMutex;
|
||||
std::vector<std::pair<uint64_t, zeus::FutureBase>> m_pendingCall;
|
||||
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;
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
template<class CLASS_TYPE>
|
||||
void connect(CLASS_TYPE* _class, void (CLASS_TYPE::*_func)(ememory::SharedPtr<zeus::Buffer>)) {
|
||||
m_observerElement = [=](ememory::SharedPtr<zeus::Buffer> _value){
|
||||
void connect(CLASS_TYPE* _class, void (CLASS_TYPE::*_func)(ememory::SharedPtr<zeus::Message>)) {
|
||||
m_observerElement = [=](ememory::SharedPtr<zeus::Message> _value){
|
||||
(*_class.*_func)(_value);
|
||||
};
|
||||
}
|
||||
@ -210,7 +210,7 @@ namespace zeus {
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
int32_t writeBinary(ememory::SharedPtr<zeus::Buffer> _data);
|
||||
int32_t writeBinary(ememory::SharedPtr<zeus::Message> _data);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
@ -234,7 +234,7 @@ namespace zeus {
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
void newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer);
|
||||
void newMessage(ememory::SharedPtr<zeus::Message> _buffer);
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
@ -280,7 +280,7 @@ namespace zeus {
|
||||
* @return
|
||||
*/
|
||||
zeus::FutureBase callBinary(uint64_t _transactionId,
|
||||
ememory::SharedPtr<zeus::Buffer> _obj,
|
||||
ememory::SharedPtr<zeus::Message> _obj,
|
||||
const uint32_t& _service=0);
|
||||
public:
|
||||
/**
|
||||
@ -291,7 +291,7 @@ namespace zeus {
|
||||
template<class... _ARGS>
|
||||
zeus::FutureBase call(const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) {
|
||||
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);
|
||||
}
|
||||
public:
|
||||
@ -302,7 +302,7 @@ namespace zeus {
|
||||
* @return
|
||||
*/
|
||||
zeus::FutureBase callForward(uint32_t _source,
|
||||
ememory::SharedPtr<zeus::Buffer> _Buffer,
|
||||
ememory::SharedPtr<zeus::Message> _Message,
|
||||
uint64_t _singleReferenceId);
|
||||
/**
|
||||
* @brief
|
||||
@ -310,7 +310,7 @@ namespace zeus {
|
||||
* @return
|
||||
*/
|
||||
void callForwardMultiple(uint32_t _source,
|
||||
ememory::SharedPtr<zeus::Buffer> _Buffer,
|
||||
ememory::SharedPtr<zeus::Message> _Message,
|
||||
uint64_t _singleReferenceId);
|
||||
#endif
|
||||
public: // answers ...
|
||||
@ -329,7 +329,7 @@ namespace zeus {
|
||||
*/
|
||||
template<class ZEUS_ARG>
|
||||
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->setSource(_source);
|
||||
answer->setDestination(_destination);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <zeus/message/Answer.hpp>
|
||||
|
||||
void zeus::message::Answer::generateDisplay(std::ostream& _os) const {
|
||||
zeus::Buffer::generateDisplay(_os);
|
||||
zeus::Message::generateDisplay(_os);
|
||||
if (getNumberParameter() != 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) {
|
||||
zeus::Buffer::writeOn(_interface);
|
||||
zeus::Message::writeOn(_interface);
|
||||
_interface.writeData((uint8_t*)m_errorType.c_str(), m_errorType.size() + 1);
|
||||
if (m_errorType.size() != 0) {
|
||||
_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) {
|
||||
@ -69,11 +69,11 @@ void zeus::message::Answer::composeWith(const uint8_t* _buffer, uint32_t _lenght
|
||||
pos++;
|
||||
}
|
||||
// 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) {
|
||||
parameterAppendBufferData(_obj);
|
||||
void zeus::message::Answer::appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) {
|
||||
parameterAppendMessageData(_obj);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
@ -14,28 +14,28 @@ namespace zeus {
|
||||
namespace message {
|
||||
class Answer :
|
||||
public message::Parameter {
|
||||
friend class zeus::message::Message;
|
||||
friend class zeus::Message;
|
||||
protected:
|
||||
std::string m_errorType;
|
||||
std::string m_errorHelp;
|
||||
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):
|
||||
zeus::message::Parameter(_iface) {
|
||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::answer);
|
||||
};
|
||||
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;
|
||||
void generateDisplay(std::ostream& _os) const override;
|
||||
public:
|
||||
/**
|
||||
* @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:
|
||||
enum zeus::message::type getType() const override {
|
||||
return zeus::message::type::answer;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <zeus/message/Call.hpp>
|
||||
|
||||
void zeus::message::Call::generateDisplay(std::ostream& _os) const {
|
||||
zeus::Buffer::generateDisplay(_os);
|
||||
zeus::Message::generateDisplay(_os);
|
||||
_os << " '" + m_callName + "'";
|
||||
_os << " nbParam=" + etk::to_string(getNumberParameter());
|
||||
if (getNumberParameter() != 0) {
|
||||
@ -35,9 +35,9 @@ void zeus::message::Call::setCall(const std::string& _value) {
|
||||
}
|
||||
|
||||
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);
|
||||
return BufferParameter::writeOn(_interface);
|
||||
return message::Parameter::writeOn(_interface);
|
||||
}
|
||||
|
||||
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++;
|
||||
// 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) {
|
||||
parameterAppendBufferData(_obj);
|
||||
void zeus::message::Call::appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj) {
|
||||
parameterAppendMessageData(_obj);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
@ -11,29 +11,29 @@
|
||||
|
||||
namespace zeus {
|
||||
namespace message {
|
||||
class BufferCall :
|
||||
public BufferParameter {
|
||||
friend class zeus::Buffer;
|
||||
class Call :
|
||||
public message::Parameter {
|
||||
friend class zeus::Message;
|
||||
protected:
|
||||
std::string m_callName;
|
||||
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):
|
||||
zeus::BufferParameter(_iface) {
|
||||
Call(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
zeus::message::Parameter(_iface) {
|
||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::call);
|
||||
};
|
||||
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;
|
||||
void generateDisplay(std::ostream& _os) const override;
|
||||
public:
|
||||
/**
|
||||
* @brief Create a shared pointer on the BufferCall
|
||||
* @return Allocated Buffer.
|
||||
* @brief Create a shared pointer on the MessageCall
|
||||
* @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:
|
||||
enum zeus::message::type getType() const override {
|
||||
return zeus::message::type::call;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <zeus/message/Data.hpp>
|
||||
|
||||
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 << " part=" << etk::to_string(m_partId);
|
||||
_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) {
|
||||
zeus::Buffer::writeOn(_interface);
|
||||
zeus::Message::writeOn(_interface);
|
||||
_interface.writeData((uint8_t*)&m_partId, sizeof(uint32_t));
|
||||
_interface.writeData((uint8_t*)&m_parameterId, sizeof(uint16_t));
|
||||
_interface.writeData((uint8_t*)&m_data[0], m_data.size());
|
||||
|
@ -5,22 +5,22 @@
|
||||
*/
|
||||
#pragma once
|
||||
#include <etk/types.hpp>
|
||||
#include <enet/WebSocket.hpp>
|
||||
#include <zeus/WebServer.hpp>
|
||||
#include <zeus/message/ParamType.hpp>
|
||||
#include <zeus/message/Message.hpp>
|
||||
|
||||
namespace zeus {
|
||||
class WebServer;
|
||||
namespace message {
|
||||
class BufferData:
|
||||
public Buffer {
|
||||
friend class zeus::Buffer;
|
||||
class Data: public zeus::Message {
|
||||
friend class zeus::Message;
|
||||
protected:
|
||||
uint32_t m_partId;
|
||||
uint16_t m_parameterId;
|
||||
std::vector<uint8_t> m_data;
|
||||
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):
|
||||
zeus::Message(_iface),
|
||||
@ -28,13 +28,13 @@ namespace zeus {
|
||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::data);
|
||||
};
|
||||
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;
|
||||
void generateDisplay(std::ostream& _os) const override;
|
||||
public:
|
||||
/**
|
||||
* @brief Create a shared pointer on the BufferData
|
||||
* @return Allocated Buffer.
|
||||
* @brief Create a shared pointer on the MessageData
|
||||
* @return Allocated Message.
|
||||
*/
|
||||
static ememory::SharedPtr<zeus::message::Data> create(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||
public:
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/types.hpp>
|
||||
#include <zeus/message/Buffer.hpp>
|
||||
#include <zeus/message/Message.hpp>
|
||||
#include <zeus/debug.hpp>
|
||||
#include <zeus/message/ParamType.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
@ -15,8 +15,8 @@
|
||||
// -- Factory
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
ememory::SharedPtr<zeus::BufferEvent> zeus::BufferEvent::create() {
|
||||
return ememory::SharedPtr<zeus::BufferEvent>(new zeus::BufferEvent);
|
||||
ememory::SharedPtr<zeus::MessageEvent> zeus::MessageEvent::create() {
|
||||
return ememory::SharedPtr<zeus::MessageEvent>(new zeus::MessageEvent);
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -11,24 +11,24 @@
|
||||
namespace zeus {
|
||||
namespace message {
|
||||
/*
|
||||
class BufferEvent :
|
||||
public BufferParameter {
|
||||
friend class zeus::Buffer;
|
||||
class MessageEvent :
|
||||
public message::Parameter {
|
||||
friend class zeus::Message;
|
||||
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);
|
||||
};
|
||||
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:
|
||||
/ **
|
||||
* @brief Create a shared pointer on the BufferEvent
|
||||
* @return Allocated Buffer.
|
||||
* @brief Create a shared pointer on the MessageEvent
|
||||
* @return Allocated Message.
|
||||
* /
|
||||
static ememory::SharedPtr<zeus::BufferEvent> create();
|
||||
static ememory::SharedPtr<zeus::MessageEvent> create();
|
||||
public:
|
||||
enum zeus::message::type getType() const override {
|
||||
return zeus::message::type::event;
|
||||
|
@ -15,8 +15,8 @@
|
||||
// -- Factory
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
ememory::SharedPtr<zeus::BufferFlow> zeus::BufferFlow::create() {
|
||||
return ememory::SharedPtr<zeus::BufferFlow>(new zeus::BufferFlow);
|
||||
ememory::SharedPtr<zeus::MessageFlow> zeus::MessageFlow::create() {
|
||||
return ememory::SharedPtr<zeus::MessageFlow>(new zeus::MessageFlow);
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -11,23 +11,23 @@
|
||||
namespace zeus {
|
||||
namespace message {
|
||||
/*
|
||||
class BufferFlow:
|
||||
public Buffer {
|
||||
friend class zeus::Buffer;
|
||||
class MessageFlow:
|
||||
public Message {
|
||||
friend class zeus::Message;
|
||||
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);
|
||||
};
|
||||
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||
public:
|
||||
/ **
|
||||
* @brief Create a shared pointer on the BufferFlow
|
||||
* @return Allocated Buffer.
|
||||
* @brief Create a shared pointer on the MessageFlow
|
||||
* @return Allocated Message.
|
||||
* /
|
||||
static ememory::SharedPtr<zeus::BufferFlow> create();
|
||||
static ememory::SharedPtr<zeus::MessageFlow> create();
|
||||
public:
|
||||
enum zeus::message::type getType() const override {
|
||||
return zeus::message::type::flow;
|
||||
|
@ -18,16 +18,16 @@
|
||||
#include <zeus/WebServer.hpp>
|
||||
|
||||
|
||||
zeus::message::Message(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
zeus::Message::Message(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
m_iface(_iface) {
|
||||
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");
|
||||
}
|
||||
|
||||
void zeus::message::appendBuffer(ememory::SharedPtr<zeus::Message> _obj) {
|
||||
void zeus::Message::appendMessage(ememory::SharedPtr<zeus::Message> _obj) {
|
||||
if (_obj == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -39,23 +39,23 @@ void zeus::message::appendBuffer(ememory::SharedPtr<zeus::Message> _obj) {
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
_interface.writeData((uint8_t*)&m_header, sizeof(headerBin));
|
||||
_interface.writeData((uint8_t*)&m_header, sizeof(zeus::message::headerBin));
|
||||
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
|
||||
}
|
||||
|
||||
void zeus::message::clear() {
|
||||
void zeus::Message::clear() {
|
||||
m_header.transactionId = 1;
|
||||
m_header.sourceId = 0;
|
||||
m_header.sourceObjectId = 0;
|
||||
@ -73,7 +73,7 @@ std::ostream& zeus::operator <<(std::ostream& _os, ememory::SharedPtr<zeus::Mess
|
||||
}
|
||||
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
|
||||
_os << " if=" << etk::to_string(getInterfaceId());
|
||||
_os << " tr-id=" << etk::to_string(getTransactionId());
|
||||
@ -87,9 +87,6 @@ void zeus::message::generateDisplay(std::ostream& _os) const {
|
||||
case zeus::message::type::unknow:
|
||||
_os << " -UNKNOW-";
|
||||
break;
|
||||
case zeus::message::type::ctrl:
|
||||
_os << " -CTRL-";
|
||||
break;
|
||||
case zeus::message::type::call:
|
||||
_os << " -CALL-";
|
||||
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;
|
||||
}
|
||||
|
||||
void zeus::message::setInterfaceId(uint32_t _value) {
|
||||
void zeus::Message::setInterfaceId(uint32_t _value) {
|
||||
m_interfaceID = _value;
|
||||
}
|
||||
|
||||
uint32_t zeus::message::getTransactionId() const {
|
||||
uint32_t zeus::Message::getTransactionId() const {
|
||||
return m_header.transactionId;
|
||||
}
|
||||
|
||||
void zeus::message::setTransactionId(uint32_t _value) {
|
||||
void zeus::Message::setTransactionId(uint32_t _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;
|
||||
}
|
||||
|
||||
void zeus::message::setSource(uint32_t _value) {
|
||||
void zeus::Message::setSource(uint32_t _value) {
|
||||
m_header.sourceId = _value >> 16;
|
||||
m_header.sourceObjectId = _value & 0xFFFF;
|
||||
}
|
||||
|
||||
uint16_t zeus::message::getSourceId() const {
|
||||
uint16_t zeus::Message::getSourceId() const {
|
||||
return m_header.sourceId;
|
||||
}
|
||||
|
||||
void zeus::message::setSourceId(uint16_t _value) {
|
||||
void zeus::Message::setSourceId(uint16_t _value) {
|
||||
m_header.sourceId = _value;
|
||||
}
|
||||
|
||||
uint16_t zeus::message::getSourceObjectId() const {
|
||||
uint16_t zeus::Message::getSourceObjectId() const {
|
||||
return m_header.sourceObjectId;
|
||||
}
|
||||
|
||||
void zeus::message::setSourceObjectId(uint16_t _value) {
|
||||
void zeus::Message::setSourceObjectId(uint16_t _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;
|
||||
}
|
||||
|
||||
void zeus::message::setDestination(uint32_t _value) {
|
||||
void zeus::Message::setDestination(uint32_t _value) {
|
||||
m_header.destinationId = _value >> 16;
|
||||
m_header.destinationObjectId = _value & 0xFFFF;
|
||||
}
|
||||
|
||||
uint16_t zeus::message::getDestinationId() const {
|
||||
uint16_t zeus::Message::getDestinationId() const {
|
||||
return m_header.destinationId;
|
||||
}
|
||||
|
||||
void zeus::message::setDestinationId(uint16_t _value) {
|
||||
void zeus::Message::setDestinationId(uint16_t _value) {
|
||||
m_header.destinationId = _value;
|
||||
}
|
||||
|
||||
uint16_t zeus::message::getDestinationObjectId() const {
|
||||
uint16_t zeus::Message::getDestinationObjectId() const {
|
||||
return m_header.destinationObjectId;
|
||||
}
|
||||
|
||||
void zeus::message::setDestinationObjectId(uint16_t _value) {
|
||||
void zeus::Message::setDestinationObjectId(uint16_t _value) {
|
||||
m_header.destinationObjectId = _value;
|
||||
}
|
||||
|
||||
bool zeus::message::getPartFinish() const {
|
||||
bool zeus::Message::getPartFinish() const {
|
||||
return (m_header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0;
|
||||
}
|
||||
|
||||
void zeus::message::setPartFinish(bool _value) {
|
||||
void zeus::Message::setPartFinish(bool _value) {
|
||||
if (_value == true) {
|
||||
m_header.flags = (m_header.flags & 0x7F) | ZEUS_BUFFER_FLAG_FINISH;
|
||||
} 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;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// -- 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));
|
||||
}
|
||||
|
||||
ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer) {
|
||||
headerBin header;
|
||||
if (_buffer.size() < sizeof(headerBin)) {
|
||||
ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer) {
|
||||
zeus::message::headerBin header;
|
||||
if (_buffer.size() < sizeof(zeus::message::headerBin)) {
|
||||
ZEUS_ERROR("wrong size of the buffer");
|
||||
return nullptr;
|
||||
}
|
||||
memcpy(reinterpret_cast<char*>(&header), &_buffer[0], sizeof(headerBin));
|
||||
enum zeus::message::type type = getTypeType(uint16_t(header.flags & 0x07));
|
||||
memcpy(reinterpret_cast<char*>(&header), &_buffer[0], sizeof(zeus::message::headerBin));
|
||||
enum zeus::message::type type = zeus::message::getTypeFromInt(uint16_t(header.flags & 0x07));
|
||||
switch (type) {
|
||||
case zeus::message::type::unknow:
|
||||
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: {
|
||||
ememory::SharedPtr<zeus::MessageCall> value = zeus::MessageCall::create(_iface);
|
||||
ememory::SharedPtr<zeus::message::Call> value = zeus::message::Call::create(_iface);
|
||||
if (value == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -232,13 +213,13 @@ ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus:
|
||||
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));
|
||||
value->composeWith(&_buffer[sizeof(zeus::message::headerBin)],
|
||||
_buffer.size() - sizeof(zeus::message::headerBin));
|
||||
return value;
|
||||
}
|
||||
break;
|
||||
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) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -248,13 +229,13 @@ ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus:
|
||||
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));
|
||||
value->composeWith(&_buffer[sizeof(zeus::message::headerBin)],
|
||||
_buffer.size() - sizeof(zeus::message::headerBin));
|
||||
return value;
|
||||
}
|
||||
break;
|
||||
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) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -264,8 +245,8 @@ ememory::SharedPtr<zeus::Message> zeus::message::create(ememory::SharedPtr<zeus:
|
||||
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));
|
||||
value->composeWith(&_buffer[sizeof(zeus::message::headerBin)],
|
||||
_buffer.size() - sizeof(zeus::message::headerBin));
|
||||
return value;
|
||||
}
|
||||
break;
|
||||
|
@ -121,13 +121,13 @@ namespace zeus {
|
||||
virtual ~Message() = default;
|
||||
/**
|
||||
* @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);
|
||||
/**
|
||||
* @brief Create a shared pointer on the buffer
|
||||
* @param[in] _buffer Buffer on the data
|
||||
* @return Allocated Buffer.
|
||||
* @param[in] _buffer Message on the data
|
||||
* @return Allocated Message.
|
||||
*/
|
||||
static ememory::SharedPtr<zeus::Message> create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer);
|
||||
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 ...
|
||||
* @param[in] _obj Buffer to add
|
||||
* @param[in] _obj Message to add
|
||||
*/
|
||||
void appendBuffer(ememory::SharedPtr<zeus::Message> _obj);
|
||||
virtual void appendBufferData(ememory::SharedPtr<zeus::MessageData> _obj);
|
||||
void appendMessage(ememory::SharedPtr<zeus::Message> _obj);
|
||||
virtual void appendMessageData(ememory::SharedPtr<zeus::message::Data> _obj);
|
||||
protected:
|
||||
/**
|
||||
* @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);
|
||||
/**
|
||||
* @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;
|
||||
/**
|
||||
@ -274,7 +274,7 @@ namespace zeus {
|
||||
/**
|
||||
* @brief generate a display of the typemessage
|
||||
* @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
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, ememory::SharedPtr<zeus::Message> _obj);
|
||||
@ -283,13 +283,13 @@ namespace zeus {
|
||||
// internal:
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
* @param[in] _data Buffer to add type
|
||||
* @param[in] _data Message to add type
|
||||
* @param[in] _type string of the type to add
|
||||
*/
|
||||
void addTypeObject(std::vector<uint8_t>& _data, const std::string _type);
|
||||
|
@ -93,10 +93,12 @@ bool zeus::message::ParamType::operator != (const uint16_t& _value) const {
|
||||
|
||||
#define generate_basic_type(_type, _name, _id, _num, _vect) \
|
||||
namespace zeus { \
|
||||
namespace message { \
|
||||
template<> const zeus::message::ParamType& createType<_type>() {\
|
||||
static zeus::message::ParamType type(_name, _id, _num, _vect); \
|
||||
return type; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
const uint16_t zeus::message::ParamTypeObject = 0xFFFF;
|
||||
const uint16_t zeus::message::paramTypeObject = 0xFFFF;
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace zeus {
|
||||
*/
|
||||
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);
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <zeus/File.hpp>
|
||||
|
||||
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) {
|
||||
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size());
|
||||
return createType<void>();
|
||||
@ -111,11 +111,11 @@ zeus::ParamType zeus::message::Parameter::getParameterType(int32_t _id) const {
|
||||
if (find == false) {
|
||||
ZEUS_ERROR("Request object with a name too big ==> error ...");
|
||||
m_parameter[_id].first = 0;
|
||||
return zeus::ParamType("no-name", typeId);
|
||||
return zeus::message::ParamType("no-name", typeId);
|
||||
}
|
||||
std::string type(tmp);
|
||||
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 ... ");
|
||||
return createType<void>();
|
||||
@ -151,7 +151,7 @@ uint16_t zeus::message::Parameter::getNumberParameter() 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.isNumber() == true) {
|
||||
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();
|
||||
}
|
||||
|
||||
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:
|
||||
uint16_t parameterID = _obj->getParameterId();
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace zeus {
|
||||
class WebServer;
|
||||
namespace message {
|
||||
class Parameter:
|
||||
public Buffer {
|
||||
public Message {
|
||||
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...)
|
||||
public:
|
||||
@ -40,7 +40,7 @@ namespace zeus {
|
||||
* @param[in] _id Number 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
|
||||
* @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) {
|
||||
addParameter(_iface, m_parameter.size(), _value);
|
||||
}
|
||||
void parameterAppendBufferData(ememory::SharedPtr<zeus::BufferData> _obj);
|
||||
void parameterAppendMessageData(ememory::SharedPtr<zeus::message::Data> _obj);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,12 @@
|
||||
#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()));
|
||||
}
|
||||
|
||||
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));
|
||||
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;
|
||||
addType(data, createType<void>());
|
||||
m_parameter.push_back(std::make_pair(2,data));
|
||||
}
|
||||
void zeus::Parameter::addParameterEmptyVector() {
|
||||
void zeus::message::Parameter::addParameterEmptyVector() {
|
||||
// special case of json change mode
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<void>>());
|
||||
@ -326,7 +326,7 @@ namespace zeus {
|
||||
uint32_t _destination,
|
||||
uint32_t _transactionId,
|
||||
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->setSource(_source);
|
||||
answer->setDestination(_destination);
|
||||
@ -357,7 +357,7 @@ namespace zeus {
|
||||
data.resize(data.size()+_value.size());
|
||||
memcpy(&data[currentOffset], _value.data(), _value.size());
|
||||
} 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));
|
||||
|
@ -16,7 +16,7 @@ namespace zeus {
|
||||
namespace message {
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
if (createType<bool>() != type) {
|
||||
@ -34,7 +34,7 @@ namespace zeus {
|
||||
template<>
|
||||
std::string Parameter::getParameter<std::string>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::string out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
out.resize(dataSize, 0);
|
||||
@ -45,7 +45,7 @@ namespace zeus {
|
||||
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -85,7 +85,7 @@ namespace zeus {
|
||||
}
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -126,7 +126,7 @@ namespace zeus {
|
||||
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -167,7 +167,7 @@ namespace zeus {
|
||||
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -215,7 +215,7 @@ namespace zeus {
|
||||
#endif
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -256,7 +256,7 @@ namespace zeus {
|
||||
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -297,7 +297,7 @@ namespace zeus {
|
||||
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -338,7 +338,7 @@ namespace zeus {
|
||||
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -379,7 +379,7 @@ namespace zeus {
|
||||
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -419,7 +419,7 @@ namespace zeus {
|
||||
}
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -484,7 +484,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -574,7 +574,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -665,7 +665,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -756,7 +756,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -847,7 +847,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -938,7 +938,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -1029,7 +1029,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -1120,7 +1120,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -1211,7 +1211,7 @@ namespace zeus {
|
||||
template<>
|
||||
std::vector<float> Parameter::getParameter<std::vector<float>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<float> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -1302,7 +1302,7 @@ namespace zeus {
|
||||
template<>
|
||||
std::vector<double> Parameter::getParameter<std::vector<double>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<double> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -1393,7 +1393,7 @@ namespace zeus {
|
||||
template<>
|
||||
std::vector<bool> Parameter::getParameter<std::vector<bool>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<bool> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -1415,7 +1415,7 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
if (type == createType<std::vector<void>>()) {
|
||||
@ -1438,7 +1438,7 @@ namespace zeus {
|
||||
}
|
||||
template<>
|
||||
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);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
@ -1454,11 +1454,11 @@ namespace zeus {
|
||||
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> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
zeus::message::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
if (type.getId() == zeus::paramTypeObject) {
|
||||
if (type.getId() == zeus::message::paramTypeObject) {
|
||||
// Get the type string of the parameter:
|
||||
ZEUS_VERBOSE("Get type : " << type.getName());
|
||||
ZEUS_VERBOSE("Get id : " << getSourceId() << "/" << getSourceObjectId());
|
||||
|
@ -24,12 +24,12 @@ namespace etk {
|
||||
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);
|
||||
return _os;
|
||||
}
|
||||
|
||||
static enum zeus::message::type getTypeType(uint16_t _value) {
|
||||
enum zeus::message::type zeus::message::getTypeFromInt(uint16_t _value) {
|
||||
switch (_value) {
|
||||
case 0:
|
||||
return zeus::message::type::unknow;
|
||||
|
@ -27,6 +27,8 @@ namespace zeus {
|
||||
* @return a reference of the stream
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum zeus::message::type _value);
|
||||
|
||||
enum zeus::message::type getTypeFromInt(uint16_t _value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <zeus/FileImpl.hpp>
|
||||
#include <zeus/zeus-File.impl.hpp>
|
||||
#include <zeus/mineType.hpp>
|
||||
#include "debug.hpp"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user