[DEV] correct rework of buffer interface to manage more type of messages ...
This commit is contained in:
parent
42ada729aa
commit
8b21709a01
@ -37,20 +37,20 @@ int main(int _argc, const char *_argv[]) {
|
|||||||
APPL_INFO("==================================");
|
APPL_INFO("==================================");
|
||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
bool ret = client1.connect("test1~atria-soft.com", "clientTest1#atria-soft.com", "QSDQSDGQSF54HSXWVCSQDJ654URTDJ654NBXCDFDGAEZ51968");
|
bool ret = client1.connect("test1~atria-soft.com", "clientTest1~atria-soft.com", "QSDQSDGQSF54HSXWVCSQDJ654URTDJ654NBXCDFDGAEZ51968");
|
||||||
if (ret == false) {
|
if (ret == false) {
|
||||||
APPL_ERROR(" ==> NOT Connected with 'clientTest1#atria-soft.com'");
|
APPL_ERROR(" ==> NOT Connected to 'test1~atria-soft.com' with 'clientTest1~atria-soft.com'");
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
APPL_INFO(" ==> Connected with 'clientTest1#atria-soft.com'");
|
APPL_INFO(" ==> Connected with 'clientTest1~atria-soft.com'");
|
||||||
}
|
}
|
||||||
} else if (true) {
|
} else if (true) {
|
||||||
bool ret = client1.connect("test1~atria-soft.com", "coucou");
|
bool ret = client1.connect("test1~atria-soft.com", "coucou");
|
||||||
if (ret == false) {
|
if (ret == false) {
|
||||||
APPL_ERROR(" ==> NOT Authentify with 'test1#atria-soft.com'");
|
APPL_ERROR(" ==> NOT Authentify with 'test1~atria-soft.com'");
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
APPL_INFO(" ==> Authentify with 'test1#atria-soft.com'");
|
APPL_INFO(" ==> Authentify with 'test1~atria-soft.com'");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool ret = client1.connect("test1~atria-soft.com");
|
bool ret = client1.connect("test1~atria-soft.com");
|
||||||
|
@ -109,7 +109,8 @@ void appl::ClientInterface::onClientData(const ememory::SharedPtr<zeus::Buffer>&
|
|||||||
answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'");
|
answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string callFunction = _value->getCall();
|
ememory::SharedPtr<zeus::BufferCall> callObj = std::static_pointer_cast<zeus::BufferCall>(_value);
|
||||||
|
std::string callFunction = callObj->getCall();
|
||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
case appl::ClientInterface::state::disconnect:
|
case appl::ClientInterface::state::disconnect:
|
||||||
case appl::ClientInterface::state::unconnect:
|
case appl::ClientInterface::state::unconnect:
|
||||||
@ -125,7 +126,7 @@ void appl::ClientInterface::onClientData(const ememory::SharedPtr<zeus::Buffer>&
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (callFunction == "connectToUser") {
|
if (callFunction == "connectToUser") {
|
||||||
m_userConnectionName = _value->getParameter<std::string>(0);
|
m_userConnectionName = callObj->getParameter<std::string>(0);
|
||||||
if (m_userConnectionName == "") {
|
if (m_userConnectionName == "") {
|
||||||
answerProtocolError(transactionId, "Call connectToUser with no parameter 'user'");
|
answerProtocolError(transactionId, "Call connectToUser with no parameter 'user'");
|
||||||
} else {
|
} else {
|
||||||
@ -158,8 +159,8 @@ void appl::ClientInterface::onClientData(const ememory::SharedPtr<zeus::Buffer>&
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (callFunction == "identify") {
|
if (callFunction == "identify") {
|
||||||
std::string clientName = _value->getParameter<std::string>(0);
|
std::string clientName = callObj->getParameter<std::string>(0);
|
||||||
std::string clientTocken = _value->getParameter<std::string>(1);
|
std::string clientTocken = callObj->getParameter<std::string>(1);
|
||||||
if (m_userService == nullptr) {
|
if (m_userService == nullptr) {
|
||||||
answerProtocolError(transactionId, "gateWay internal error 3");
|
answerProtocolError(transactionId, "gateWay internal error 3");
|
||||||
return;
|
return;
|
||||||
@ -180,7 +181,7 @@ void appl::ClientInterface::onClientData(const ememory::SharedPtr<zeus::Buffer>&
|
|||||||
m_clientName = clientName;
|
m_clientName = clientName;
|
||||||
}
|
}
|
||||||
if (callFunction == "auth") {
|
if (callFunction == "auth") {
|
||||||
std::string password = _value->getParameter<std::string>(0);
|
std::string password = callObj->getParameter<std::string>(0);
|
||||||
zeus::Future<bool> fut = m_userService->m_interfaceClient.callClient(m_uid2, "checkAuth", password);
|
zeus::Future<bool> fut = m_userService->m_interfaceClient.callClient(m_uid2, "checkAuth", password);
|
||||||
fut.wait(); // TODO: Set timeout ...
|
fut.wait(); // TODO: Set timeout ...
|
||||||
if (fut.hasError() == true) {
|
if (fut.hasError() == true) {
|
||||||
@ -235,7 +236,7 @@ void appl::ClientInterface::onClientData(const ememory::SharedPtr<zeus::Buffer>&
|
|||||||
break;
|
break;
|
||||||
case appl::ClientInterface::state::clientIdentify:
|
case appl::ClientInterface::state::clientIdentify:
|
||||||
{
|
{
|
||||||
uint32_t serviceId = _value->getServiceId();
|
uint32_t serviceId = callObj->getServiceId();
|
||||||
if (serviceId == 0) {
|
if (serviceId == 0) {
|
||||||
// This is 2 default service for the cient interface that manage the authorisation of view:
|
// This is 2 default service for the cient interface that manage the authorisation of view:
|
||||||
if (callFunction == "getServiceCount") {
|
if (callFunction == "getServiceCount") {
|
||||||
@ -249,7 +250,7 @@ void appl::ClientInterface::onClientData(const ememory::SharedPtr<zeus::Buffer>&
|
|||||||
}
|
}
|
||||||
if (callFunction == "link") {
|
if (callFunction == "link") {
|
||||||
// first param:
|
// first param:
|
||||||
std::string serviceName = _value->getParameter<std::string>(0);
|
std::string serviceName = callObj->getParameter<std::string>(0);
|
||||||
// Check if service already link:
|
// Check if service already link:
|
||||||
auto it = m_listConnectedService.begin();
|
auto it = m_listConnectedService.begin();
|
||||||
while (it != m_listConnectedService.end()) {
|
while (it != m_listConnectedService.end()) {
|
||||||
@ -290,7 +291,7 @@ void appl::ClientInterface::onClientData(const ememory::SharedPtr<zeus::Buffer>&
|
|||||||
}
|
}
|
||||||
if (callFunction == "unlink") {
|
if (callFunction == "unlink") {
|
||||||
// first param: the service we want to unconnect ...
|
// first param: the service we want to unconnect ...
|
||||||
int64_t localServiceID = _value->getParameter<int64_t>(0)-1;
|
int64_t localServiceID = callObj->getParameter<int64_t>(0)-1;
|
||||||
// Check if service already link:
|
// Check if service already link:
|
||||||
if (localServiceID >= m_listConnectedService.size()) {
|
if (localServiceID >= m_listConnectedService.size()) {
|
||||||
m_interfaceClient.answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
m_interfaceClient.answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||||
@ -332,10 +333,10 @@ void appl::ClientInterface::onClientData(const ememory::SharedPtr<zeus::Buffer>&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ZEUS_DEBUG(" ==> transmit : " << tmpp->getTransactionId() << " -> " << transactionId);
|
ZEUS_DEBUG(" ==> transmit : " << tmpp->getTransactionId() << " -> " << transactionId);
|
||||||
ZEUS_DEBUG(" msg=" << *tmpp);
|
ZEUS_DEBUG(" msg=" << tmpp);
|
||||||
tmpp->setTransactionId(transactionId);
|
tmpp->setTransactionId(transactionId);
|
||||||
tmpp->setServiceId(serviceId+1);
|
tmpp->setServiceId(serviceId+1);
|
||||||
ZEUS_DEBUG("transmit=" << *tmpp);
|
ZEUS_DEBUG("transmit=" << tmpp);
|
||||||
m_interfaceClient.writeBinary(tmpp);
|
m_interfaceClient.writeBinary(tmpp);
|
||||||
// multiple send element ...
|
// multiple send element ...
|
||||||
return tmpp->getPartFinish();
|
return tmpp->getPartFinish();
|
||||||
|
@ -75,14 +75,15 @@ void appl::ServiceInterface::onServiceData(const ememory::SharedPtr<zeus::Buffer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_value->getType() == zeus::Buffer::typeMessage::call) {
|
if (_value->getType() == zeus::Buffer::typeMessage::call) {
|
||||||
std::string callFunction = _value->getCall();
|
ememory::SharedPtr<zeus::BufferCall> callObj = std::static_pointer_cast<zeus::BufferCall>(_value);
|
||||||
|
std::string callFunction = callObj->getCall();
|
||||||
if (callFunction == "connect-service") {
|
if (callFunction == "connect-service") {
|
||||||
if (m_name != "") {
|
if (m_name != "") {
|
||||||
ZEUS_WARNING("Service interface ==> try change the servie name after init: '" << _value->getParameter<std::string>(0));
|
ZEUS_WARNING("Service interface ==> try change the servie name after init: '" << callObj->getParameter<std::string>(0));
|
||||||
m_interfaceClient.answerValue(transactionId, false);
|
m_interfaceClient.answerValue(transactionId, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_name = _value->getParameter<std::string>(0);
|
m_name = callObj->getParameter<std::string>(0);
|
||||||
m_interfaceClient.setInterfaceName("srv-" + m_name);
|
m_interfaceClient.setInterfaceName("srv-" + m_name);
|
||||||
m_interfaceClient.answerValue(transactionId, true);
|
m_interfaceClient.answerValue(transactionId, true);
|
||||||
return;
|
return;
|
||||||
|
@ -124,7 +124,7 @@ namespace zeus {
|
|||||||
* @param[in] _class Pointer on the object that might be call (note: brut cast)
|
* @param[in] _class Pointer on the object that might be call (note: brut cast)
|
||||||
*/
|
*/
|
||||||
virtual void execute(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
virtual void execute(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferCall>& _obj,
|
||||||
void* _class=nullptr) = 0;
|
void* _class=nullptr) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template <class ZEUS_CLASS_TYPE, class ZEUS_RETURN, class... ZEUS_TYPES>
|
template <class ZEUS_CLASS_TYPE, class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||||
void executeClassCall(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
void executeClassCall(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferParameter>& _obj,
|
||||||
ZEUS_CLASS_TYPE* _pointer,
|
ZEUS_CLASS_TYPE* _pointer,
|
||||||
ZEUS_RETURN (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) {
|
ZEUS_RETURN (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
@ -54,7 +54,7 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template <class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
template <class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||||
void executeClassCall(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
void executeClassCall(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferParameter>& _obj,
|
||||||
ZEUS_CLASS_TYPE* _pointer,
|
ZEUS_CLASS_TYPE* _pointer,
|
||||||
void (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) {
|
void (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...)) {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
@ -108,7 +108,7 @@ namespace zeus {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
void execute(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
void execute(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferCall>& _obj,
|
||||||
void* _class) override {
|
void* _class) override {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -17,7 +17,7 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template <class ZEUS_RETURN, class... ZEUS_TYPES>
|
template <class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||||
void executeCall(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
void executeCall(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferParameter>& _obj,
|
||||||
ZEUS_RETURN (*_func)(ZEUS_TYPES...)) {
|
ZEUS_RETURN (*_func)(ZEUS_TYPES...)) {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -46,7 +46,7 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template <class... ZEUS_TYPES>
|
template <class... ZEUS_TYPES>
|
||||||
void executeCall(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
void executeCall(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferParameter>& _obj,
|
||||||
void (*_func)(ZEUS_TYPES...)) {
|
void (*_func)(ZEUS_TYPES...)) {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -99,7 +99,7 @@ namespace zeus {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
void execute(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
void execute(const ememory::SharedPtr<zeus::WebServer>& _interfaceClient,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferCall>& _obj,
|
||||||
void* _class) override {
|
void* _class) override {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
628
zeus/Buffer.cpp
628
zeus/Buffer.cpp
@ -53,11 +53,11 @@ zeus::Buffer::Buffer() {
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create() {
|
void zeus::Buffer::appendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj) {
|
||||||
return ememory::SharedPtr<zeus::Buffer>(new zeus::Buffer);
|
ZEUS_ERROR("Can not append datas ... Not managed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Buffer::appendBufferData(const ememory::SharedPtr<zeus::Buffer>& _obj) {
|
void zeus::Buffer::appendBuffer(const ememory::SharedPtr<zeus::Buffer>& _obj) {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -69,161 +69,99 @@ void zeus::Buffer::appendBufferData(const ememory::SharedPtr<zeus::Buffer>& _obj
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setPartFinish(_obj->getPartFinish());
|
setPartFinish(_obj->getPartFinish());
|
||||||
if (_obj->m_parameter.size() <= 1) {
|
appendBufferData(std::static_pointer_cast<zeus::BufferData>(_obj));
|
||||||
// normal end frame with no data ==> no problem ...
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// At this point we just add data at the parameter value:
|
|
||||||
//It contain 2 things :
|
|
||||||
// - param 0 : parameter ID (int16_t)
|
|
||||||
// - param 1 : Raw data (local direct acces ...)
|
|
||||||
uint16_t parameterID = _obj->internalGetParameter<uint16_t>(0);
|
|
||||||
|
|
||||||
zeus::ParamType type = _obj->internalGetParameterType(1);
|
|
||||||
const uint8_t* pointer = _obj->internalGetParameterPointer(1);
|
|
||||||
uint32_t dataSize = _obj->internalGetParameterSize(1);
|
|
||||||
if ( type.getId() != zeus::paramTypeRaw
|
|
||||||
|| pointer == nullptr) {
|
|
||||||
ZEUS_ERROR("Can not get parameter Raw ==> stop add");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (dataSize == 0) {
|
|
||||||
// no data (normal case)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// now, we will add datas:
|
|
||||||
if (parameterID >= m_parameter.size()) {
|
|
||||||
ZEUS_ERROR("Try to add data on an unexisting parameter...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int32_t offset = m_parameter[parameterID].second.size();
|
|
||||||
m_parameter[parameterID].second.resize(offset + dataSize);
|
|
||||||
memcpy(&m_parameter[parameterID].second[offset], pointer, dataSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t zeus::Buffer::getSize() {
|
||||||
void zeus::Buffer::internalComposeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
return sizeof(headerBin);
|
||||||
clear();
|
|
||||||
if (_lenght < sizeof(headerBin)) {
|
|
||||||
ZEUS_ERROR("wrong size of the buffer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uint32_t offset = 0;
|
|
||||||
memcpy(reinterpret_cast<char*>(&m_header), &_buffer[offset], sizeof(headerBin));
|
|
||||||
offset += sizeof(headerBin);
|
|
||||||
m_parameter.clear();
|
|
||||||
m_parameter.resize(m_header.numberOfParameter, std::make_pair(-1, std::vector<uint8_t>()));
|
|
||||||
// Load all Parameters
|
|
||||||
int32_t nbParameters = 0;
|
|
||||||
while ( nbParameters < m_header.numberOfParameter
|
|
||||||
&& offset < _lenght) {
|
|
||||||
// parameters is contituated with size + data assiciated
|
|
||||||
uint32_t sizeParam;
|
|
||||||
memcpy(&sizeParam, &_buffer[offset], sizeof(uint32_t));
|
|
||||||
offset += sizeof(uint32_t);
|
|
||||||
if (offset+sizeParam > _lenght) {
|
|
||||||
ZEUS_ERROR("Wrong parameter size : " << sizeParam << " / availlable=" << _lenght-offset);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::vector<uint8_t> data;
|
|
||||||
data.resize(sizeParam);
|
|
||||||
memcpy(&data[0], &_buffer[offset], data.size() * sizeof(uint8_t));
|
|
||||||
offset += data.size() * sizeof(uint8_t);
|
|
||||||
m_parameter[nbParameters].second = data;
|
|
||||||
nbParameters++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zeus::Buffer::writeOn(enet::WebSocket& _interface) {
|
bool zeus::Buffer::writeOn(enet::WebSocket& _interface) {
|
||||||
m_header.numberOfParameter = m_parameter.size();
|
uint64_t size = getSize();
|
||||||
uint64_t size = sizeof(headerBin);
|
|
||||||
for (auto &it : m_parameter) {
|
|
||||||
size += sizeof(uint32_t); // parameter size
|
|
||||||
size += it.second.size();
|
|
||||||
}
|
|
||||||
if (_interface.writeHeader(size, false) == false) {
|
if (_interface.writeHeader(size, false) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint8_t* data = nullptr;
|
|
||||||
uint32_t dataSize = 0;
|
|
||||||
m_header.numberOfParameter = m_parameter.size();
|
|
||||||
size = _interface.writeData((uint8_t*)&m_header, sizeof(headerBin));
|
|
||||||
for (auto &it : m_parameter) {
|
|
||||||
uint32_t paramSize = it.second.size();
|
|
||||||
size = _interface.writeData((uint8_t*)¶mSize, sizeof(uint32_t));
|
|
||||||
size = _interface.writeData(&it.second[0], it.second.size() * sizeof(uint8_t));
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Buffer::composeWith(const std::vector<uint8_t>& _buffer) {
|
|
||||||
internalComposeWith(&_buffer[0], _buffer.size());
|
void zeus::Buffer::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||||
|
// impossible case
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Buffer::clear() {
|
void zeus::Buffer::clear() {
|
||||||
m_parameter.clear();
|
|
||||||
m_header.transactionID = 1;
|
m_header.transactionID = 1;
|
||||||
m_header.clientID = 0;
|
m_header.clientID = 0;
|
||||||
m_header.partID = 0x8000;
|
m_header.flags = ZEUS_BUFFER_FLAG_FINISH;
|
||||||
m_header.typeMessage = 1;
|
|
||||||
m_header.numberOfParameter = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& zeus::operator <<(std::ostream& _os, const zeus::Buffer& _obj) {
|
std::ostream& zeus::operator <<(std::ostream& _os, zeus::Buffer* _obj) {
|
||||||
_os << "zeus::Buffer: ";
|
_os << "zeus::Buffer: ";
|
||||||
//out += " v=" + etk::to_string(m_header.versionProtocol); // se it in the websocket
|
if (_obj == nullptr) {
|
||||||
_os << " id=" << etk::to_string(_obj.getTransactionId());
|
_os << "nullptr";
|
||||||
_os << " cId=" << etk::to_string(_obj.getClientId());
|
} else {
|
||||||
if ( _obj.getPartFinish() == false
|
_obj->generateDisplay(_os);
|
||||||
|| _obj.getPartId() != 0) {
|
|
||||||
_os << " part=" << etk::to_string(_obj.getPartId());
|
|
||||||
if (_obj.getPartFinish() == true) {
|
|
||||||
_os << "/finish";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
enum zeus::Buffer::typeMessage type = _obj.getType();
|
return _os;
|
||||||
|
}
|
||||||
|
void zeus::Buffer::generateDisplay(std::ostream& _os) const {
|
||||||
|
//out += " v=" + etk::to_string(m_header.versionProtocol); // se it in the websocket
|
||||||
|
_os << " id=" << etk::to_string(getTransactionId());
|
||||||
|
_os << " cId=" << etk::to_string(getClientId());
|
||||||
|
if (getPartFinish() == true) {
|
||||||
|
_os << "finish";
|
||||||
|
}
|
||||||
|
enum zeus::Buffer::typeMessage type = getType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case zeus::Buffer::typeMessage::unknow:
|
case zeus::Buffer::typeMessage::unknow:
|
||||||
_os << " -UNKNOW-";
|
_os << " -UNKNOW-";
|
||||||
break;
|
break;
|
||||||
case zeus::Buffer::typeMessage::call:
|
case zeus::Buffer::typeMessage::call:
|
||||||
_os << " nbParam=" + etk::to_string(_obj.getNumberParameter());
|
_os << " -CALL-";
|
||||||
_os << " -CALL-:'" + _obj.getCall() + "'";
|
|
||||||
break;
|
break;
|
||||||
case zeus::Buffer::typeMessage::answer:
|
case zeus::Buffer::typeMessage::answer:
|
||||||
_os << " -ANSWER-:";
|
_os << " -ANSWER-";
|
||||||
if (_obj.m_parameter.size() == 1) {
|
|
||||||
_os << "Value:" + _obj.simpleStringParam(0);
|
|
||||||
} else if (_obj.m_parameter.size() == 2) {
|
|
||||||
_os << "Error";
|
|
||||||
_os << "Error:" + _obj.simpleStringParam(0);
|
|
||||||
} else if (_obj.m_parameter.size() == 3) {
|
|
||||||
_os << "Value:" + _obj.simpleStringParam(0);
|
|
||||||
_os << "+Error:" + _obj.simpleStringParam(1);
|
|
||||||
} else {
|
|
||||||
_os << "???";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case zeus::Buffer::typeMessage::event:
|
case zeus::Buffer::typeMessage::event:
|
||||||
_os << " -EVENT-";
|
_os << " -EVENT-";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case zeus::Buffer::typeMessage::data:
|
case zeus::Buffer::typeMessage::data:
|
||||||
_os << " -DATA-";
|
_os << " -DATA-";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (_obj.getNumberParameter() != 0) {
|
}
|
||||||
|
|
||||||
|
void zeus::BufferCall::generateDisplay(std::ostream& _os) const {
|
||||||
|
zeus::Buffer::generateDisplay(_os);
|
||||||
|
_os << " '" + m_callName + "'";
|
||||||
|
_os << " nbParam=" + etk::to_string(getNumberParameter());
|
||||||
|
if (getNumberParameter() != 0) {
|
||||||
_os << " paramType(";
|
_os << " paramType(";
|
||||||
for (int32_t iii=0; iii<_obj.getNumberParameter(); ++iii) {
|
for (int32_t iii=0; iii<getNumberParameter(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << ",";
|
_os << ",";
|
||||||
}
|
}
|
||||||
_os << _obj.internalGetParameterType(iii).getName();
|
_os << getParameterType(iii).getName();
|
||||||
}
|
}
|
||||||
_os << ")";
|
_os << ")";
|
||||||
}
|
}
|
||||||
return _os;
|
}
|
||||||
|
|
||||||
|
void zeus::BufferAnswer::generateDisplay(std::ostream& _os) const {
|
||||||
|
zeus::Buffer::generateDisplay(_os);
|
||||||
|
_os << " '" + simpleStringParam(0) + "'";
|
||||||
|
if (m_errorType.size() != 0) {
|
||||||
|
_os << " Error='" + m_errorType + "'";
|
||||||
|
}if (m_errorHelp.size() != 0) {
|
||||||
|
_os << " Help='" + m_errorHelp + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferData::generateDisplay(std::ostream& _os) const {
|
||||||
|
zeus::Buffer::generateDisplay(_os);
|
||||||
|
_os << " paramId=" << etk::to_string(m_partId);
|
||||||
|
_os << " part=" << etk::to_string(m_parameterId);
|
||||||
|
_os << " nbData=" << etk::to_string(m_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t zeus::Buffer::getTransactionId() const {
|
uint32_t zeus::Buffer::getTransactionId() const {
|
||||||
@ -242,50 +180,83 @@ void zeus::Buffer::setClientId(uint32_t _value) {
|
|||||||
m_header.clientID = _value;
|
m_header.clientID = _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// note limited 15 bits
|
|
||||||
uint16_t zeus::Buffer::getPartId() const {
|
|
||||||
if (getType() != zeus::Buffer::typeMessage::data) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return uint16_t(m_header.partID & 0x7FFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void zeus::Buffer::setPartId(uint16_t _value) {
|
|
||||||
if ( getType() != zeus::Buffer::typeMessage::data
|
|
||||||
&& _value != 0) {
|
|
||||||
ZEUS_ERROR("can not set a partId at other than data buffer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_header.partID = (m_header.partID&0x8000) | (_value & 0x7FFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool zeus::Buffer::getPartFinish() const {
|
bool zeus::Buffer::getPartFinish() const {
|
||||||
return m_header.partID<0;
|
return (m_header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Buffer::setPartFinish(bool _value) {
|
void zeus::Buffer::setPartFinish(bool _value) {
|
||||||
if (_value == true) {
|
if (_value == true) {
|
||||||
m_header.partID = (m_header.partID & 0x7FFF) | 0x8000;
|
m_header.flags = (m_header.flags & 0x7F) | ZEUS_BUFFER_FLAG_FINISH;
|
||||||
} else {
|
} else {
|
||||||
m_header.partID = m_header.partID & 0x7FFF;
|
m_header.flags = m_header.flags & 0x7F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum zeus::Buffer::typeMessage zeus::Buffer::getType() const {
|
enum zeus::Buffer::typeMessage zeus::Buffer::getType() const {
|
||||||
return (enum zeus::Buffer::typeMessage)m_header.typeMessage;
|
return zeus::Buffer::typeMessage::unknow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Buffer::setType(enum typeMessage _value) {
|
|
||||||
m_header.typeMessage = uint16_t(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t zeus::Buffer::getNumberParameter() const {
|
// ------------------------------------------------------------------------------------
|
||||||
if (m_parameter.size() <= 1) {
|
// -- Multiple parameter
|
||||||
return 0;
|
// ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
size_t zeus::BufferParameter::parameterGetSize() {
|
||||||
|
size_t size = sizeof(uint16_t);
|
||||||
|
for (auto &it : m_parameter) {
|
||||||
|
size += sizeof(uint32_t); // parameter size
|
||||||
|
size += it.second.size();
|
||||||
}
|
}
|
||||||
return m_parameter.size()-1;
|
return size;
|
||||||
}
|
}
|
||||||
zeus::ParamType zeus::Buffer::internalGetParameterType(int32_t _id) const {
|
|
||||||
|
bool zeus::BufferParameter::parameterWriteOn(enet::WebSocket& _interface) {
|
||||||
|
uint8_t* data = nullptr;
|
||||||
|
uint32_t dataSize = 0;
|
||||||
|
uint16_t numberOfParameter = m_parameter.size();
|
||||||
|
size_t size = _interface.writeData((uint8_t*)&numberOfParameter, sizeof(uint16_t));
|
||||||
|
for (auto &it : m_parameter) {
|
||||||
|
uint32_t paramSize = it.second.size();
|
||||||
|
size = _interface.writeData((uint8_t*)¶mSize, sizeof(uint32_t));
|
||||||
|
size = _interface.writeData(&it.second[0], it.second.size() * sizeof(uint8_t));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferParameter::parameterComposeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||||
|
m_parameter.clear();
|
||||||
|
uint16_t nbParameters = 0;
|
||||||
|
if (_lenght < sizeof(uint16_t)) {
|
||||||
|
ZEUS_ERROR("wrong size of the buffer ==> missing parameter count");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint32_t offset = 0;
|
||||||
|
memcpy(&nbParameters, &_buffer[offset], sizeof(uint16_t));
|
||||||
|
offset += sizeof(uint16_t);
|
||||||
|
m_parameter.resize(nbParameters, std::make_pair(-1, std::vector<uint8_t>()));
|
||||||
|
// Load all Parameters
|
||||||
|
nbParameters = 0;
|
||||||
|
while ( nbParameters < m_parameter.size()
|
||||||
|
&& offset < _lenght) {
|
||||||
|
// parameters is contituated with size + data assiciated
|
||||||
|
uint32_t sizeParam;
|
||||||
|
memcpy(&sizeParam, &_buffer[offset], sizeof(uint32_t));
|
||||||
|
offset += sizeof(uint32_t);
|
||||||
|
if (offset+sizeParam > _lenght) {
|
||||||
|
ZEUS_ERROR("Wrong parameter size : " << sizeParam << " / availlable=" << _lenght-offset);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> data;
|
||||||
|
data.resize(sizeParam);
|
||||||
|
memcpy(&data[0], &_buffer[offset], data.size() * sizeof(uint8_t));
|
||||||
|
offset += data.size() * sizeof(uint8_t);
|
||||||
|
m_parameter[nbParameters].second = data;
|
||||||
|
nbParameters++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::ParamType zeus::BufferParameter::getParameterType(int32_t _id) const {
|
||||||
if (m_parameter.size() <= _id) {
|
if (m_parameter.size() <= _id) {
|
||||||
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size());
|
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size());
|
||||||
return createType<void>();
|
return createType<void>();
|
||||||
@ -335,139 +306,308 @@ zeus::ParamType zeus::Buffer::internalGetParameterType(int32_t _id) const {
|
|||||||
ZEUS_ERROR("Can not get type of parameter ... ");
|
ZEUS_ERROR("Can not get type of parameter ... ");
|
||||||
return createType<void>();
|
return createType<void>();
|
||||||
}
|
}
|
||||||
zeus::ParamType zeus::Buffer::getParameterType(int32_t _id) const {
|
|
||||||
return internalGetParameterType(_id + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint8_t* zeus::Buffer::internalGetParameterPointer(int32_t _id) const {
|
const uint8_t* zeus::BufferParameter::getParameterPointer(int32_t _id) const {
|
||||||
const uint8_t* out = nullptr;
|
const uint8_t* out = nullptr;
|
||||||
if (m_parameter.size() <= _id) {
|
if (m_parameter.size() <= _id) {
|
||||||
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size());
|
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size());
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
if (m_parameter[_id].first <= -1) {
|
if (m_parameter[_id].first <= -1) {
|
||||||
internalGetParameterType(_id); // this function initialize this parameter if needed ...
|
getParameterType(_id); // this function initialize this parameter if needed ...
|
||||||
}
|
}
|
||||||
out = reinterpret_cast<const uint8_t*>(&m_parameter[_id].second[m_parameter[_id].first]);
|
out = reinterpret_cast<const uint8_t*>(&m_parameter[_id].second[m_parameter[_id].first]);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t* zeus::Buffer::getParameterPointer(int32_t _id) const {
|
uint32_t zeus::BufferParameter::getParameterSize(int32_t _id) const {
|
||||||
return internalGetParameterPointer(_id + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t zeus::Buffer::internalGetParameterSize(int32_t _id) const {
|
|
||||||
int32_t out = 0;
|
int32_t out = 0;
|
||||||
if (m_parameter.size() <= _id) {
|
if (m_parameter.size() <= _id) {
|
||||||
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size());
|
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_parameter.size());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (m_parameter[_id].first <= -1) {
|
if (m_parameter[_id].first <= -1) {
|
||||||
internalGetParameterType(_id); // this function initialize this parameter if needed ...
|
getParameterType(_id); // this function initialize this parameter if needed ...
|
||||||
}
|
}
|
||||||
return m_parameter[_id].second.size() - m_parameter[_id].first;
|
return m_parameter[_id].second.size() - m_parameter[_id].first;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Buffer::addData(uint16_t _parameterId, void* _data, uint32_t _size) {
|
uint16_t zeus::BufferParameter::getNumberParameter() const {
|
||||||
m_parameter.clear();
|
return m_parameter.size();
|
||||||
addParameter(_parameterId);
|
|
||||||
std::vector<uint8_t> data;
|
|
||||||
// set parameter type in case of wrong interpretation
|
|
||||||
zeus::addTypeRaw(data);
|
|
||||||
int32_t offset = data.size();
|
|
||||||
data.resize(offset + _size);
|
|
||||||
memcpy(&data[offset], _data, _size);
|
|
||||||
m_parameter.push_back(std::make_pair(2,data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t zeus::Buffer::getParameterSize(int32_t _id) const {
|
std::string zeus::BufferParameter::simpleStringParam(uint32_t _id) const {
|
||||||
return internalGetParameterSize(_id + 1);
|
zeus::ParamType paramType = getParameterType(_id);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void zeus::Buffer::addError(const std::string& _value, const std::string& _comment) {
|
|
||||||
addParameter(_value);
|
|
||||||
addParameter(_comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string zeus::Buffer::getCall() const {
|
|
||||||
std::string out;
|
|
||||||
switch(getType()) {
|
|
||||||
case zeus::Buffer::typeMessage::call:
|
|
||||||
return internalGetParameter<std::string>(0);
|
|
||||||
break;
|
|
||||||
case zeus::Buffer::typeMessage::answer:
|
|
||||||
ZEUS_WARNING("get 'call' with an input type: 'answer'");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ZEUS_WARNING("get 'call' with an input type: '" << getType() << "'");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void zeus::Buffer::setCall(std::string _value) {
|
|
||||||
if (m_parameter.size() != 0) {
|
|
||||||
ZEUS_ERROR("Clear Buffer of parameter ==> set the call type in first ...");
|
|
||||||
m_parameter.clear();
|
|
||||||
}
|
|
||||||
addParameter(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool zeus::Buffer::hasError() {
|
|
||||||
if (getType() != zeus::Buffer::typeMessage::answer) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (m_parameter.size() == 2) {
|
|
||||||
return true;
|
|
||||||
} else if (m_parameter.size() == 3) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string zeus::Buffer::getError() {
|
|
||||||
if (getType() != zeus::Buffer::typeMessage::answer) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (m_parameter.size() == 2) {
|
|
||||||
return getParameter<std::string>(0);
|
|
||||||
} else if (m_parameter.size() == 3) {
|
|
||||||
return getParameter<std::string>(1);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string zeus::Buffer::getErrorHelp() {
|
|
||||||
if (getType() != zeus::Buffer::typeMessage::answer) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (m_parameter.size() == 2) {
|
|
||||||
return getParameter<std::string>(1);
|
|
||||||
} else if (m_parameter.size() == 3) {
|
|
||||||
return getParameter<std::string>(2);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string zeus::Buffer::simpleStringParam(uint32_t _id) const {
|
|
||||||
zeus::ParamType paramType = internalGetParameterType(_id);
|
|
||||||
if (paramType.isVector() == false) {
|
if (paramType.isVector() == false) {
|
||||||
if (paramType.isNumber() == true) {
|
if (paramType.isNumber() == true) {
|
||||||
return etk::to_string(internalGetParameter<int64_t>(_id));
|
return etk::to_string(getParameter<int64_t>(_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (paramType == createType<bool>()) {
|
if (paramType == createType<bool>()) {
|
||||||
return etk::to_string(internalGetParameter<bool>(_id));
|
return etk::to_string(getParameter<bool>(_id));
|
||||||
}
|
}
|
||||||
if (paramType == createType<std::string>()) {
|
if (paramType == createType<std::string>()) {
|
||||||
return "{" + internalGetParameter<std::string>(_id) + "}";
|
return "{" + getParameter<std::string>(_id) + "}";
|
||||||
}
|
}
|
||||||
if (paramType == createType<std::vector<std::string>>()) {
|
if (paramType == createType<std::vector<std::string>>()) {
|
||||||
return "[" + etk::to_string(internalGetParameter<std::vector<std::string>>(_id)) + "]";
|
return "[" + etk::to_string(getParameter<std::vector<std::string>>(_id)) + "]";
|
||||||
}
|
}
|
||||||
return paramType.getName();
|
return paramType.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void zeus::BufferParameter::parameterAppendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj) {
|
||||||
|
// At this point we just add data at the parameter value:
|
||||||
|
uint16_t parameterID = _obj->getParameterId();
|
||||||
|
|
||||||
|
if (_obj->getData().size() == 0) {
|
||||||
|
// no data (normal case)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// now, we will add datas:
|
||||||
|
if (parameterID >= m_parameter.size()) {
|
||||||
|
ZEUS_ERROR("Try to add data on an unexisting parameter...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t offset = m_parameter[parameterID].second.size();
|
||||||
|
m_parameter[parameterID].second.resize(offset + _obj->getData().size());
|
||||||
|
memcpy(&m_parameter[parameterID].second[offset], &_obj->getData()[0], _obj->getData().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
// -- Call
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const std::string& zeus::BufferCall::getCall() const {
|
||||||
|
return m_callName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferCall::setCall(const std::string& _value) {
|
||||||
|
m_callName = _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t zeus::BufferCall::getSize() {
|
||||||
|
// name + \0 + parameters ...
|
||||||
|
return m_callName.size()+1 + parameterGetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zeus::BufferCall::writeOn(enet::WebSocket& _interface) {
|
||||||
|
_interface.writeData((uint8_t*)m_callName.c_str(), m_callName.size() + 1);
|
||||||
|
return parameterWriteOn(_interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferCall::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||||
|
// First element iw the call name, after, this is the parameters...
|
||||||
|
// parse the string: (call name)
|
||||||
|
uint32_t pos = 0;
|
||||||
|
m_callName.clear();
|
||||||
|
while( pos < _lenght
|
||||||
|
&& _buffer[pos] != '\0') {
|
||||||
|
m_callName += _buffer[pos];
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
// parse parameters:
|
||||||
|
parameterComposeWith(&_buffer[pos], _lenght-pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferCall::appendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj) {
|
||||||
|
parameterAppendBufferData(_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
// -- Answer
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool zeus::BufferAnswer::hasError() {
|
||||||
|
return m_errorType.size() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& zeus::BufferAnswer::getError() {
|
||||||
|
return m_errorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& zeus::BufferAnswer::getErrorHelp() {
|
||||||
|
return m_errorHelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferAnswer::addError(const std::string& _value, const std::string& _comment) {
|
||||||
|
m_errorType = _value;
|
||||||
|
m_errorHelp = _comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t zeus::BufferAnswer::getSize() {
|
||||||
|
// name + \0 + parameters ...
|
||||||
|
size_t size = m_errorType.size()+1 + parameterGetSize();
|
||||||
|
if (m_errorType.size() != 0) {
|
||||||
|
size += m_errorHelp.size() + 1;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zeus::BufferAnswer::writeOn(enet::WebSocket& _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 parameterWriteOn(_interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferAnswer::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||||
|
// First element iw the call name, after, this is the parameters...
|
||||||
|
// parse the string: (call name)
|
||||||
|
uint32_t pos = 0;
|
||||||
|
m_errorType.clear();
|
||||||
|
m_errorHelp.clear();
|
||||||
|
while( pos < _lenght
|
||||||
|
&& _buffer[pos] != '\0') {
|
||||||
|
m_errorType += _buffer[pos];
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
if (m_errorType.size() != 0) {
|
||||||
|
while( pos < _lenght
|
||||||
|
&& _buffer[pos] != '\0') {
|
||||||
|
m_errorHelp += _buffer[pos];
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// parse parameters:
|
||||||
|
parameterComposeWith(&_buffer[pos], _lenght-pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferAnswer::appendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj) {
|
||||||
|
parameterAppendBufferData(_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
// -- Data
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void zeus::BufferData::addData(uint16_t _parameterId, void* _data, uint32_t _size) {
|
||||||
|
m_parameterId = _parameterId;
|
||||||
|
m_data.resize(_size);
|
||||||
|
memcpy(&m_data[0], _data, _size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// note limited 15 bits
|
||||||
|
uint32_t zeus::BufferData::getPartId() const {
|
||||||
|
return m_partId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferData::setPartId(uint32_t _value) {
|
||||||
|
if (_value == 0) {
|
||||||
|
ZEUS_ERROR("Part ID must be != of 0");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_partId = _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t zeus::BufferData::getSize() {
|
||||||
|
// name + \0 + parameters ...
|
||||||
|
return sizeof(uint32_t) + sizeof(uint16_t) + m_data.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zeus::BufferData::writeOn(enet::WebSocket& _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());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::BufferData::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||||
|
// First element iw the call name, after, this is the parameters...
|
||||||
|
// parse the string: (call name)
|
||||||
|
uint32_t pos = 0;
|
||||||
|
m_partId = 0;
|
||||||
|
m_parameterId = 0;
|
||||||
|
memcpy(reinterpret_cast<char*>(&m_partId), &_buffer[pos], sizeof(uint32_t));
|
||||||
|
pos += sizeof(uint32_t);
|
||||||
|
memcpy(reinterpret_cast<char*>(&m_parameterId), &_buffer[pos], sizeof(uint16_t));
|
||||||
|
pos += sizeof(uint16_t);
|
||||||
|
m_data.resize(_lenght - pos);
|
||||||
|
memcpy(&m_data[0], &_buffer[pos], m_data.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
// -- Factory
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create() {
|
||||||
|
return ememory::SharedPtr<zeus::Buffer>(new zeus::Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create(const std::vector<uint8_t>& _buffer) {
|
||||||
|
headerBin header;
|
||||||
|
if (_buffer.size() < sizeof(headerBin)) {
|
||||||
|
ZEUS_ERROR("wrong size of the buffer");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char*>(&header), &_buffer[0], sizeof(headerBin));
|
||||||
|
enum zeus::Buffer::typeMessage type = getTypeType(uint16_t(header.flags & 0x07));
|
||||||
|
switch (type) {
|
||||||
|
case zeus::Buffer::typeMessage::unknow:
|
||||||
|
return nullptr;
|
||||||
|
case zeus::Buffer::typeMessage::call: {
|
||||||
|
ememory::SharedPtr<zeus::BufferCall> value = zeus::BufferCall::create();
|
||||||
|
if (value == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
value->setTransactionId(header.transactionID);
|
||||||
|
value->setClientId(header.clientID);
|
||||||
|
value->setClientId((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0);
|
||||||
|
value->composeWith(&_buffer[sizeof(headerBin)],
|
||||||
|
_buffer.size() - sizeof(headerBin));
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case zeus::Buffer::typeMessage::answer: {
|
||||||
|
ememory::SharedPtr<zeus::BufferAnswer> value = zeus::BufferAnswer::create();
|
||||||
|
if (value == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
value->setTransactionId(header.transactionID);
|
||||||
|
value->setClientId(header.clientID);
|
||||||
|
value->setClientId((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0);
|
||||||
|
value->composeWith(&_buffer[sizeof(headerBin)],
|
||||||
|
_buffer.size() - sizeof(headerBin));
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case zeus::Buffer::typeMessage::data: {
|
||||||
|
ememory::SharedPtr<zeus::BufferData> value = zeus::BufferData::create();
|
||||||
|
if (value == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
value->setTransactionId(header.transactionID);
|
||||||
|
value->setClientId(header.clientID);
|
||||||
|
value->setClientId((header.flags & ZEUS_BUFFER_FLAG_FINISH) != 0);
|
||||||
|
value->composeWith(&_buffer[sizeof(headerBin)],
|
||||||
|
_buffer.size() - sizeof(headerBin));
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case zeus::Buffer::typeMessage::event:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ememory::SharedPtr<zeus::BufferCall> zeus::BufferCall::create() {
|
||||||
|
return ememory::SharedPtr<zeus::BufferCall>(new zeus::BufferCall);
|
||||||
|
}
|
||||||
|
|
||||||
|
ememory::SharedPtr<zeus::BufferAnswer> zeus::BufferAnswer::create() {
|
||||||
|
return ememory::SharedPtr<zeus::BufferAnswer>(new zeus::BufferAnswer);
|
||||||
|
}
|
||||||
|
|
||||||
|
ememory::SharedPtr<zeus::BufferData> zeus::BufferData::create() {
|
||||||
|
return ememory::SharedPtr<zeus::BufferData>(new zeus::BufferData);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
ememory::SharedPtr<zeus::BufferEvent> zeus::BufferEvent::create() {
|
||||||
|
return ememory::SharedPtr<zeus::BufferEvent>(new zeus::BufferEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
ememory::SharedPtr<zeus::BufferFlow> zeus::BufferFlow::create() {
|
||||||
|
return ememory::SharedPtr<zeus::BufferFlow>(new zeus::BufferFlow);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
341
zeus/Buffer.h
341
zeus/Buffer.h
@ -17,8 +17,10 @@ namespace zeus {
|
|||||||
|
|
||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
|
class BufferData;
|
||||||
//U32 message lenght
|
//U32 message lenght
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
|
/*
|
||||||
struct headerBin {
|
struct headerBin {
|
||||||
//uint16_t versionProtocol; // protocol Version (might be 1)
|
//uint16_t versionProtocol; // protocol Version (might be 1)
|
||||||
uint32_t transactionID;
|
uint32_t transactionID;
|
||||||
@ -27,6 +29,16 @@ namespace zeus {
|
|||||||
uint16_t typeMessage; //TypeMessgae (1:call, 2:Answer, 4:event)
|
uint16_t typeMessage; //TypeMessgae (1:call, 2:Answer, 4:event)
|
||||||
uint16_t numberOfParameter;
|
uint16_t numberOfParameter;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
struct headerBin {
|
||||||
|
//uint16_t versionProtocol; // protocol Version (might be 1)
|
||||||
|
uint32_t transactionID;
|
||||||
|
uint32_t clientID; // same as sevice ID
|
||||||
|
uint8_t flags; // List of flags & type message:
|
||||||
|
// - 0-2: Type of the message
|
||||||
|
// - 3-6: Reserved
|
||||||
|
// - 7: message finished
|
||||||
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
/*
|
/*
|
||||||
// not needed ==> can be deduced with parameter number ... U16 Offset String call Name (start of the buffer) end with \0
|
// not needed ==> can be deduced with parameter number ... U16 Offset String call Name (start of the buffer) end with \0
|
||||||
@ -89,25 +101,36 @@ namespace zeus {
|
|||||||
- vector:string
|
- vector:string
|
||||||
- obj:file
|
- obj:file
|
||||||
*/
|
*/
|
||||||
|
#define ZEUS_BUFFER_FLAG_FINISH (0x80)
|
||||||
|
#define ZEUS_BUFFER_FLAG_TYPE_MESSAGE (0x07)
|
||||||
/**
|
/**
|
||||||
* @brief Protocol buffer to transmit datas
|
* @brief Protocol buffer to transmit datas
|
||||||
*/
|
*/
|
||||||
class Buffer {
|
class Buffer {
|
||||||
friend std::ostream& operator<<(std::ostream&, const zeus::Buffer&);
|
friend std::ostream& operator<<(std::ostream&, zeus::Buffer*);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::Buffer::create
|
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::Buffer::create
|
||||||
*/
|
*/
|
||||||
Buffer();
|
Buffer();
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Virtualize the buffer class
|
||||||
|
*/
|
||||||
|
virtual ~Buffer() = default;
|
||||||
/**
|
/**
|
||||||
* @brief Create a shared pointer on the buffer
|
* @brief Create a shared pointer on the buffer
|
||||||
* @return Allocated Buffer.
|
* @return Allocated Buffer.
|
||||||
*/
|
*/
|
||||||
static ememory::SharedPtr<zeus::Buffer> create();
|
static ememory::SharedPtr<zeus::Buffer> create();
|
||||||
|
/**
|
||||||
|
* @brief Create a shared pointer on the buffer
|
||||||
|
* @param[in] _buffer Buffer on the data
|
||||||
|
* @return Allocated Buffer.
|
||||||
|
*/
|
||||||
|
static ememory::SharedPtr<zeus::Buffer> create(const std::vector<uint8_t>& _buffer);
|
||||||
protected:
|
protected:
|
||||||
headerBin m_header; //!< header of the protocol
|
headerBin m_header; //!< header of the protocol
|
||||||
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...)
|
|
||||||
std::vector<zeus::ActionAsyncClient> m_multipleSend; //!< Async element to send data on the webinterface when too big ...
|
std::vector<zeus::ActionAsyncClient> m_multipleSend; //!< Async element to send data on the webinterface when too big ...
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -128,20 +151,16 @@ namespace zeus {
|
|||||||
* @brief When multiple frame buffer, they need to concatenate the data... call this function with the new data to append it ...
|
* @brief When multiple frame buffer, they need to concatenate the data... call this function with the new data to append it ...
|
||||||
* @param[in] _obj Buffer to add
|
* @param[in] _obj Buffer to add
|
||||||
*/
|
*/
|
||||||
void appendBufferData(const ememory::SharedPtr<zeus::Buffer>& _obj);
|
void appendBuffer(const ememory::SharedPtr<zeus::Buffer>& _obj);
|
||||||
|
virtual void appendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief When receive new data form websocket, it might be added by this input (set all the frame ...)
|
* @brief When receive new data form websocket, it might be added by this input (set all the frame ...)
|
||||||
* @param[in] _buffer Pointer on the data to add.
|
* @param[in] _buffer Pointer on the data to add.
|
||||||
* @param[in] _lenght number of octet to add.
|
* @param[in] _lenght number of octet to add.
|
||||||
*/
|
*/
|
||||||
void internalComposeWith(const uint8_t* _buffer, uint32_t _lenght);
|
virtual void composeWith(const uint8_t* _buffer, uint32_t _lenght);
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* @brief When receive new data form websocket, it might be added by this input.
|
|
||||||
* @param[in] _buffer Buffer on the data
|
|
||||||
*/
|
|
||||||
void composeWith(const std::vector<uint8_t>& _buffer);
|
|
||||||
/**
|
/**
|
||||||
* @brief Chear the buffer
|
* @brief Chear the buffer
|
||||||
*/
|
*/
|
||||||
@ -180,16 +199,6 @@ namespace zeus {
|
|||||||
void setServiceId(uint32_t _value) {
|
void setServiceId(uint32_t _value) {
|
||||||
setClientId(_value);
|
setClientId(_value);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @brief Get the part Id of the buffer
|
|
||||||
* @return Part Identifier
|
|
||||||
*/
|
|
||||||
uint16_t getPartId() const;
|
|
||||||
/**
|
|
||||||
* @brief Set the part Id of the buffer
|
|
||||||
* @param[in] _value New Part ID
|
|
||||||
*/
|
|
||||||
void setPartId(uint16_t _value);
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if it is the last packet of the buffer
|
* @brief Check if it is the last packet of the buffer
|
||||||
* @return If "true" The Buffer wait no more datas
|
* @return If "true" The Buffer wait no more datas
|
||||||
@ -214,63 +223,29 @@ namespace zeus {
|
|||||||
* @brief Get the type of the buffer
|
* @brief Get the type of the buffer
|
||||||
* @return the current type of the buffer
|
* @return the current type of the buffer
|
||||||
*/
|
*/
|
||||||
enum typeMessage getType() const;
|
virtual enum typeMessage getType() const;
|
||||||
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Set the type of the buffer
|
* @brief Write the buffer on a specific interface
|
||||||
* @param[in] _value New type of the buffer
|
* @param[in] _interface socket to write data
|
||||||
|
* @return true of no error appear
|
||||||
*/
|
*/
|
||||||
void setType(enum typeMessage _value);
|
virtual bool writeOn(enet::WebSocket& _interface);
|
||||||
|
virtual size_t getSize();
|
||||||
|
virtual void generateDisplay(std::ostream& _os) const ;
|
||||||
|
};
|
||||||
|
class BufferParameter:
|
||||||
|
public Buffer {
|
||||||
protected:
|
protected:
|
||||||
|
mutable std::vector<std::pair<int32_t,std::vector<uint8_t>>> m_parameter; //!< list of the parameter (offset of start data and buffer of data (subprotocol...)
|
||||||
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Template to get a parameter with a specific type
|
* @brief Template to get a parameter with a specific type
|
||||||
* @param[in] _id Number of the parameter
|
* @param[in] _id Number of the parameter
|
||||||
* @return Converted type of the parameter (or empty value)
|
* @return Converted type of the parameter (or empty value)
|
||||||
*/
|
*/
|
||||||
template<class ZEUS_TYPE_DATA>
|
template<class ZEUS_TYPE_DATA>
|
||||||
ZEUS_TYPE_DATA internalGetParameter(int32_t _id) const;
|
ZEUS_TYPE_DATA getParameter(int32_t _id) const;
|
||||||
/**
|
|
||||||
* @brief Get the type of a parameter.
|
|
||||||
* @param[in] _id Number of the parameter
|
|
||||||
* @return type of the parameter
|
|
||||||
*/
|
|
||||||
zeus::ParamType internalGetParameterType(int32_t _id) const;
|
|
||||||
/**
|
|
||||||
* @brief Get the start pointer of the parameter
|
|
||||||
* @param[in] _id Number of the parameter
|
|
||||||
* @return pointer of the parameter or nullptr
|
|
||||||
*/
|
|
||||||
const uint8_t* internalGetParameterPointer(int32_t _id) const;
|
|
||||||
/**
|
|
||||||
* @brief Get the size of the parameter availlable in the parameter pointer
|
|
||||||
* @param[in] _id Number of the parameter
|
|
||||||
* @return size of the parameter buffer
|
|
||||||
*/
|
|
||||||
uint32_t internalGetParameterSize(int32_t _id) const;
|
|
||||||
/**
|
|
||||||
* @brief Convert the parameter in a simple human readable string
|
|
||||||
* @param[in] _id Number of the parameter
|
|
||||||
* @return readable string
|
|
||||||
*/
|
|
||||||
std::string simpleStringParam(uint32_t _id) const;
|
|
||||||
// ===============================================
|
|
||||||
// == Section call
|
|
||||||
// ===============================================
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief get the call value of the buffer
|
|
||||||
* @return string of the function to call
|
|
||||||
*/
|
|
||||||
std::string getCall() const;
|
|
||||||
/**
|
|
||||||
* @brief Set the call value of the buffer
|
|
||||||
* @param[in] _value Function to call
|
|
||||||
*/
|
|
||||||
void setCall(std::string _value);
|
|
||||||
/**
|
|
||||||
* @brief Get the number of parameter availlable
|
|
||||||
* @return number of parameter
|
|
||||||
*/
|
|
||||||
uint16_t getNumberParameter() const;
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the type of a parameter.
|
* @brief Get the type of a parameter.
|
||||||
* @param[in] _id Number of the parameter
|
* @param[in] _id Number of the parameter
|
||||||
@ -289,24 +264,11 @@ namespace zeus {
|
|||||||
* @return size of the parameter buffer
|
* @return size of the parameter buffer
|
||||||
*/
|
*/
|
||||||
uint32_t getParameterSize(int32_t _id) const;
|
uint32_t getParameterSize(int32_t _id) const;
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
/**
|
||||||
* @brief Add a parameter at a specific position
|
* @brief Get the number of parameter availlable
|
||||||
* @param[in] _paramId Id of the parameter (needed for the multiple packet sending)
|
* @return number of parameter
|
||||||
* @param[in] _value Value to add in parameter
|
|
||||||
*/
|
*/
|
||||||
template<class ZEUS_TYPE_DATA>
|
uint16_t getNumberParameter() const;
|
||||||
void internalAddParameter(uint16_t _paramId, const ZEUS_TYPE_DATA& _value);
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Add a parameter on the call function
|
|
||||||
* @param[in] _value Value to add in parameter
|
|
||||||
*/
|
|
||||||
template<class ZEUS_TYPE_DATA>
|
|
||||||
void addParameter(const ZEUS_TYPE_DATA& _value) {
|
|
||||||
internalAddParameter<ZEUS_TYPE_DATA>(m_parameter.size(), _value);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Add an empty vector with no type
|
* @brief Add an empty vector with no type
|
||||||
*/
|
*/
|
||||||
@ -316,18 +278,101 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
void addParameter();
|
void addParameter();
|
||||||
/**
|
/**
|
||||||
* @brief Template to get a parameter with a specific type
|
* @brief Convert the parameter in a simple human readable string
|
||||||
* @param[in] _id Number of the parameter
|
* @param[in] _id Number of the parameter
|
||||||
* @return Converted type of the parameter (or empty value)
|
* @return readable string
|
||||||
|
*/
|
||||||
|
std::string simpleStringParam(uint32_t _id) const;
|
||||||
|
/**
|
||||||
|
* @brief When receive new data form websocket, it might be added by this input (set all the frame ...)
|
||||||
|
* @param[in] _buffer Pointer on the data to add.
|
||||||
|
* @param[in] _lenght number of octet to add.
|
||||||
|
*/
|
||||||
|
void parameterComposeWith(const uint8_t* _buffer, uint32_t _lenght);
|
||||||
|
bool parameterWriteOn(enet::WebSocket& _interface);
|
||||||
|
size_t parameterGetSize();
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief Add a parameter at a specific position
|
||||||
|
* @param[in] _paramId Id of the parameter (needed for the multiple packet sending)
|
||||||
|
* @param[in] _value Value to add in parameter
|
||||||
*/
|
*/
|
||||||
template<class ZEUS_TYPE_DATA>
|
template<class ZEUS_TYPE_DATA>
|
||||||
ZEUS_TYPE_DATA getParameter(int32_t _id) const {
|
void addParameter(uint16_t _paramId, const ZEUS_TYPE_DATA& _value);
|
||||||
return internalGetParameter<ZEUS_TYPE_DATA>(_id+1);
|
|
||||||
}
|
|
||||||
// ===============================================
|
|
||||||
// == Section Answer
|
|
||||||
// ===============================================
|
|
||||||
public:
|
public:
|
||||||
|
template<class ZEUS_TYPE_DATA>
|
||||||
|
void addParameter(const ZEUS_TYPE_DATA& _value) {
|
||||||
|
addParameter(m_parameter.size(), _value);
|
||||||
|
}
|
||||||
|
void parameterAppendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj);
|
||||||
|
};
|
||||||
|
class BufferCall :
|
||||||
|
public BufferParameter {
|
||||||
|
friend class zeus::Buffer;
|
||||||
|
protected:
|
||||||
|
std::string m_callName;
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferCall::create
|
||||||
|
*/
|
||||||
|
BufferCall() {
|
||||||
|
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::call);
|
||||||
|
};
|
||||||
|
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||||
|
void appendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj) override;
|
||||||
|
bool writeOn(enet::WebSocket& _interface) override;
|
||||||
|
size_t getSize() override;
|
||||||
|
void generateDisplay(std::ostream& _os) const override;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a shared pointer on the BufferCall
|
||||||
|
* @return Allocated Buffer.
|
||||||
|
*/
|
||||||
|
static ememory::SharedPtr<zeus::BufferCall> create();
|
||||||
|
public:
|
||||||
|
enum zeus::Buffer::typeMessage getType() const override {
|
||||||
|
return zeus::Buffer::typeMessage::call;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief get the call value of the buffer
|
||||||
|
* @return string of the function to call
|
||||||
|
*/
|
||||||
|
const std::string& getCall() const;
|
||||||
|
/**
|
||||||
|
* @brief Set the call value of the buffer
|
||||||
|
* @param[in] _value Function to call
|
||||||
|
*/
|
||||||
|
void setCall(const std::string& _value);
|
||||||
|
|
||||||
|
};
|
||||||
|
class BufferAnswer :
|
||||||
|
public BufferParameter {
|
||||||
|
friend class zeus::Buffer;
|
||||||
|
protected:
|
||||||
|
std::string m_errorType;
|
||||||
|
std::string m_errorHelp;
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferAnswer::create
|
||||||
|
*/
|
||||||
|
BufferAnswer() {
|
||||||
|
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::answer);
|
||||||
|
};
|
||||||
|
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||||
|
void appendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj) override;
|
||||||
|
bool writeOn(enet::WebSocket& _interface) override;
|
||||||
|
size_t getSize() override;
|
||||||
|
void generateDisplay(std::ostream& _os) const override;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a shared pointer on the BufferAnswer
|
||||||
|
* @return Allocated Buffer.
|
||||||
|
*/
|
||||||
|
static ememory::SharedPtr<zeus::BufferAnswer> create();
|
||||||
|
public:
|
||||||
|
enum zeus::Buffer::typeMessage getType() const override {
|
||||||
|
return zeus::Buffer::typeMessage::answer;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief set the answer of the call
|
* @brief set the answer of the call
|
||||||
* @param[in] _value Value to add
|
* @param[in] _value Value to add
|
||||||
@ -343,7 +388,7 @@ namespace zeus {
|
|||||||
// TODO : Do it better check error ... ==> can be good ...
|
// TODO : Do it better check error ... ==> can be good ...
|
||||||
template<class ZEUS_TYPE_DATA>
|
template<class ZEUS_TYPE_DATA>
|
||||||
ZEUS_TYPE_DATA getAnswer() const {
|
ZEUS_TYPE_DATA getAnswer() const {
|
||||||
return internalGetParameter<ZEUS_TYPE_DATA>(0);
|
return getParameter<ZEUS_TYPE_DATA>(0);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Ann an error on the message answer
|
* @brief Ann an error on the message answer
|
||||||
@ -360,14 +405,60 @@ namespace zeus {
|
|||||||
* @brief get the error value (if exist)
|
* @brief get the error value (if exist)
|
||||||
* @return string of the error
|
* @return string of the error
|
||||||
*/
|
*/
|
||||||
std::string getError();
|
const std::string& getError();
|
||||||
/**
|
/**
|
||||||
* @brief get the error help (if exist)
|
* @brief get the error help (if exist)
|
||||||
* @return string of the error help
|
* @return string of the error help
|
||||||
*/
|
*/
|
||||||
std::string getErrorHelp();
|
const std::string& getErrorHelp();
|
||||||
|
};
|
||||||
|
class BufferData:
|
||||||
|
public Buffer {
|
||||||
|
friend class zeus::Buffer;
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
BufferData():
|
||||||
|
m_partId(0) {
|
||||||
|
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::data);
|
||||||
|
};
|
||||||
|
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||||
|
// TODO :... void appendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj) override;
|
||||||
|
bool writeOn(enet::WebSocket& _interface) override;
|
||||||
|
size_t getSize() override;
|
||||||
|
void generateDisplay(std::ostream& _os) const override;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a shared pointer on the BufferData
|
||||||
|
* @return Allocated Buffer.
|
||||||
|
*/
|
||||||
|
static ememory::SharedPtr<zeus::BufferData> create();
|
||||||
|
public:
|
||||||
|
enum zeus::Buffer::typeMessage getType() const override {
|
||||||
|
return zeus::Buffer::typeMessage::data;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the parameter Id of the buffer
|
||||||
|
* @return Part Identifier
|
||||||
|
*/
|
||||||
|
uint16_t getParameterId() const {
|
||||||
|
return m_parameterId;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the part Id of the buffer
|
||||||
|
* @return Part Identifier
|
||||||
|
*/
|
||||||
|
uint32_t getPartId() const;
|
||||||
|
/**
|
||||||
|
* @brief Set the part Id of the buffer
|
||||||
|
* @param[in] _value New Part ID
|
||||||
|
*/
|
||||||
|
void setPartId(uint32_t _value);
|
||||||
/**
|
/**
|
||||||
* @brief add a raw data on the buffer
|
* @brief add a raw data on the buffer
|
||||||
* @param[in] _parameterId Parameter id of the destination of the data
|
* @param[in] _parameterId Parameter id of the destination of the data
|
||||||
@ -376,12 +467,62 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
void addData(uint16_t _parameterId, void* _data, uint32_t _size);
|
void addData(uint16_t _parameterId, void* _data, uint32_t _size);
|
||||||
/**
|
/**
|
||||||
* @brief Write the buffer on a specific interface
|
* @brief Get data reference
|
||||||
* @param[in] _interface socket to write data
|
|
||||||
* @return true of no error appear
|
|
||||||
*/
|
*/
|
||||||
bool writeOn(enet::WebSocket& _interface);
|
const std::vector<uint8_t>& getData() const {
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
|
class BufferEvent :
|
||||||
|
public BufferParameter {
|
||||||
|
friend class zeus::Buffer;
|
||||||
|
protected:
|
||||||
|
/ **
|
||||||
|
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferEvent::create
|
||||||
|
* /
|
||||||
|
BufferEvent() {
|
||||||
|
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::event);
|
||||||
|
};
|
||||||
|
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||||
|
void appendBufferData(const ememory::SharedPtr<zeus::BufferData>& _obj) override;
|
||||||
|
public:
|
||||||
|
/ **
|
||||||
|
* @brief Create a shared pointer on the BufferEvent
|
||||||
|
* @return Allocated Buffer.
|
||||||
|
* /
|
||||||
|
static ememory::SharedPtr<zeus::BufferEvent> create();
|
||||||
|
public:
|
||||||
|
enum zeus::Buffer::typeMessage getType() const override {
|
||||||
|
return zeus::Buffer::typeMessage::event;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
class BufferFlow:
|
||||||
|
public Buffer {
|
||||||
|
friend class zeus::Buffer;
|
||||||
|
protected:
|
||||||
|
/ **
|
||||||
|
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferFlow::create
|
||||||
|
* /
|
||||||
|
BufferFlow() {
|
||||||
|
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::flow);
|
||||||
|
};
|
||||||
|
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||||
|
public:
|
||||||
|
/ **
|
||||||
|
* @brief Create a shared pointer on the BufferFlow
|
||||||
|
* @return Allocated Buffer.
|
||||||
|
* /
|
||||||
|
static ememory::SharedPtr<zeus::BufferFlow> create();
|
||||||
|
public:
|
||||||
|
enum zeus::Buffer::typeMessage getType() const override {
|
||||||
|
return zeus::Buffer::typeMessage::flow;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief generate a display of the typemessage
|
* @brief generate a display of the typemessage
|
||||||
* @param[in] _os stream to add data
|
* @param[in] _os stream to add data
|
||||||
@ -395,7 +536,7 @@ namespace zeus {
|
|||||||
* @value[in] _obj Buffer to display
|
* @value[in] _obj Buffer to display
|
||||||
* @return a reference of the stream
|
* @return a reference of the stream
|
||||||
*/
|
*/
|
||||||
std::ostream& operator <<(std::ostream& _os, const zeus::Buffer& _obj);
|
std::ostream& operator <<(std::ostream& _os, zeus::Buffer* _obj);
|
||||||
|
|
||||||
// internal:
|
// internal:
|
||||||
/**
|
/**
|
||||||
|
@ -35,12 +35,12 @@ void zeus::addTypeRaw(std::vector<uint8_t>& _data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void zeus::Buffer::addParameter() {
|
void zeus::BufferParameter::addParameter() {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<void>());
|
addType(data, createType<void>());
|
||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
void zeus::Buffer::addParameterEmptyVector() {
|
void zeus::BufferParameter::addParameterEmptyVector() {
|
||||||
// special case of json change mode
|
// special case of json change mode
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<void>>());
|
addType(data, createType<std::vector<void>>());
|
||||||
@ -48,7 +48,7 @@ void zeus::Buffer::addParameterEmptyVector() {
|
|||||||
}
|
}
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::string>(uint16_t _paramId, const std::string& _value) {
|
void BufferParameter::addParameter<std::string>(uint16_t _paramId, const std::string& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::string>());
|
addType(data, createType<std::string>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -57,7 +57,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<std::string>>(uint16_t _paramId, const std::vector<std::string>& _value) {
|
void BufferParameter::addParameter<std::vector<std::string>>(uint16_t _paramId, const std::vector<std::string>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<std::string>>());
|
addType(data, createType<std::vector<std::string>>());
|
||||||
// count all datas:
|
// count all datas:
|
||||||
@ -80,7 +80,7 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<bool>>(uint16_t _paramId, const std::vector<bool>& _value) {
|
void BufferParameter::addParameter<std::vector<bool>>(uint16_t _paramId, const std::vector<bool>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<bool>>());
|
addType(data, createType<std::vector<bool>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -99,7 +99,7 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<int8_t>>(uint16_t _paramId, const std::vector<int8_t>& _value) {
|
void BufferParameter::addParameter<std::vector<int8_t>>(uint16_t _paramId, const std::vector<int8_t>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<int8_t>>());
|
addType(data, createType<std::vector<int8_t>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -109,7 +109,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<int16_t>>(uint16_t _paramId, const std::vector<int16_t>& _value) {
|
void BufferParameter::addParameter<std::vector<int16_t>>(uint16_t _paramId, const std::vector<int16_t>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<int16_t>>());
|
addType(data, createType<std::vector<int16_t>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -119,7 +119,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<int32_t>>(uint16_t _paramId, const std::vector<int32_t>& _value) {
|
void BufferParameter::addParameter<std::vector<int32_t>>(uint16_t _paramId, const std::vector<int32_t>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<int32_t>>());
|
addType(data, createType<std::vector<int32_t>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -129,7 +129,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<int64_t>>(uint16_t _paramId, const std::vector<int64_t>& _value) {
|
void BufferParameter::addParameter<std::vector<int64_t>>(uint16_t _paramId, const std::vector<int64_t>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<int64_t>>());
|
addType(data, createType<std::vector<int64_t>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -139,7 +139,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<uint8_t>>(uint16_t _paramId, const std::vector<uint8_t>& _value) {
|
void BufferParameter::addParameter<std::vector<uint8_t>>(uint16_t _paramId, const std::vector<uint8_t>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<uint8_t>>());
|
addType(data, createType<std::vector<uint8_t>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -149,7 +149,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<uint16_t>>(uint16_t _paramId, const std::vector<uint16_t>& _value) {
|
void BufferParameter::addParameter<std::vector<uint16_t>>(uint16_t _paramId, const std::vector<uint16_t>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<uint16_t>>());
|
addType(data, createType<std::vector<uint16_t>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -159,7 +159,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<uint32_t>>(uint16_t _paramId, const std::vector<uint32_t>& _value) {
|
void BufferParameter::addParameter<std::vector<uint32_t>>(uint16_t _paramId, const std::vector<uint32_t>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<uint32_t>>());
|
addType(data, createType<std::vector<uint32_t>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -169,7 +169,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<uint64_t>>(uint16_t _paramId, const std::vector<uint64_t>& _value) {
|
void BufferParameter::addParameter<std::vector<uint64_t>>(uint16_t _paramId, const std::vector<uint64_t>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<uint64_t>>());
|
addType(data, createType<std::vector<uint64_t>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -180,7 +180,7 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<float>>(uint16_t _paramId, const std::vector<float>& _value) {
|
void BufferParameter::addParameter<std::vector<float>>(uint16_t _paramId, const std::vector<float>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<float>>());
|
addType(data, createType<std::vector<float>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -191,7 +191,7 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<std::vector<double>>(uint16_t _paramId, const std::vector<double>& _value) {
|
void BufferParameter::addParameter<std::vector<double>>(uint16_t _paramId, const std::vector<double>& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<std::vector<double>>());
|
addType(data, createType<std::vector<double>>());
|
||||||
// add size:
|
// add size:
|
||||||
@ -202,21 +202,21 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<int8_t>(uint16_t _paramId, const int8_t& _value) {
|
void BufferParameter::addParameter<int8_t>(uint16_t _paramId, const int8_t& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<int8_t>());
|
addType(data, createType<int8_t>());
|
||||||
data.push_back(uint8_t(_value));
|
data.push_back(uint8_t(_value));
|
||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<uint8_t>(uint16_t _paramId, const uint8_t& _value) {
|
void BufferParameter::addParameter<uint8_t>(uint16_t _paramId, const uint8_t& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<uint8_t>());
|
addType(data, createType<uint8_t>());
|
||||||
data.push_back(_value);
|
data.push_back(_value);
|
||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<int16_t>(uint16_t _paramId, const int16_t& _value) {
|
void BufferParameter::addParameter<int16_t>(uint16_t _paramId, const int16_t& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<int16_t>());
|
addType(data, createType<int16_t>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -225,7 +225,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<uint16_t>(uint16_t _paramId, const uint16_t& _value) {
|
void BufferParameter::addParameter<uint16_t>(uint16_t _paramId, const uint16_t& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<uint16_t>());
|
addType(data, createType<uint16_t>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -234,7 +234,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<int32_t>(uint16_t _paramId, const int32_t& _value) {
|
void BufferParameter::addParameter<int32_t>(uint16_t _paramId, const int32_t& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<int32_t>());
|
addType(data, createType<int32_t>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -243,7 +243,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<uint32_t>(uint16_t _paramId, const uint32_t& _value) {
|
void BufferParameter::addParameter<uint32_t>(uint16_t _paramId, const uint32_t& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<uint32_t>());
|
addType(data, createType<uint32_t>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -252,7 +252,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<int64_t>(uint16_t _paramId, const int64_t& _value) {
|
void BufferParameter::addParameter<int64_t>(uint16_t _paramId, const int64_t& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<int64_t>());
|
addType(data, createType<int64_t>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -261,7 +261,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<uint64_t>(uint16_t _paramId, const uint64_t& _value) {
|
void BufferParameter::addParameter<uint64_t>(uint16_t _paramId, const uint64_t& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<uint64_t>());
|
addType(data, createType<uint64_t>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -270,7 +270,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<float>(uint16_t _paramId, const float& _value) {
|
void BufferParameter::addParameter<float>(uint16_t _paramId, const float& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<float>());
|
addType(data, createType<float>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -279,7 +279,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<double>(uint16_t _paramId, const double& _value) {
|
void BufferParameter::addParameter<double>(uint16_t _paramId, const double& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<double>());
|
addType(data, createType<double>());
|
||||||
int32_t currentOffset = data.size();
|
int32_t currentOffset = data.size();
|
||||||
@ -288,7 +288,7 @@ namespace zeus {
|
|||||||
m_parameter.push_back(std::make_pair(2,data));
|
m_parameter.push_back(std::make_pair(2,data));
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<bool>(uint16_t _paramId, const bool& _value) {
|
void BufferParameter::addParameter<bool>(uint16_t _paramId, const bool& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<bool>());
|
addType(data, createType<bool>());
|
||||||
if (_value == true) {
|
if (_value == true) {
|
||||||
@ -321,10 +321,9 @@ namespace zeus {
|
|||||||
uint32_t _clientId,
|
uint32_t _clientId,
|
||||||
uint32_t _transactionId,
|
uint32_t _transactionId,
|
||||||
uint32_t _partId) {
|
uint32_t _partId) {
|
||||||
ememory::SharedPtr<zeus::Buffer> answer = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferData> answer = zeus::BufferData::create();
|
||||||
answer->setTransactionId(_transactionId);
|
answer->setTransactionId(_transactionId);
|
||||||
answer->setClientId(_clientId);
|
answer->setClientId(_clientId);
|
||||||
answer->setType(zeus::Buffer::typeMessage::data);
|
|
||||||
answer->setPartId(_partId);
|
answer->setPartId(_partId);
|
||||||
answer->setPartFinish(false);
|
answer->setPartFinish(false);
|
||||||
int32_t tmpSize = ZEUS_MINIMUM_SIZE_MULTIPLE;
|
int32_t tmpSize = ZEUS_MINIMUM_SIZE_MULTIPLE;
|
||||||
@ -342,7 +341,7 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<zeus::File>(uint16_t _paramId, const zeus::File& _value) {
|
void BufferParameter::addParameter<zeus::File>(uint16_t _paramId, const zeus::File& _value) {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
addType(data, createType<zeus::File>());
|
addType(data, createType<zeus::File>());
|
||||||
// set mine type in string:
|
// set mine type in string:
|
||||||
@ -393,10 +392,9 @@ namespace zeus {
|
|||||||
if (m_node.fileIsOpen() == false) {
|
if (m_node.fileIsOpen() == false) {
|
||||||
m_node.fileOpenRead();
|
m_node.fileOpenRead();
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<zeus::Buffer> answer = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferData> answer = zeus::BufferData::create();
|
||||||
answer->setTransactionId(_transactionId);
|
answer->setTransactionId(_transactionId);
|
||||||
answer->setClientId(_clientId);
|
answer->setClientId(_clientId);
|
||||||
answer->setType(zeus::Buffer::typeMessage::data);
|
|
||||||
answer->setPartId(_partId);
|
answer->setPartId(_partId);
|
||||||
answer->setPartFinish(false);
|
answer->setPartFinish(false);
|
||||||
int32_t tmpSize = ZEUS_MINIMUM_SIZE_MULTIPLE;
|
int32_t tmpSize = ZEUS_MINIMUM_SIZE_MULTIPLE;
|
||||||
@ -417,7 +415,7 @@ namespace zeus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void Buffer::internalAddParameter<zeus::FileServer>(uint16_t _paramId, const zeus::FileServer& _value) {
|
void BufferParameter::addParameter<zeus::FileServer>(uint16_t _paramId, const zeus::FileServer& _value) {
|
||||||
etk::FSNode node(_value.getFileName());
|
etk::FSNode node(_value.getFileName());
|
||||||
node.fileOpenRead();
|
node.fileOpenRead();
|
||||||
std::string extention = std::string(_value.getFileName().begin()+_value.getFileName().size() -3, _value.getFileName().end());
|
std::string extention = std::string(_value.getFileName().begin()+_value.getFileName().size() -3, _value.getFileName().end());
|
||||||
@ -430,7 +428,7 @@ namespace zeus {
|
|||||||
node.fileRead(&fileData[0], 1, size);
|
node.fileRead(&fileData[0], 1, size);
|
||||||
}
|
}
|
||||||
zeus::File tmpFile(zeus::getMineType(extention), fileData, size);
|
zeus::File tmpFile(zeus::getMineType(extention), fileData, size);
|
||||||
internalAddParameter(_paramId, tmpFile);
|
addParameter(_paramId, tmpFile);
|
||||||
node.fileClose();
|
node.fileClose();
|
||||||
if (size >= ZEUS_MINIMUM_SIZE_MULTIPLE) {
|
if (size >= ZEUS_MINIMUM_SIZE_MULTIPLE) {
|
||||||
m_multipleSend.push_back(zeus::SendFile(_value.getFileName(), _paramId, size));
|
m_multipleSend.push_back(zeus::SendFile(_value.getFileName(), _paramId, size));
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
#include <climits>
|
#include <climits>
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
template<>
|
template<>
|
||||||
bool Buffer::internalGetParameter<bool>(int32_t _id) const {
|
bool BufferParameter::getParameter<bool>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
if (createType<bool>() != type) {
|
if (createType<bool>() != type) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -29,11 +29,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::string Buffer::internalGetParameter<std::string>(int32_t _id) const {
|
std::string BufferParameter::getParameter<std::string>(int32_t _id) const {
|
||||||
std::string out;
|
std::string out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
out.resize(dataSize, 0);
|
out.resize(dataSize, 0);
|
||||||
memcpy(&out[0], pointer, out.size());
|
memcpy(&out[0], pointer, out.size());
|
||||||
return out;
|
return out;
|
||||||
@ -41,10 +41,10 @@ namespace zeus {
|
|||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
uint8_t Buffer::internalGetParameter<uint8_t>(int32_t _id) const {
|
uint8_t BufferParameter::getParameter<uint8_t>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -81,10 +81,10 @@ namespace zeus {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
uint16_t Buffer::internalGetParameter<uint16_t>(int32_t _id) const {
|
uint16_t BufferParameter::getParameter<uint16_t>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -122,10 +122,10 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
uint32_t Buffer::internalGetParameter<uint32_t>(int32_t _id) const {
|
uint32_t BufferParameter::getParameter<uint32_t>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -163,10 +163,10 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
uint64_t Buffer::internalGetParameter<uint64_t>(int32_t _id) const {
|
uint64_t BufferParameter::getParameter<uint64_t>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -204,10 +204,10 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
int8_t Buffer::internalGetParameter<int8_t>(int32_t _id) const {
|
int8_t BufferParameter::getParameter<int8_t>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -245,10 +245,10 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
int16_t Buffer::internalGetParameter<int16_t>(int32_t _id) const {
|
int16_t BufferParameter::getParameter<int16_t>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -286,10 +286,10 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
int32_t Buffer::internalGetParameter<int32_t>(int32_t _id) const {
|
int32_t BufferParameter::getParameter<int32_t>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -327,10 +327,10 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
int64_t Buffer::internalGetParameter<int64_t>(int32_t _id) const {
|
int64_t BufferParameter::getParameter<int64_t>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -368,10 +368,10 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
float Buffer::internalGetParameter<float>(int32_t _id) const {
|
float BufferParameter::getParameter<float>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -408,10 +408,10 @@ namespace zeus {
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
double Buffer::internalGetParameter<double>(int32_t _id) const {
|
double BufferParameter::getParameter<double>(int32_t _id) const {
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<uint8_t>() == type) {
|
if (createType<uint8_t>() == type) {
|
||||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||||
@ -472,11 +472,11 @@ namespace zeus {
|
|||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<uint8_t> Buffer::internalGetParameter<std::vector<uint8_t>>(int32_t _id) const {
|
std::vector<uint8_t> BufferParameter::getParameter<std::vector<uint8_t>>(int32_t _id) const {
|
||||||
std::vector<uint8_t> out;
|
std::vector<uint8_t> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -562,11 +562,11 @@ namespace zeus {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
std::vector<uint16_t> Buffer::internalGetParameter<std::vector<uint16_t>>(int32_t _id) const {
|
std::vector<uint16_t> BufferParameter::getParameter<std::vector<uint16_t>>(int32_t _id) const {
|
||||||
std::vector<uint16_t> out;
|
std::vector<uint16_t> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -653,11 +653,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<uint32_t> Buffer::internalGetParameter<std::vector<uint32_t>>(int32_t _id) const {
|
std::vector<uint32_t> BufferParameter::getParameter<std::vector<uint32_t>>(int32_t _id) const {
|
||||||
std::vector<uint32_t> out;
|
std::vector<uint32_t> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -744,11 +744,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<uint64_t> Buffer::internalGetParameter<std::vector<uint64_t>>(int32_t _id) const {
|
std::vector<uint64_t> BufferParameter::getParameter<std::vector<uint64_t>>(int32_t _id) const {
|
||||||
std::vector<uint64_t> out;
|
std::vector<uint64_t> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -835,11 +835,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<int8_t> Buffer::internalGetParameter<std::vector<int8_t>>(int32_t _id) const {
|
std::vector<int8_t> BufferParameter::getParameter<std::vector<int8_t>>(int32_t _id) const {
|
||||||
std::vector<int8_t> out;
|
std::vector<int8_t> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -926,11 +926,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<int16_t> Buffer::internalGetParameter<std::vector<int16_t>>(int32_t _id) const {
|
std::vector<int16_t> BufferParameter::getParameter<std::vector<int16_t>>(int32_t _id) const {
|
||||||
std::vector<int16_t> out;
|
std::vector<int16_t> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -1017,11 +1017,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<int32_t> Buffer::internalGetParameter<std::vector<int32_t>>(int32_t _id) const {
|
std::vector<int32_t> BufferParameter::getParameter<std::vector<int32_t>>(int32_t _id) const {
|
||||||
std::vector<int32_t> out;
|
std::vector<int32_t> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -1108,11 +1108,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<int64_t> Buffer::internalGetParameter<std::vector<int64_t>>(int32_t _id) const {
|
std::vector<int64_t> BufferParameter::getParameter<std::vector<int64_t>>(int32_t _id) const {
|
||||||
std::vector<int64_t> out;
|
std::vector<int64_t> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -1199,11 +1199,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<float> Buffer::internalGetParameter<std::vector<float>>(int32_t _id) const {
|
std::vector<float> BufferParameter::getParameter<std::vector<float>>(int32_t _id) const {
|
||||||
std::vector<float> out;
|
std::vector<float> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -1290,11 +1290,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<double> Buffer::internalGetParameter<std::vector<double>>(int32_t _id) const {
|
std::vector<double> BufferParameter::getParameter<std::vector<double>>(int32_t _id) const {
|
||||||
std::vector<double> out;
|
std::vector<double> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -1381,11 +1381,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<bool> Buffer::internalGetParameter<std::vector<bool>>(int32_t _id) const {
|
std::vector<bool> BufferParameter::getParameter<std::vector<bool>>(int32_t _id) const {
|
||||||
std::vector<bool> out;
|
std::vector<bool> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
@ -1403,11 +1403,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
std::vector<std::string> Buffer::internalGetParameter<std::vector<std::string>>(int32_t _id) const {
|
std::vector<std::string> BufferParameter::getParameter<std::vector<std::string>>(int32_t _id) const {
|
||||||
std::vector<std::string> out;
|
std::vector<std::string> out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
if (type == createType<std::vector<void>>()) {
|
if (type == createType<std::vector<void>>()) {
|
||||||
return out;
|
return out;
|
||||||
} else if (createType<std::vector<std::string>>() == type) {
|
} else if (createType<std::vector<std::string>>() == type) {
|
||||||
@ -1428,11 +1428,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
zeus::File Buffer::internalGetParameter<zeus::File>(int32_t _id) const {
|
zeus::File BufferParameter::getParameter<zeus::File>(int32_t _id) const {
|
||||||
zeus::File out;
|
zeus::File out;
|
||||||
zeus::ParamType type = internalGetParameterType(_id);
|
zeus::ParamType type = getParameterType(_id);
|
||||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
const uint8_t* pointer = getParameterPointer(_id);
|
||||||
uint32_t dataSize = internalGetParameterSize(_id);
|
uint32_t dataSize = getParameterSize(_id);
|
||||||
// TODO : Check size ...
|
// TODO : Check size ...
|
||||||
if (createType<zeus::File>() == type) {
|
if (createType<zeus::File>() == type) {
|
||||||
// get mine type in string:
|
// get mine type in string:
|
||||||
|
@ -24,7 +24,7 @@ void zeus::Client::onClientData(const ememory::SharedPtr<zeus::Buffer>& _value)
|
|||||||
if (_value == nullptr) {
|
if (_value == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ZEUS_ERROR("Get Data On the Communication interface that is not understand ... : " << *_value);
|
ZEUS_ERROR("Get Data On the Communication interface that is not understand ... : " << _value);
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::ServiceRemote zeus::Client::getService(const std::string& _name) {
|
zeus::ServiceRemote zeus::Client::getService(const std::string& _name) {
|
||||||
|
@ -104,7 +104,7 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||||
if (m_interfaceClient == nullptr) {
|
if (m_interfaceClient == nullptr) {
|
||||||
ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
||||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||||
return zeus::FutureBase(0, ret);
|
return zeus::FutureBase(0, ret);
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||||
if (m_interfaceClient == nullptr) {
|
if (m_interfaceClient == nullptr) {
|
||||||
ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
||||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||||
return zeus::FutureBase(0, ret, _callback);
|
return zeus::FutureBase(0, ret, _callback);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<bool>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<bool>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
int64_t zeus::Future<int64_t>::get() {
|
int64_t zeus::Future<int64_t>::get() {
|
||||||
@ -31,7 +31,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<bool>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<bool>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
int32_t zeus::Future<int32_t>::get() {
|
int32_t zeus::Future<int32_t>::get() {
|
||||||
@ -43,7 +43,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<int32_t>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<int32_t>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
int16_t zeus::Future<int16_t>::get() {
|
int16_t zeus::Future<int16_t>::get() {
|
||||||
@ -55,7 +55,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<int16_t>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<int16_t>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
int8_t zeus::Future<int8_t>::get() {
|
int8_t zeus::Future<int8_t>::get() {
|
||||||
@ -67,7 +67,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<int8_t>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<int8_t>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
uint64_t zeus::Future<uint64_t>::get() {
|
uint64_t zeus::Future<uint64_t>::get() {
|
||||||
@ -79,7 +79,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<int64_t>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<int64_t>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
uint32_t zeus::Future<uint32_t>::get() {
|
uint32_t zeus::Future<uint32_t>::get() {
|
||||||
@ -91,7 +91,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<uint32_t>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<uint32_t>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
uint16_t zeus::Future<uint16_t>::get() {
|
uint16_t zeus::Future<uint16_t>::get() {
|
||||||
@ -103,7 +103,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<uint16_t>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<uint16_t>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
uint8_t zeus::Future<uint8_t>::get() {
|
uint8_t zeus::Future<uint8_t>::get() {
|
||||||
@ -115,7 +115,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<uint8_t>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<uint8_t>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
double zeus::Future<double>::get() {
|
double zeus::Future<double>::get() {
|
||||||
@ -127,7 +127,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<double>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<double>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
float zeus::Future<float>::get() {
|
float zeus::Future<float>::get() {
|
||||||
@ -139,7 +139,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<float>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<float>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
std::string zeus::Future<std::string>::get() {
|
std::string zeus::Future<std::string>::get() {
|
||||||
@ -151,7 +151,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getAnswer<std::string>();
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::string>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
std::vector<int64_t> zeus::Future<std::vector<int64_t>>::get() {
|
std::vector<int64_t> zeus::Future<std::vector<int64_t>>::get() {
|
||||||
@ -164,7 +164,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<int64_t>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<int64_t>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -178,7 +178,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<int32_t>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<int32_t>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -192,7 +192,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<int16_t>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<int16_t>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -206,7 +206,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<int8_t>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<int8_t>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -220,7 +220,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<uint64_t>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<uint64_t>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -234,7 +234,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<uint32_t>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<uint32_t>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -248,7 +248,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<uint16_t>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<uint16_t>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -262,7 +262,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<uint8_t>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<uint8_t>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -276,7 +276,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<double>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<double>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -290,7 +290,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<float>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<float>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -304,7 +304,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<std::string>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<std::string>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -318,7 +318,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<std::vector<bool>>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<std::vector<bool>>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
@ -332,7 +332,7 @@ namespace zeus {
|
|||||||
ZEUS_WARNING("No Return value ...");
|
ZEUS_WARNING("No Return value ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out = m_data->m_returnData->getAnswer<zeus::File>();
|
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<zeus::File>();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ bool zeus::FutureBase::appendData(const ememory::SharedPtr<zeus::Buffer>& _value
|
|||||||
}
|
}
|
||||||
if (_value->getType() == zeus::Buffer::typeMessage::data) {
|
if (_value->getType() == zeus::Buffer::typeMessage::data) {
|
||||||
if (m_data->m_returnData != nullptr) {
|
if (m_data->m_returnData != nullptr) {
|
||||||
m_data->m_returnData->appendBufferData(_value);
|
m_data->m_returnData->appendBuffer(_value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_data->m_returnData = _value;
|
m_data->m_returnData = _value;
|
||||||
@ -120,10 +120,14 @@ uint32_t zeus::FutureBase::getClientId() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool zeus::FutureBase::hasError() const {
|
bool zeus::FutureBase::hasError() const {
|
||||||
if (m_data == nullptr) {
|
if ( m_data == nullptr
|
||||||
|
|| m_data->m_returnData == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->hasError();
|
if (m_data->m_returnData->getType() == zeus::Buffer::typeMessage::answer) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->hasError();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string zeus::FutureBase::getErrorType() const {
|
std::string zeus::FutureBase::getErrorType() const {
|
||||||
@ -131,15 +135,21 @@ std::string zeus::FutureBase::getErrorType() const {
|
|||||||
|| m_data->m_returnData == nullptr) {
|
|| m_data->m_returnData == nullptr) {
|
||||||
return "NULL_PTR";
|
return "NULL_PTR";
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getError();
|
if (m_data->m_returnData->getType() == zeus::Buffer::typeMessage::answer) {
|
||||||
|
return "NOT_ANSWER_MESSAGE";
|
||||||
|
}
|
||||||
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getError();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string zeus::FutureBase::getErrorHelp() const {
|
std::string zeus::FutureBase::getErrorHelp() const {
|
||||||
if ( m_data == nullptr
|
if ( m_data == nullptr
|
||||||
|| m_data->m_returnData == nullptr) {
|
|| m_data->m_returnData == nullptr) {
|
||||||
return "Thsi is a nullptr future";
|
return "This is a nullptr future";
|
||||||
}
|
}
|
||||||
return m_data->m_returnData->getErrorHelp();
|
if (m_data->m_returnData->getType() == zeus::Buffer::typeMessage::answer) {
|
||||||
|
return "This answer is not a anwser type";
|
||||||
|
}
|
||||||
|
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getErrorHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zeus::FutureBase::isValid() const {
|
bool zeus::FutureBase::isValid() const {
|
||||||
|
@ -133,26 +133,28 @@ void zeus::Service::callBinary(const ememory::SharedPtr<zeus::Buffer>& _obj) {
|
|||||||
ZEUS_ERROR("Local Answer: '...'");
|
ZEUS_ERROR("Local Answer: '...'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if (_obj.getType() == zeus::Buffer::typeMessage::event) {
|
if (_obj->getType() == zeus::Buffer::typeMessage::call) {
|
||||||
uint32_t clientId = _obj->getClientId();
|
ememory::SharedPtr<zeus::BufferCall> callObj = std::static_pointer_cast<zeus::BufferCall>(_obj);
|
||||||
std::string callFunction = _obj->getCall();
|
uint32_t clientId = callObj->getClientId();
|
||||||
if (callFunction[0] == '_') {
|
std::string callFunction = callObj->getCall();
|
||||||
if (callFunction == "_new") {
|
if (callFunction[0] == '_') {
|
||||||
std::string userName = _obj->getParameter<std::string>(0);
|
if (callFunction == "_new") {
|
||||||
std::string clientName = _obj->getParameter<std::string>(1);
|
std::string userName = callObj->getParameter<std::string>(0);
|
||||||
std::vector<std::string> clientGroup = _obj->getParameter<std::vector<std::string>>(2);
|
std::string clientName = callObj->getParameter<std::string>(1);
|
||||||
clientConnect(clientId, userName, clientName, clientGroup);
|
std::vector<std::string> clientGroup = callObj->getParameter<std::vector<std::string>>(2);
|
||||||
} else if (callFunction == "_delete") {
|
clientConnect(clientId, userName, clientName, clientGroup);
|
||||||
clientDisconnect(clientId);
|
} else if (callFunction == "_delete") {
|
||||||
|
clientDisconnect(clientId);
|
||||||
|
}
|
||||||
|
m_interfaceClient->answerValue(callObj->getTransactionId(), true, clientId);
|
||||||
|
return;
|
||||||
|
} else if (isFunctionAuthorized(clientId, callFunction) == true) {
|
||||||
|
callBinary2(callFunction, callObj);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
m_interfaceClient->answerError(callObj->getTransactionId(), "NOT-AUTHORIZED-FUNCTION", "", clientId);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
m_interfaceClient->answerValue(_obj->getTransactionId(), true, clientId);
|
|
||||||
return;
|
|
||||||
} else if (isFunctionAuthorized(clientId, callFunction) == true) {
|
|
||||||
callBinary2(callFunction, _obj);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
m_interfaceClient->answerError(_obj->getTransactionId(), "NOT-AUTHORIZED-FUNCTION", "", clientId);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||||
if (m_interfaceClient == nullptr) {
|
if (m_interfaceClient == nullptr) {
|
||||||
ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
||||||
if (ret != nullptr) {
|
if (ret != nullptr) {
|
||||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||||
if (m_interfaceClient == nullptr) {
|
if (m_interfaceClient == nullptr) {
|
||||||
ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
||||||
if (ret != nullptr) {
|
if (ret != nullptr) {
|
||||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
ememory::SharedPtr<zeus::Buffer> zeus::createBaseCall(uint64_t _transactionId, const std::string& _functionName, const uint32_t& _serviceId) {
|
ememory::SharedPtr<zeus::BufferCall> zeus::createBaseCall(uint64_t _transactionId, const std::string& _functionName, const uint32_t& _serviceId) {
|
||||||
ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferCall> obj = zeus::BufferCall::create();
|
||||||
if (obj == nullptr) {
|
if (obj == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ ememory::SharedPtr<zeus::Buffer> zeus::createBaseCall(uint64_t _transactionId, c
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::createParam(int32_t _paramId, const ememory::SharedPtr<zeus::Buffer>& _obj) {
|
void zeus::createParam(int32_t _paramId, const ememory::SharedPtr<zeus::BufferCall>& _obj) {
|
||||||
// Finish recursive parse ...
|
// Finish recursive parse ...
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,11 +135,10 @@ class SendAsyncBinary {
|
|||||||
m_partId++;
|
m_partId++;
|
||||||
}
|
}
|
||||||
if (m_async.size() == 0) {
|
if (m_async.size() == 0) {
|
||||||
ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferData> obj = zeus::BufferData::create();
|
||||||
if (obj == nullptr) {
|
if (obj == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
obj->setType(zeus::Buffer::typeMessage::data);
|
|
||||||
obj->setServiceId(m_serviceId);
|
obj->setServiceId(m_serviceId);
|
||||||
obj->setTransactionId(m_transactionId);
|
obj->setTransactionId(m_transactionId);
|
||||||
obj->setPartId(m_partId);
|
obj->setPartId(m_partId);
|
||||||
@ -182,13 +181,12 @@ bool zeus::WebServer::onReceiveUri(const std::string& _uri, const std::vector<st
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary) {
|
void zeus::WebServer::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary) {
|
||||||
ememory::SharedPtr<zeus::Buffer> dataRaw = zeus::Buffer::create();
|
|
||||||
if (_isBinary == true) {
|
if (_isBinary == true) {
|
||||||
ZEUS_ERROR("Receive non binary frame ...");
|
ZEUS_ERROR("Receive non binary frame ...");
|
||||||
disconnect(true);
|
disconnect(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dataRaw->composeWith(_frame);
|
ememory::SharedPtr<zeus::Buffer> dataRaw = zeus::Buffer::create(_frame);
|
||||||
newBuffer(dataRaw);
|
newBuffer(dataRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +195,7 @@ void zeus::WebServer::ping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer) {
|
void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer) {
|
||||||
ZEUS_VERBOSE("Receive :" << *_buffer);
|
ZEUS_VERBOSE("Receive :" << _buffer);
|
||||||
zeus::FutureBase future;
|
zeus::FutureBase future;
|
||||||
uint64_t tid = _buffer->getTransactionId();
|
uint64_t tid = _buffer->getTransactionId();
|
||||||
if (tid == 0) {
|
if (tid == 0) {
|
||||||
@ -306,8 +304,7 @@ zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId,
|
|||||||
ZEUS_VERBOSE("Send [START] ");
|
ZEUS_VERBOSE("Send [START] ");
|
||||||
if (isActive() == false) {
|
if (isActive() == false) {
|
||||||
ZEUS_ERROR("Send [STOP] ==> not connected (no TCP)");
|
ZEUS_ERROR("Send [STOP] ==> not connected (no TCP)");
|
||||||
ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> obj = zeus::BufferAnswer::create();
|
||||||
obj->setType(zeus::Buffer::typeMessage::answer);
|
|
||||||
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
||||||
return zeus::FutureBase(_transactionId, obj, _callback);
|
return zeus::FutureBase(_transactionId, obj, _callback);
|
||||||
}
|
}
|
||||||
@ -330,8 +327,7 @@ zeus::FutureBase zeus::WebServer::callForward(uint32_t _clientId,
|
|||||||
//ret.setSynchronous();
|
//ret.setSynchronous();
|
||||||
|
|
||||||
if (isActive() == false) {
|
if (isActive() == false) {
|
||||||
ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> obj = zeus::BufferAnswer::create();
|
||||||
obj->setType(zeus::Buffer::typeMessage::answer);
|
|
||||||
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
||||||
return zeus::FutureBase(0, obj, _callback);
|
return zeus::FutureBase(0, obj, _callback);
|
||||||
}
|
}
|
||||||
@ -371,11 +367,10 @@ void zeus::WebServer::callForwardMultiple(uint32_t _clientId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::answerError(uint64_t _clientTransactionId, const std::string& _errorValue, const std::string& _errorHelp, uint32_t _clientId) {
|
void zeus::WebServer::answerError(uint64_t _clientTransactionId, const std::string& _errorValue, const std::string& _errorHelp, uint32_t _clientId) {
|
||||||
ememory::SharedPtr<zeus::Buffer> answer = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> answer = zeus::BufferAnswer::create();
|
||||||
if (answer == nullptr) {
|
if (answer == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
answer->setType(zeus::Buffer::typeMessage::answer);
|
|
||||||
answer->setTransactionId(_clientTransactionId);
|
answer->setTransactionId(_clientTransactionId);
|
||||||
answer->setClientId(_clientId);
|
answer->setClientId(_clientId);
|
||||||
answer->addError(_errorValue, _errorHelp);
|
answer->addError(_errorValue, _errorHelp);
|
||||||
@ -384,11 +379,10 @@ void zeus::WebServer::answerError(uint64_t _clientTransactionId, const std::stri
|
|||||||
|
|
||||||
|
|
||||||
void zeus::WebServer::answerVoid(uint64_t _clientTransactionId, uint32_t _clientId) {
|
void zeus::WebServer::answerVoid(uint64_t _clientTransactionId, uint32_t _clientId) {
|
||||||
ememory::SharedPtr<zeus::Buffer> answer = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> answer = zeus::BufferAnswer::create();
|
||||||
if (answer == nullptr) {
|
if (answer == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
answer->setType(zeus::Buffer::typeMessage::answer);
|
|
||||||
answer->setTransactionId(_clientTransactionId);
|
answer->setTransactionId(_clientTransactionId);
|
||||||
answer->setClientId(_clientId);
|
answer->setClientId(_clientId);
|
||||||
answer->addParameter();
|
answer->addParameter();
|
||||||
|
@ -17,14 +17,14 @@ namespace zeus {
|
|||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ememory::SharedPtr<zeus::Buffer> createBaseCall(uint64_t _transactionId, const std::string& _functionName, const uint32_t& _serviceId=0);
|
ememory::SharedPtr<zeus::BufferCall> createBaseCall(uint64_t _transactionId, const std::string& _functionName, const uint32_t& _serviceId=0);
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void createParam(int32_t _paramId,
|
void createParam(int32_t _paramId,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj);
|
const ememory::SharedPtr<zeus::BufferCall>& _obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -33,9 +33,9 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template<class ZEUS_TYPE, class... _ARGS>
|
template<class ZEUS_TYPE, class... _ARGS>
|
||||||
void createParam(int32_t _paramId,
|
void createParam(int32_t _paramId,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferCall>& _obj,
|
||||||
const ZEUS_TYPE& _param,
|
const ZEUS_TYPE& _param,
|
||||||
_ARGS&&... _args) {
|
_ARGS&&... _args) {
|
||||||
_obj->addParameter<ZEUS_TYPE>(_param);
|
_obj->addParameter<ZEUS_TYPE>(_param);
|
||||||
_paramId++;
|
_paramId++;
|
||||||
createParam(_paramId, _obj, std::forward<_ARGS>(_args)...);
|
createParam(_paramId, _obj, std::forward<_ARGS>(_args)...);
|
||||||
@ -48,9 +48,9 @@ namespace zeus {
|
|||||||
// convert const char in std::string ...
|
// convert const char in std::string ...
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
void createParam(int32_t _paramId,
|
void createParam(int32_t _paramId,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _obj,
|
const ememory::SharedPtr<zeus::BufferCall>& _obj,
|
||||||
const char* _param,
|
const char* _param,
|
||||||
_ARGS&&... _args) {
|
_ARGS&&... _args) {
|
||||||
createParam(_paramId, _obj, std::string(_param), std::forward<_ARGS>(_args)...);
|
createParam(_paramId, _obj, std::string(_param), std::forward<_ARGS>(_args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +60,8 @@ namespace zeus {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
ememory::SharedPtr<zeus::Buffer> createCall(uint64_t _transactionId, const std::string& _functionName, _ARGS&&... _args) {
|
ememory::SharedPtr<zeus::BufferCall> createCall(uint64_t _transactionId, const std::string& _functionName, _ARGS&&... _args) {
|
||||||
ememory::SharedPtr<zeus::Buffer> callElem = createBaseCall(_transactionId, _functionName);
|
ememory::SharedPtr<zeus::BufferCall> callElem = createBaseCall(_transactionId, _functionName);
|
||||||
if (callElem == nullptr) {
|
if (callElem == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -74,8 +74,8 @@ namespace zeus {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
ememory::SharedPtr<zeus::Buffer> createCallService(uint64_t _transactionId, const uint32_t& _serviceName, const std::string& _functionName, _ARGS&&... _args) {
|
ememory::SharedPtr<zeus::BufferCall> createCallService(uint64_t _transactionId, const uint32_t& _serviceName, const std::string& _functionName, _ARGS&&... _args) {
|
||||||
ememory::SharedPtr<zeus::Buffer> callElem = createBaseCall(_transactionId, _functionName, _serviceName);
|
ememory::SharedPtr<zeus::BufferCall> callElem = createBaseCall(_transactionId, _functionName, _serviceName);
|
||||||
if (callElem == nullptr) {
|
if (callElem == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||||
uint16_t id = getId();
|
uint16_t id = getId();
|
||||||
ememory::SharedPtr<zeus::Buffer> callElem = zeus::createCall(id, _functionName, std::forward<_ARGS>(_args)...);
|
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCall(id, _functionName, std::forward<_ARGS>(_args)...);
|
||||||
return callBinary(id, callElem);
|
return callBinary(id, callElem);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -256,7 +256,7 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||||
uint16_t id = getId();
|
uint16_t id = getId();
|
||||||
ememory::SharedPtr<zeus::Buffer> callElem = zeus::createCall(id, _functionName, std::forward<_ARGS>(_args)...);
|
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCall(id, _functionName, std::forward<_ARGS>(_args)...);
|
||||||
return callBinary(id, callElem, _callback);
|
return callBinary(id, callElem, _callback);
|
||||||
}
|
}
|
||||||
public: // section call with service ID / Client ID
|
public: // section call with service ID / Client ID
|
||||||
@ -269,7 +269,7 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callService(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase callService(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args) {
|
||||||
uint16_t id = getId();
|
uint16_t id = getId();
|
||||||
ememory::SharedPtr<zeus::Buffer> callElem = zeus::createCallService(id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCallService(id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
||||||
return callBinary(id, callElem);
|
return callBinary(id, callElem);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -280,7 +280,7 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callServiceAction(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
zeus::FutureBase callServiceAction(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||||
uint16_t id = getId();
|
uint16_t id = getId();
|
||||||
ememory::SharedPtr<zeus::Buffer> callElem = zeus::createCallService(id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCallService(id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
||||||
return callBinary(id, callElem, _callback);
|
return callBinary(id, callElem, _callback);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -290,8 +290,8 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callClient(uint32_t _clientId,
|
zeus::FutureBase callClient(uint32_t _clientId,
|
||||||
const std::string& _functionName,
|
const std::string& _functionName,
|
||||||
_ARGS&&... _args) {
|
_ARGS&&... _args) {
|
||||||
return callService(_clientId, _functionName, _args...);
|
return callService(_clientId, _functionName, _args...);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -301,9 +301,9 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callClientAction(uint32_t _clientId,
|
zeus::FutureBase callClientAction(uint32_t _clientId,
|
||||||
const std::string& _functionName,
|
const std::string& _functionName,
|
||||||
_ARGS&&... _args,
|
_ARGS&&... _args,
|
||||||
zeus::FutureData::ObserverFinish _callback) {
|
zeus::FutureData::ObserverFinish _callback) {
|
||||||
return callServiceAction(_clientId, _functionName, _args..., _callback);
|
return callServiceAction(_clientId, _functionName, _args..., _callback);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -312,9 +312,9 @@ namespace zeus {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
zeus::FutureBase callForward(uint32_t _clientId,
|
zeus::FutureBase callForward(uint32_t _clientId,
|
||||||
const ememory::SharedPtr<zeus::Buffer>& _Buffer,
|
const ememory::SharedPtr<zeus::Buffer>& _Buffer,
|
||||||
uint64_t _singleReferenceId,
|
uint64_t _singleReferenceId,
|
||||||
zeus::FutureData::ObserverFinish _callback);
|
zeus::FutureData::ObserverFinish _callback);
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* @param[in]
|
* @param[in]
|
||||||
@ -338,8 +338,7 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template<class ZEUS_ARG>
|
template<class ZEUS_ARG>
|
||||||
void answerValue(uint64_t _clientTransactionId, ZEUS_ARG _value, uint32_t _clientId=0) {
|
void answerValue(uint64_t _clientTransactionId, ZEUS_ARG _value, uint32_t _clientId=0) {
|
||||||
ememory::SharedPtr<zeus::Buffer> answer = zeus::Buffer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> answer = zeus::BufferAnswer::create();
|
||||||
answer->setType(zeus::Buffer::typeMessage::answer);
|
|
||||||
answer->setTransactionId(_clientTransactionId);
|
answer->setTransactionId(_clientTransactionId);
|
||||||
answer->setClientId(_clientId);
|
answer->setClientId(_clientId);
|
||||||
answer->addAnswer(_value);
|
answer->addAnswer(_value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user