[DEV] continue thinking about signal and progression
This commit is contained in:
parent
7840f2231e
commit
cc7493c079
@ -36,7 +36,7 @@ list_of_known_type = [
|
|||||||
["stream", "zeus::Stream"],
|
["stream", "zeus::Stream"],
|
||||||
["json", "ejson::Object"],
|
["json", "ejson::Object"],
|
||||||
["raw", "zeus::Raw"],
|
["raw", "zeus::Raw"],
|
||||||
["ActionNotif", "zeus::ActionNotification"],
|
["ActionNotif", "zeus::ActionNotification<std::string>"],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -184,12 +184,14 @@ class FunctionDefinition:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = ""
|
self.name = ""
|
||||||
self.brief = ""
|
self.brief = ""
|
||||||
|
self.action_type = "void_tmp"
|
||||||
self.return_type = ""
|
self.return_type = ""
|
||||||
self.return_brief = ""
|
self.return_brief = ""
|
||||||
self.parameters = []
|
self.parameters = []
|
||||||
self.is_action = False
|
self.is_action = False
|
||||||
|
|
||||||
def set_action(self):
|
def set_action(self, type):
|
||||||
|
self.action_type = remove_start_stop_spacer(type)
|
||||||
self.is_action = True
|
self.is_action = True
|
||||||
|
|
||||||
def set_function_name(self, name):
|
def set_function_name(self, name):
|
||||||
@ -238,7 +240,10 @@ class FunctionDefinition:
|
|||||||
debug.info(" " + self.return_type + " " + self.name + "(")
|
debug.info(" " + self.return_type + " " + self.name + "(")
|
||||||
for elem in self.parameters:
|
for elem in self.parameters:
|
||||||
debug.info(" " + elem["type"] + " " + elem["name"] + ", # " + elem["brief"])
|
debug.info(" " + elem["type"] + " " + elem["name"] + ", # " + elem["brief"])
|
||||||
debug.info(" )")
|
if action_type == "void":
|
||||||
|
debug.info(" )")
|
||||||
|
else:
|
||||||
|
debug.info(" ) action/event type = '" + action_type + "'")
|
||||||
|
|
||||||
def generate_doxy(self, space):
|
def generate_doxy(self, space):
|
||||||
# generate doxygen comment:
|
# generate doxygen comment:
|
||||||
@ -275,7 +280,7 @@ class FunctionDefinition:
|
|||||||
param_data = ""
|
param_data = ""
|
||||||
id_parameter = 0
|
id_parameter = 0
|
||||||
if self.is_action == True:
|
if self.is_action == True:
|
||||||
param_data += "zeus::ActionNotification& _notifs"
|
param_data += "zeus::ActionNotification<" + convert_type_in_cpp(self.action_type, False, True) + ">& _notifs"
|
||||||
id_parameter += 1
|
id_parameter += 1
|
||||||
for elem in self.parameters:
|
for elem in self.parameters:
|
||||||
id_parameter += 1
|
id_parameter += 1
|
||||||
@ -297,7 +302,10 @@ class FunctionDefinition:
|
|||||||
def generate_hpp_proxy(self, space):
|
def generate_hpp_proxy(self, space):
|
||||||
out = "";
|
out = "";
|
||||||
out += self.generate_doxy(space)
|
out += self.generate_doxy(space)
|
||||||
out += space + "virtual zeus::Future<" + convert_type_in_cpp(self.return_type, True, False) + "> " + self.name + "("
|
out += space + "virtual zeus::Future<" + convert_type_in_cpp(self.return_type, True, False)
|
||||||
|
if self.action_type != "void_tmp":
|
||||||
|
out += "," + convert_type_in_cpp(self.action_type, True, False)
|
||||||
|
out += "> " + self.name + "("
|
||||||
param_data = ""
|
param_data = ""
|
||||||
id_parameter = 0
|
id_parameter = 0
|
||||||
for elem in self.parameters:
|
for elem in self.parameters:
|
||||||
@ -310,11 +318,14 @@ class FunctionDefinition:
|
|||||||
else:
|
else:
|
||||||
param_data += elem["name"]
|
param_data += elem["name"]
|
||||||
out += param_data
|
out += param_data
|
||||||
out += ") const;\n"
|
out += ");\n"
|
||||||
return out;
|
return out;
|
||||||
def generate_cpp_proxy(self, space, class_name):
|
def generate_cpp_proxy(self, space, class_name):
|
||||||
out = "";
|
out = "";
|
||||||
out += space + "zeus::Future<" + convert_type_in_cpp(self.return_type, True, False) + "> " + class_name + "::" + self.name + "("
|
out += space + "zeus::Future<" + convert_type_in_cpp(self.return_type, True, False)
|
||||||
|
if self.action_type != "void_tmp":
|
||||||
|
out += "," + convert_type_in_cpp(self.action_type, True, False)
|
||||||
|
out += "> " + class_name + "::" + self.name + "("
|
||||||
param_data = ""
|
param_data = ""
|
||||||
id_parameter = 0
|
id_parameter = 0
|
||||||
for elem in self.parameters:
|
for elem in self.parameters:
|
||||||
@ -327,7 +338,7 @@ class FunctionDefinition:
|
|||||||
else:
|
else:
|
||||||
param_data += elem["name"]
|
param_data += elem["name"]
|
||||||
out += param_data
|
out += param_data
|
||||||
out += ") const {\n"
|
out += ") {\n"
|
||||||
space += " "
|
space += " "
|
||||||
if self.is_action == True:
|
if self.is_action == True:
|
||||||
out += space + 'return m_obj.callAction("' + self.name + '"'
|
out += space + 'return m_obj.callAction("' + self.name + '"'
|
||||||
@ -933,9 +944,17 @@ def tool_generate_idl(target, module, data_option):
|
|||||||
if line[:10] == "[function]":
|
if line[:10] == "[function]":
|
||||||
type_function = "function"
|
type_function = "function"
|
||||||
line = line[10:]
|
line = line[10:]
|
||||||
if line[:8] == "[action]":
|
if line[:8] == "[action ":
|
||||||
type_function = "action"
|
type_function = "action"
|
||||||
line = line[8:]
|
line = line[8:]
|
||||||
|
type_event = "";
|
||||||
|
for elem in line:
|
||||||
|
if elem == "]":
|
||||||
|
break
|
||||||
|
type_event += elem
|
||||||
|
line = line[len(type_event)+1:]
|
||||||
|
if validate_type(type_event) == False:
|
||||||
|
debug.error("line " + str(id_line) + " action type unknow : '" + type_event + "' not in " + str(get_list_type()))
|
||||||
|
|
||||||
# remove wihte space
|
# remove wihte space
|
||||||
while len(line)>0 \
|
while len(line)>0 \
|
||||||
@ -987,7 +1006,7 @@ def tool_generate_idl(target, module, data_option):
|
|||||||
if type_function == "function":
|
if type_function == "function":
|
||||||
service_def.add_function(current_def)
|
service_def.add_function(current_def)
|
||||||
elif type_function == "action":
|
elif type_function == "action":
|
||||||
current_def.set_action()
|
current_def.set_action(type_event)
|
||||||
service_def.add_function(current_def)
|
service_def.add_function(current_def)
|
||||||
elif type_function == "factory":
|
elif type_function == "factory":
|
||||||
service_def.add_factory(current_def)
|
service_def.add_factory(current_def)
|
||||||
|
@ -33,7 +33,7 @@ obj:zeus-Media get(uint32)
|
|||||||
#param:data:A file reference on the media (transmission is async)
|
#param:data:A file reference on the media (transmission is async)
|
||||||
#return:Local personal ID of the media
|
#return:Local personal ID of the media
|
||||||
//#notification:Send progression in json
|
//#notification:Send progression in json
|
||||||
[action] uint32 add(obj:zeus-File)
|
[action string] uint32 add(obj:zeus-File)
|
||||||
|
|
||||||
#brief:Remove a media in the service (no trash)
|
#brief:Remove a media in the service (no trash)
|
||||||
#param:mediaId:Id of the media
|
#param:mediaId:Id of the media
|
||||||
|
@ -20,16 +20,16 @@ namespace zeus {
|
|||||||
* @param[in] _pointer Pointer on the class to call
|
* @param[in] _pointer Pointer on the class to call
|
||||||
* @param[in] _func pointer on the function to call
|
* @param[in] _func pointer on the function to call
|
||||||
*/
|
*/
|
||||||
template <class ZEUS_CLASS_TYPE, class ZEUS_RETURN, class... ZEUS_TYPES>
|
template <class ZEUS_CLASS_TYPE, class ZEUS_RETURN, class ZEUS_EVENT, class... ZEUS_TYPES>
|
||||||
void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||||
ememory::SharedPtr<zeus::message::Parameter> _obj,
|
ememory::SharedPtr<zeus::message::Parameter> _obj,
|
||||||
ZEUS_CLASS_TYPE* _pointer,
|
ZEUS_CLASS_TYPE* _pointer,
|
||||||
ZEUS_RETURN (ZEUS_CLASS_TYPE::*_func)(zeus::ActionNotification& _notifs, ZEUS_TYPES...)) {
|
ZEUS_RETURN (ZEUS_CLASS_TYPE::*_func)(zeus::ActionNotification<ZEUS_EVENT>& _notifs, ZEUS_TYPES...)) {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ZEUS_RETURN ret;
|
ZEUS_RETURN ret;
|
||||||
zeus::ActionNotification notifs(_interfaceClient, _obj->getTransactionId(), _obj->getDestination(), _obj->getSource());
|
zeus::ActionNotification<ZEUS_EVENT> notifs(_interfaceClient, _obj->getTransactionId(), _obj->getDestination(), _obj->getSource());
|
||||||
if (zeus::checkOrderFunctionParameter() == true) {
|
if (zeus::checkOrderFunctionParameter() == true) {
|
||||||
// clang generate a basic warning:
|
// clang generate a basic warning:
|
||||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||||
@ -89,15 +89,15 @@ namespace zeus {
|
|||||||
* @param[in] _pointer Pointer on the class to call
|
* @param[in] _pointer Pointer on the class to call
|
||||||
* @param[in] _func pointer on the function to call
|
* @param[in] _func pointer on the function to call
|
||||||
*/
|
*/
|
||||||
template <class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
template <class ZEUS_CLASS_TYPE, class ZEUS_EVENT, class... ZEUS_TYPES>
|
||||||
void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
void executeClassCall(ememory::SharedPtr<zeus::WebServer> _interfaceClient,
|
||||||
ememory::SharedPtr<zeus::message::Parameter> _obj,
|
ememory::SharedPtr<zeus::message::Parameter> _obj,
|
||||||
ZEUS_CLASS_TYPE* _pointer,
|
ZEUS_CLASS_TYPE* _pointer,
|
||||||
void (ZEUS_CLASS_TYPE::*_func)(zeus::ActionNotification& _notifs, ZEUS_TYPES...)) {
|
void (ZEUS_CLASS_TYPE::*_func)(zeus::ActionNotification<ZEUS_EVENT>& _notifs, ZEUS_TYPES...)) {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
zeus::ActionNotification notifs(_interfaceClient, _obj->getTransactionId(), _obj->getDestination(), _obj->getSource());
|
zeus::ActionNotification<ZEUS_EVENT> notifs(_interfaceClient, _obj->getTransactionId(), _obj->getDestination(), _obj->getSource());
|
||||||
if (zeus::checkOrderFunctionParameter() == true) {
|
if (zeus::checkOrderFunctionParameter() == true) {
|
||||||
// clang generate a basic warning:
|
// clang generate a basic warning:
|
||||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||||
@ -152,13 +152,13 @@ namespace zeus {
|
|||||||
/**
|
/**
|
||||||
* @brief Chass that permit to declare a function that call intanced element or a class element
|
* @brief Chass that permit to declare a function that call intanced element or a class element
|
||||||
*/
|
*/
|
||||||
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
template <class ZEUS_RETURN, class ZEUS_EVENT, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||||
class AbstractActionTypeClass: public zeus::AbstractFunction {
|
class AbstractActionTypeClass: public zeus::AbstractFunction {
|
||||||
protected:
|
protected:
|
||||||
static const zeus::message::ParamType m_returnType;
|
static const zeus::message::ParamType m_returnType;
|
||||||
static const zeus::message::ParamType m_paramType[sizeof...(ZEUS_TYPES)];
|
static const zeus::message::ParamType m_paramType[sizeof...(ZEUS_TYPES)];
|
||||||
public:
|
public:
|
||||||
using functionType = ZEUS_RETURN (ZEUS_CLASS_TYPE::*)(zeus::ActionNotification& _notifs, ZEUS_TYPES...);
|
using functionType = ZEUS_RETURN (ZEUS_CLASS_TYPE::*)(zeus::ActionNotification<ZEUS_EVENT>& _notifs, ZEUS_TYPES...);
|
||||||
functionType m_function;
|
functionType m_function;
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -418,11 +418,11 @@ namespace zeus {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// specialization
|
// specialization
|
||||||
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
template <class ZEUS_RETURN, class ZEUS_EVENT, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||||
const zeus::message::ParamType AbstractActionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_returnType = zeus::message::createType<ZEUS_RETURN>();
|
const zeus::message::ParamType AbstractActionTypeClass<ZEUS_RETURN, ZEUS_EVENT, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_returnType = zeus::message::createType<ZEUS_RETURN>();
|
||||||
// specialization
|
// specialization
|
||||||
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
template <class ZEUS_RETURN, class ZEUS_EVENT, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||||
const zeus::message::ParamType AbstractActionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_paramType[sizeof...(ZEUS_TYPES)] = {zeus::message::createType<ZEUS_TYPES>()...};
|
const zeus::message::ParamType AbstractActionTypeClass<ZEUS_RETURN, ZEUS_EVENT, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_paramType[sizeof...(ZEUS_TYPES)] = {zeus::message::createType<ZEUS_TYPES>()...};
|
||||||
// specialization
|
// specialization
|
||||||
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||||
const zeus::message::ParamType AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_returnType = zeus::message::createType<ZEUS_RETURN>();
|
const zeus::message::ParamType AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_returnType = zeus::message::createType<ZEUS_RETURN>();
|
||||||
@ -435,9 +435,9 @@ namespace zeus {
|
|||||||
* @param[in] _fffp Pointer of the function
|
* @param[in] _fffp Pointer of the function
|
||||||
* @return Abstract type of the function
|
* @return Abstract type of the function
|
||||||
*/
|
*/
|
||||||
template <typename ZEUS_RETURN, class ZEUS_CLASS_TYPE, typename... ZEUS_TYPES>
|
template <typename ZEUS_RETURN, class ZEUS_EVENT, class ZEUS_CLASS_TYPE, typename... ZEUS_TYPES>
|
||||||
AbstractFunction* createAbstractFunctionClass(const std::string& _name, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(zeus::ActionNotification& _notifs, ZEUS_TYPES...)) {
|
AbstractFunction* createAbstractFunctionClass(const std::string& _name, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(zeus::ActionNotification<ZEUS_EVENT>& _notifs, ZEUS_TYPES...)) {
|
||||||
return new AbstractActionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>(_name, _fffp);
|
return new AbstractActionTypeClass<ZEUS_RETURN, ZEUS_EVENT, ZEUS_CLASS_TYPE, ZEUS_TYPES...>(_name, _fffp);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Create a function information with the function type
|
* @brief Create a function information with the function type
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
|
template<class ZEUS_TYPE_EVENT>
|
||||||
class ActionNotification {
|
class ActionNotification {
|
||||||
private:
|
private:
|
||||||
ememory::SharedPtr<zeus::WebServer> m_interface;
|
ememory::SharedPtr<zeus::WebServer> m_interface;
|
||||||
@ -25,11 +26,15 @@ namespace zeus {
|
|||||||
m_transactionId(_transactionId),
|
m_transactionId(_transactionId),
|
||||||
m_source(_source),
|
m_source(_source),
|
||||||
m_destination(_destination) {}
|
m_destination(_destination) {}
|
||||||
|
// TODO: Deprecated ...
|
||||||
void notify(const std::string& _value) {
|
void notify(const ZEUS_TYPE_EVENT& _value) {
|
||||||
if (m_interface != nullptr) {
|
emit(_value);
|
||||||
m_interface->progressNotify(m_transactionId, m_source, m_destination, _value);
|
}
|
||||||
|
void emit(const ZEUS_TYPE_EVENT& _value) {
|
||||||
|
if (m_interface == nullptr) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
m_interface->eventValue(m_transactionId, m_source, m_destination, _value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -121,6 +121,7 @@ void zeus::Client::onClientData(ememory::SharedPtr<zeus::Message> _value) {
|
|||||||
}
|
}
|
||||||
answerProtocolError(transactionId, "interact with client, musty only call: link/unlink/movelink");
|
answerProtocolError(transactionId, "interact with client, musty only call: link/unlink/movelink");
|
||||||
return;
|
return;
|
||||||
|
/*
|
||||||
} else if (_value->getType() == zeus::message::type::event) {
|
} else if (_value->getType() == zeus::message::type::event) {
|
||||||
ememory::SharedPtr<zeus::message::Event> eventObj = ememory::staticPointerCast<zeus::message::Event>(_value);
|
ememory::SharedPtr<zeus::message::Event> eventObj = ememory::staticPointerCast<zeus::message::Event>(_value);
|
||||||
std::string callFunction = eventObj->getCall();
|
std::string callFunction = eventObj->getCall();
|
||||||
@ -131,6 +132,7 @@ void zeus::Client::onClientData(ememory::SharedPtr<zeus::Message> _value) {
|
|||||||
}
|
}
|
||||||
answerProtocolError(transactionId, "interact with client, musty only call: removeInterface");
|
answerProtocolError(transactionId, "interact with client, musty only call: removeInterface");
|
||||||
return;
|
return;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
m_interfaceWeb->answerError(transactionId, _value->getDestination(), _value->getSource(), "UNKNOW-ACTION");
|
m_interfaceWeb->answerError(transactionId, _value->getDestination(), _value->getSource(), "UNKNOW-ACTION");
|
||||||
return;
|
return;
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
// TODO : When do a cast of the type on the future ==> do a wait ...
|
// TODO : When do a cast of the type on the future ==> do a wait ...
|
||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
|
class void_tmp {};
|
||||||
/**
|
/**
|
||||||
* @brief future template to cast type in a specific type
|
* @brief future template to cast type in a specific type
|
||||||
*/
|
*/
|
||||||
template<class ZEUS_RETURN, class ZEUS_EVENT=void>
|
template<class ZEUS_RETURN, class ZEUS_EVENT=void_tmp>
|
||||||
class Future : public zeus::FutureBase {
|
class Future : public zeus::FutureBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -123,35 +124,29 @@ namespace zeus {
|
|||||||
* @param[in] _callback Handle on the function to call in progress information
|
* @param[in] _callback Handle on the function to call in progress information
|
||||||
*/
|
*/
|
||||||
// TODO: this is deprecated ...
|
// TODO: this is deprecated ...
|
||||||
Future<ZEUS_RETURN>& onProgress(Promise::ObserverProgress _callback) {
|
Future<ZEUS_RETURN>& onProgress(Promise::ObserverEvent _callback) {
|
||||||
zeus::FutureBase::onProgress(_callback);
|
zeus::FutureBase::onEvent(_callback);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
//template<typename = std::enable_if<std::is_void<ZEUS_EVENT>::value, false>>
|
||||||
Future<ZEUS_RETURN>& onSignal(std::function<void(const ZEUS_EVENT&)> _callback) {
|
Future<ZEUS_RETURN>& onSignal(std::function<void(const ZEUS_EVENT&)> _callback) {
|
||||||
zeus::FutureBase::onSignal(
|
zeus::FutureBase::onEvent(
|
||||||
[=](ememory::SharedPtr<zeus::Message> _msg) {
|
[=](ememory::SharedPtr<zeus::message::Event> _msg) {
|
||||||
if (_msg == nullptr) {
|
if (_msg == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_msg->getType() != zeus::message::type::progress) {
|
_callback(_msg->getEvent<ZEUS_EVENT>());
|
||||||
ZEUS_WARNING("No Return value ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return _callback(static_cast<zeus::message::Progress*>(_msg.get())->getAnswer<ZEUS_EVENT>());
|
|
||||||
});
|
});
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
//template<typename = std::enable_if<std::is_void<ZEUS_EVENT>::value, false>>
|
||||||
Future<ZEUS_RETURN>& onSignal(std::function<void(ZEUS_EVENT)> _callback) {
|
Future<ZEUS_RETURN>& onSignal(std::function<void(ZEUS_EVENT)> _callback) {
|
||||||
zeus::FutureBase::onSignal(
|
zeus::FutureBase::onEvent(
|
||||||
[=](ememory::SharedPtr<zeus::Message> _msg) {
|
[=](ememory::SharedPtr<zeus::message::Event> _msg) {
|
||||||
if (_msg == nullptr) {
|
if (_msg == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_msg->getType() != zeus::message::type::progress) {
|
_callback(std::move(_msg->getEvent<ZEUS_EVENT>()));
|
||||||
ZEUS_WARNING("No Return value ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return _callback(std::move(static_cast<zeus::message::Progress*>(_msg.get())->getAnswer<ZEUS_EVENT>()));
|
|
||||||
});
|
});
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -160,7 +155,7 @@ namespace zeus {
|
|||||||
* @brief future template to cast type in a void methode (fallback)
|
* @brief future template to cast type in a void methode (fallback)
|
||||||
*/
|
*/
|
||||||
template<>
|
template<>
|
||||||
class Future<void,void> : public zeus::FutureBase {
|
class Future<void> : public zeus::FutureBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief contructor of the Future with the basic FutureBase
|
* @brief contructor of the Future with the basic FutureBase
|
||||||
@ -241,8 +236,8 @@ namespace zeus {
|
|||||||
* @brief Attach callback on activity of the action if user set some return information
|
* @brief Attach callback on activity of the action if user set some return information
|
||||||
* @param[in] _callback Handle on the function to call in progress information
|
* @param[in] _callback Handle on the function to call in progress information
|
||||||
*/
|
*/
|
||||||
Future<void>& onProgress(Promise::ObserverProgress _callback) {
|
Future<void>& onEvent(Promise::ObserverEvent _callback) {
|
||||||
zeus::FutureBase::onProgress(_callback);
|
zeus::FutureBase::onEvent(_callback);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -71,11 +71,11 @@ void zeus::FutureBase::andElse(zeus::Promise::Observer _callback) {
|
|||||||
m_promise->andElse(_callback);
|
m_promise->andElse(_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::FutureBase::onProgress(zeus::Promise::ObserverProgress _callback) {
|
void zeus::FutureBase::onEvent(zeus::Promise::ObserverEvent _callback) {
|
||||||
if (m_promise == nullptr) {
|
if (m_promise == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_promise->onProgress(_callback);
|
m_promise->onEvent(_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
echrono::Duration zeus::FutureBase::getTransmitionTime() const {
|
echrono::Duration zeus::FutureBase::getTransmitionTime() const {
|
||||||
|
@ -44,7 +44,7 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::Message> _returnData, uint32_t _source=0);
|
FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::Message> _returnData, uint32_t _source=0);
|
||||||
/**
|
/**
|
||||||
* @brief set the call is an action an then it can receive remote data ==> the authorize the onProgress Callback ..
|
* @brief set the call is an action an then it can receive remote data ==> the authorize the onEvent Callback ..
|
||||||
* @note system use only ==> user have never to call this function...
|
* @note system use only ==> user have never to call this function...
|
||||||
*/
|
*/
|
||||||
void setAction();
|
void setAction();
|
||||||
@ -65,9 +65,9 @@ namespace zeus {
|
|||||||
void andElse(zeus::Promise::Observer _callback);
|
void andElse(zeus::Promise::Observer _callback);
|
||||||
/**
|
/**
|
||||||
* @brief Attach callback on activity of the action if user set some return information
|
* @brief Attach callback on activity of the action if user set some return information
|
||||||
* @param[in] _callback Handle on the function to call in progress information
|
* @param[in] _callback Handle on the function to call in event information
|
||||||
*/
|
*/
|
||||||
void onProgress(zeus::Promise::ObserverProgress _callback);
|
void onEvent(zeus::Promise::ObserverEvent _callback);
|
||||||
/*
|
/*
|
||||||
/ **
|
/ **
|
||||||
* @brief Attach callback on a specific return action (ABORT)
|
* @brief Attach callback on a specific return action (ABORT)
|
||||||
|
@ -117,10 +117,11 @@ namespace zeus {
|
|||||||
* @note: this is for ACTION function call not normal function call
|
* @note: this is for ACTION function call not normal function call
|
||||||
*/
|
*/
|
||||||
template<class ZEUS_RETURN_VALUE,
|
template<class ZEUS_RETURN_VALUE,
|
||||||
|
class ZEUS_ACTION_TYPE,
|
||||||
class ZEUS_CLASS_TYPE,
|
class ZEUS_CLASS_TYPE,
|
||||||
class... ZEUS_FUNC_ARGS_TYPE>
|
class... ZEUS_FUNC_ARGS_TYPE>
|
||||||
zeus::AbstractFunction* advertise(const std::string& _name,
|
zeus::AbstractFunction* advertise(const std::string& _name,
|
||||||
ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(zeus::ActionNotification& _notifs, ZEUS_FUNC_ARGS_TYPE... _args)) {
|
ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(zeus::ActionNotification<ZEUS_ACTION_TYPE>& _notifs, ZEUS_FUNC_ARGS_TYPE... _args)) {
|
||||||
if (etk::start_with(_name, "srv.") == true) {
|
if (etk::start_with(_name, "srv.") == true) {
|
||||||
ZEUS_ERROR("Advertise function start with 'srv.' is not permited ==> only allow for internal service: '" << _name << "'");
|
ZEUS_ERROR("Advertise function start with 'srv.' is not permited ==> only allow for internal service: '" << _name << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <zeus/Promise.hpp>
|
#include <zeus/Promise.hpp>
|
||||||
#include <zeus/FutureBase.hpp>
|
#include <zeus/FutureBase.hpp>
|
||||||
#include <zeus/message/Answer.hpp>
|
#include <zeus/message/Answer.hpp>
|
||||||
#include <zeus/message/Progress.hpp>
|
#include <zeus/message/Event.hpp>
|
||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
#include <zeus/WebServer.hpp>
|
#include <zeus/WebServer.hpp>
|
||||||
|
|
||||||
@ -106,12 +106,12 @@ void zeus::Promise::andElse(zeus::Promise::Observer _callback) {
|
|||||||
m_callbackElse(zeus::FutureBase(sharedFromThis()));
|
m_callbackElse(zeus::FutureBase(sharedFromThis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Promise::onProgress(zeus::Promise::ObserverProgress _callback) {
|
void zeus::Promise::onEvent(zeus::Promise::ObserverEvent _callback) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
if (m_isAction == false) {
|
if (m_isAction == false) {
|
||||||
ZEUS_ERROR("Request a progress calback on a simple function call");
|
ZEUS_ERROR("Request a Event calback on a simple function call");
|
||||||
}
|
}
|
||||||
m_callbackProgress = _callback;
|
m_callbackEvent = _callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
echrono::Duration zeus::Promise::getTransmitionTime() const {
|
echrono::Duration zeus::Promise::getTransmitionTime() const {
|
||||||
@ -127,11 +127,18 @@ bool zeus::Promise::setMessage(ememory::SharedPtr<zeus::Message> _value) {
|
|||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
m_receiveTime = echrono::Steady::now();
|
m_receiveTime = echrono::Steady::now();
|
||||||
}
|
}
|
||||||
if (_value->getType() != zeus::message::type::progress) {
|
if (_value->getType() != zeus::message::type::event) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
// notification of a progresion ...
|
// notification of a progresion ...
|
||||||
if (m_callbackProgress != nullptr) {
|
if (m_callbackEvent != nullptr) {
|
||||||
m_callbackProgress(static_cast<const zeus::message::Progress*>(m_message.get())->getData());
|
if (_value == nullptr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (_value->getType() != zeus::message::type::event) {
|
||||||
|
ZEUS_WARNING("No Return value ...");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
m_callbackEvent(ememory::staticPointerCast<zeus::message::Event>(_value));
|
||||||
return false; // no error
|
return false; // no error
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <zeus/message/Message.hpp>
|
#include <zeus/message/Message.hpp>
|
||||||
|
#include <zeus/message/Event.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
#include <echrono/Steady.hpp>
|
#include <echrono/Steady.hpp>
|
||||||
@ -21,7 +22,7 @@ namespace zeus {
|
|||||||
class Promise : public ememory::EnableSharedFromThis<zeus::Promise> {
|
class Promise : public ememory::EnableSharedFromThis<zeus::Promise> {
|
||||||
public:
|
public:
|
||||||
using Observer = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer
|
using Observer = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer
|
||||||
using ObserverProgress = std::function<void(const std::string&)>; //!< Define the observer on activity of the action (note that is a string, but it can contain json or other ...)
|
using ObserverEvent = std::function<void(ememory::SharedPtr<zeus::message::Event>)>; //!< Define the observer on activity of the action (note that is a string, but it can contain json or other ...)
|
||||||
private:
|
private:
|
||||||
mutable std::mutex m_mutex; //!< local prevention of multiple acess
|
mutable std::mutex m_mutex; //!< local prevention of multiple acess
|
||||||
uint32_t m_transactionId; //!< waiting answer data
|
uint32_t m_transactionId; //!< waiting answer data
|
||||||
@ -29,7 +30,7 @@ namespace zeus {
|
|||||||
ememory::SharedPtr<zeus::Message> m_message; //!< all buffer concatenate or last buffer if synchronous
|
ememory::SharedPtr<zeus::Message> m_message; //!< all buffer concatenate or last buffer if synchronous
|
||||||
Observer m_callbackThen; //!< observer callback When data arrive and NO error appear
|
Observer m_callbackThen; //!< observer callback When data arrive and NO error appear
|
||||||
Observer m_callbackElse; //!< observer callback When data arrive and AN error appear
|
Observer m_callbackElse; //!< observer callback When data arrive and AN error appear
|
||||||
ObserverProgress m_callbackProgress; //!< observer callback When progress is sended from the remote object called
|
ObserverEvent m_callbackEvent; //!< observer callback when event is sended from the remote object called
|
||||||
//Observer m_callbackAbort; //!< observer callback When Action is abort by user
|
//Observer m_callbackAbort; //!< observer callback When Action is abort by user
|
||||||
echrono::Steady m_sendTime; //!< time when the future has been sended request
|
echrono::Steady m_sendTime; //!< time when the future has been sended request
|
||||||
echrono::Steady m_receiveTime; //!< time when the future has receve answer
|
echrono::Steady m_receiveTime; //!< time when the future has receve answer
|
||||||
@ -51,7 +52,7 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
Promise(uint32_t _transactionId, ememory::SharedPtr<zeus::Message> _returnData, uint32_t _source=0);
|
Promise(uint32_t _transactionId, ememory::SharedPtr<zeus::Message> _returnData, uint32_t _source=0);
|
||||||
/**
|
/**
|
||||||
* @brief set the call is an action an then it can receive remote data ==> the authorize the onProgress Callback ..
|
* @brief set the call is an action an then it can receive remote data ==> the authorize the onEvent Callback ..
|
||||||
* @note system use only ==> user have never to call this function...
|
* @note system use only ==> user have never to call this function...
|
||||||
*/
|
*/
|
||||||
void setAction();
|
void setAction();
|
||||||
@ -72,9 +73,9 @@ namespace zeus {
|
|||||||
void andElse(zeus::Promise::Observer _callback);
|
void andElse(zeus::Promise::Observer _callback);
|
||||||
/**
|
/**
|
||||||
* @brief Attach callback on activity of the action if user set some return information
|
* @brief Attach callback on activity of the action if user set some return information
|
||||||
* @param[in] _callback Handle on the function to call in progress information
|
* @param[in] _callback Handle on the function to call in event information
|
||||||
*/
|
*/
|
||||||
void onProgress(zeus::Promise::ObserverProgress _callback);
|
void onEvent(zeus::Promise::ObserverEvent _callback);
|
||||||
/*
|
/*
|
||||||
/ **
|
/ **
|
||||||
* @brief Attach callback on a specific return action (ABORT)
|
* @brief Attach callback on a specific return action (ABORT)
|
||||||
|
@ -11,18 +11,13 @@
|
|||||||
#include <zeus/message/Data.hpp>
|
#include <zeus/message/Data.hpp>
|
||||||
|
|
||||||
|
|
||||||
ememory::SharedPtr<zeus::message::Call> zeus::createBaseCall(bool _isEvent,
|
ememory::SharedPtr<zeus::message::Call> zeus::createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
||||||
const ememory::SharedPtr<zeus::WebServer>& _iface,
|
|
||||||
uint64_t _transactionId,
|
uint64_t _transactionId,
|
||||||
const uint32_t& _source,
|
const uint32_t& _source,
|
||||||
const uint32_t& _destination,
|
const uint32_t& _destination,
|
||||||
const std::string& _functionName) {
|
const std::string& _functionName) {
|
||||||
ememory::SharedPtr<zeus::message::Call> obj;
|
ememory::SharedPtr<zeus::message::Call> obj;
|
||||||
if (_isEvent == false) {
|
obj = zeus::message::Call::create(_iface);
|
||||||
obj = zeus::message::Call::create(_iface);
|
|
||||||
} else {
|
|
||||||
obj = zeus::message::Event::create(_iface);
|
|
||||||
}
|
|
||||||
if (obj == nullptr) {
|
if (obj == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -664,16 +659,3 @@ void zeus::WebServer::answerVoid(uint32_t _clientTransactionId, uint32_t _source
|
|||||||
answer->addParameter();
|
answer->addParameter();
|
||||||
writeBinary(answer);
|
writeBinary(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::progressNotify(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, const std::string& _value) {
|
|
||||||
auto answer = zeus::message::Progress::create(sharedFromThis());
|
|
||||||
if (answer == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
answer->setTransactionId(_clientTransactionId);
|
|
||||||
answer->setSource(_source);
|
|
||||||
answer->setDestination(_destination);
|
|
||||||
answer->setData(_value);
|
|
||||||
writeBinary(answer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -34,8 +34,7 @@ namespace zeus {
|
|||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ememory::SharedPtr<zeus::message::Call> createBaseCall(bool _isEvent,
|
ememory::SharedPtr<zeus::message::Call> createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
||||||
const ememory::SharedPtr<zeus::WebServer>& _iface,
|
|
||||||
uint64_t _transactionId,
|
uint64_t _transactionId,
|
||||||
const uint32_t& _source,
|
const uint32_t& _source,
|
||||||
const uint32_t& _destination,
|
const uint32_t& _destination,
|
||||||
@ -81,14 +80,13 @@ namespace zeus {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
ememory::SharedPtr<zeus::message::Call> createCall(bool _isEvent,
|
ememory::SharedPtr<zeus::message::Call> createCall(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
||||||
const ememory::SharedPtr<zeus::WebServer>& _iface,
|
|
||||||
uint64_t _transactionId,
|
uint64_t _transactionId,
|
||||||
const uint32_t& _source,
|
const uint32_t& _source,
|
||||||
const uint32_t& _destination,
|
const uint32_t& _destination,
|
||||||
const std::string& _functionName,
|
const std::string& _functionName,
|
||||||
_ARGS&&... _args) {
|
_ARGS&&... _args) {
|
||||||
ememory::SharedPtr<zeus::message::Call> callElem = createBaseCall(_isEvent, _iface, _transactionId, _source, _destination, _functionName);
|
ememory::SharedPtr<zeus::message::Call> callElem = createBaseCall(_iface, _transactionId, _source, _destination, _functionName);
|
||||||
if (callElem == nullptr) {
|
if (callElem == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -307,21 +305,10 @@ namespace zeus {
|
|||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase call(const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase call(const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) {
|
||||||
uint16_t id = getId();
|
uint16_t id = getId();
|
||||||
ememory::SharedPtr<zeus::message::Call> callElem = zeus::createCall(false, sharedFromThis(), id, _source, _destination, _functionName, std::forward<_ARGS>(_args)...);
|
ememory::SharedPtr<zeus::message::Call> callElem = zeus::createCall(sharedFromThis(), id, _source, _destination, _functionName, std::forward<_ARGS>(_args)...);
|
||||||
return callBinary(id, callElem);
|
return callBinary(id, callElem);
|
||||||
}
|
}
|
||||||
/**
|
public: // Events ...
|
||||||
* @brief
|
|
||||||
* @param[in]
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
template<class... _ARGS>
|
|
||||||
void event(const uint32_t& _source, const uint32_t& _destination, const std::string& _eventName, _ARGS&&... _args) {
|
|
||||||
uint16_t id = getId();
|
|
||||||
ememory::SharedPtr<zeus::message::Call> callElem = zeus::createCall(true, sharedFromThis(), id, _source, _destination, _eventName, std::forward<_ARGS>(_args)...);
|
|
||||||
callBinary(id, callElem);
|
|
||||||
}
|
|
||||||
public: // progress ...
|
|
||||||
/**
|
/**
|
||||||
* @brief Send a progression value to a specific call in progress
|
* @brief Send a progression value to a specific call in progress
|
||||||
* @param[in] _transactionId Current trasaction ID
|
* @param[in] _transactionId Current trasaction ID
|
||||||
@ -329,7 +316,15 @@ namespace zeus {
|
|||||||
* @param[in] _destination Destinatio of the progression
|
* @param[in] _destination Destinatio of the progression
|
||||||
* @param[in] _value Value to send
|
* @param[in] _value Value to send
|
||||||
*/
|
*/
|
||||||
void progressNotify(uint32_t _transactionId, uint32_t _source, uint32_t _destination, const std::string& _value);
|
template<class ZEUS_ARG>
|
||||||
|
void eventValue(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, ZEUS_ARG _value) {
|
||||||
|
ememory::SharedPtr<zeus::message::Event> event = zeus::message::Event::create(sharedFromThis());
|
||||||
|
event->setTransactionId(_clientTransactionId);
|
||||||
|
event->setSource(_source);
|
||||||
|
event->setDestination(_destination);
|
||||||
|
event->addEvent(_value);
|
||||||
|
writeBinary(event);
|
||||||
|
}
|
||||||
public: // answers ...
|
public: // answers ...
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
@ -10,6 +10,31 @@
|
|||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <zeus/message/Event.hpp>
|
#include <zeus/message/Event.hpp>
|
||||||
|
|
||||||
|
void zeus::message::Event::generateDisplay(std::ostream& _os) const {
|
||||||
|
zeus::Message::generateDisplay(_os);
|
||||||
|
if (getNumberParameter() != 0) {
|
||||||
|
_os << " '" + simpleStringParam(0) + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zeus::message::Event::writeOn(enet::WebSocket& _interface) {
|
||||||
|
std::unique_lock<std::mutex> lock = _interface.getScopeLock();
|
||||||
|
zeus::Message::writeOn(_interface);
|
||||||
|
_interface.writeData((uint8_t*)(&m_uid), sizeof(m_uid));
|
||||||
|
if (message::Parameter::writeOn(_interface) == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int32_t count = _interface.send();
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeus::message::Event::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||||
|
uint64_t* uuid = (uint64_t*)_buffer;
|
||||||
|
m_uid = *uuid;
|
||||||
|
// parse parameters:
|
||||||
|
message::Parameter::composeWith(&_buffer[sizeof(m_uid)], _lenght-sizeof(m_uid));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
// -- Factory
|
// -- Factory
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
@ -17,3 +42,4 @@
|
|||||||
ememory::SharedPtr<zeus::message::Event> zeus::message::Event::create(ememory::SharedPtr<zeus::WebServer> _iface) {
|
ememory::SharedPtr<zeus::message::Event> zeus::message::Event::create(ememory::SharedPtr<zeus::WebServer> _iface) {
|
||||||
return ememory::SharedPtr<zeus::message::Event>(new zeus::message::Event(_iface));
|
return ememory::SharedPtr<zeus::message::Event>(new zeus::message::Event(_iface));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,24 +4,33 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <zeus/message/Call.hpp>
|
#include <etk/types.hpp>
|
||||||
|
#include <enet/WebSocket.hpp>
|
||||||
|
#include <zeus/message/ParamType.hpp>
|
||||||
|
#include <zeus/message/Parameter.hpp>
|
||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
|
class WebServer;
|
||||||
namespace message {
|
namespace message {
|
||||||
class Event :
|
class Event :
|
||||||
public message::Call {
|
public message::Parameter {
|
||||||
friend class zeus::Message;
|
friend class zeus::Message;
|
||||||
|
protected:
|
||||||
|
uint64_t m_uid; //!< Signal is sended in an active call ==> then we need to identify all the type ==> need an uniqueId ... the bigger bit mean that the message has no more data ...
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::message::Call::create
|
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::message::Event::create
|
||||||
*/
|
*/
|
||||||
Event(ememory::SharedPtr<zeus::WebServer> _iface):
|
Event(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||||
zeus::message::Call(_iface) {
|
zeus::message::Parameter(_iface) {
|
||||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::event);
|
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::message::type::event);
|
||||||
};
|
};
|
||||||
|
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||||
|
bool writeOn(enet::WebSocket& _interface) override;
|
||||||
|
void generateDisplay(std::ostream& _os) const override;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a shared pointer on the MessageCall
|
* @brief Create a shared pointer on the Event
|
||||||
* @return Allocated Message.
|
* @return Allocated Message.
|
||||||
*/
|
*/
|
||||||
static ememory::SharedPtr<zeus::message::Event> create(ememory::SharedPtr<zeus::WebServer> _iface);
|
static ememory::SharedPtr<zeus::message::Event> create(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||||
@ -29,7 +38,22 @@ namespace zeus {
|
|||||||
enum zeus::message::type getType() const override {
|
enum zeus::message::type getType() const override {
|
||||||
return zeus::message::type::event;
|
return zeus::message::type::event;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief set the Event of the call
|
||||||
|
* @param[in] _value Value to add
|
||||||
|
*/
|
||||||
|
template<class ZEUS_TYPE_DATA>
|
||||||
|
void addEvent(const ZEUS_TYPE_DATA& _value) {
|
||||||
|
addParameter(_value);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief get the Event value
|
||||||
|
* @param[in] Data of the Event
|
||||||
|
*/
|
||||||
|
template<class ZEUS_TYPE_DATA>
|
||||||
|
ZEUS_TYPE_DATA getEvent() const {
|
||||||
|
return getParameter<ZEUS_TYPE_DATA>(0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,11 +119,11 @@ zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string zeus::storeInFile(zeus::ProxyFile _file, std::string _filename) {
|
std::string zeus::storeInFile(zeus::ProxyFile _file, std::string _filename) {
|
||||||
zeus::ActionNotification tmp;
|
zeus::ActionNotification<std::string> tmp;
|
||||||
return zeus::storeInFileNotify(_file, _filename, tmp);
|
return zeus::storeInFileNotify(_file, _filename, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string zeus::storeInFileNotify(zeus::ProxyFile _file, std::string _filename, zeus::ActionNotification _notification) {
|
std::string zeus::storeInFileNotify(zeus::ProxyFile _file, std::string _filename, zeus::ActionNotification<std::string> _notification) {
|
||||||
auto futSize = _file.getSize();
|
auto futSize = _file.getSize();
|
||||||
auto futSha = _file.getSha512();
|
auto futSha = _file.getSha512();
|
||||||
futSize.wait();
|
futSize.wait();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user