diff --git a/main/include/modules/event.h b/main/include/modules/event.h index 2d0f50e..63ee5ad 100755 --- a/main/include/modules/event.h +++ b/main/include/modules/event.h @@ -52,7 +52,6 @@ class ModuleInputEvent std::function m_function; void trigger_happening(const std::string& trigger_name, HappeningState state, const std::string& log); - void(*m_foo)(const std::shared_ptr& args); std::string m_name; std::string m_description; std::vector> m_params; @@ -78,7 +77,6 @@ class ModuleOutputEvent virtual void execute() {}; - void(*m_foo)(const std::shared_ptr& args); std::string m_name; std::vector> m_happenings; }; diff --git a/main/include/modules/interface.h b/main/include/modules/interface.h index b2d317a..3e51141 100755 --- a/main/include/modules/interface.h +++ b/main/include/modules/interface.h @@ -41,8 +41,6 @@ class ModuleInterface void OnInputEvent(); void OnOutputEvent(); - void AddInputEventHandler(); - void AddOutputEventHandler(); template void AddArg(const std::string& key, T value); @@ -81,9 +79,6 @@ class ModuleInterface // TODO : AddMainWindow //void AddFunction(void (*item)(), const std::string& name, Parameters params); - void AddInputEvent(void (*item)(const std::shared_ptr& args), const std::string& name); - void AddInputEvent(void (*item)(const std::shared_ptr& args), const std::string& name, DevFlag devflag, const std::string& description, const std::vector>& args_def, const bool& can_callback); - void AddOutputEvent(void (*item)(const std::shared_ptr& args), const std::string& name); std::shared_ptr GetInterface(); void ExecuteFunction(const std::string& name); @@ -112,8 +107,10 @@ class ModuleInterface void LogWarning(const std::string& message); void LogError(const std::string& message); void LogFatal(const std::string& message); - void CallInputEvent(const std::shared_ptr &args, const std::string &event_name, const std::string &module_name, void (*callback)(std::shared_ptr _args)); - void CallInputEvent(const std::shared_ptr &args, const std::string &event_name, const std::string &module_name); + + void CallOutputEvent(const std::string &event_name, ArgumentValues& args, ReturnValues& ret); + void CallInputEvent(const std::string &module_name, const std::string &event_name, ArgumentValues& args, ReturnValues& ret); + static std::shared_ptr GetEditorModuleByName(const std::string& name); diff --git a/main/src/modules/interface.cpp b/main/src/modules/interface.cpp index 4e576c8..10615f3 100755 --- a/main/src/modules/interface.cpp +++ b/main/src/modules/interface.cpp @@ -214,74 +214,6 @@ void ModuleInterface::AddFunction(std::functionm_functions.push_back(p_function); } -/** - * @brief Adds an input event to the ModuleInterface. - * - * This function creates a shared_ptr to a ModuleInputEvent and adds it to the ModuleInterface's list of input events. - * - * @param item Pointer to the input event function. - * @param name Name of the input event. - */ -void ModuleInterface::AddInputEvent(void (*item)(const std::shared_ptr &args), const std::string &name) -{ - // Checking if the event already exist - for (auto existing_events : this->m_input_events) - { - if (name == existing_events->m_name) - { - this->LogError("\"" + name + "\" event already registered ! Abording."); - return; - } - } - - // Create a shared_ptr to the ModuleInputEvent - std::shared_ptr p_event = std::make_shared(item, name); - - // Add the shared_ptr to the list of input events - this->m_input_events.push_back(p_event); -} - -void ModuleInterface::AddInputEvent(void (*item)(const std::shared_ptr &args), const std::string &name, DevFlag devflag, const std::string &description, const std::vector> &args_def, const bool &can_callback) -{ - // Checking if the event already exist - for (auto existing_events : this->m_input_events) - { - if (name == existing_events->m_name) - { - this->LogError("\"" + name + "\" event already registered ! Abording."); - return; - } - } - - // Create a shared_ptr to the ModuleInputEvent - std::shared_ptr p_event = std::make_shared(item, name); - - p_event->m_can_callback = can_callback; - p_event->m_devflag = devflag; - p_event->m_description = description; - p_event->m_params = args_def; - - // Add the shared_ptr to the list of input events - this->m_input_events.push_back(p_event); -} - -/** - * @brief Adds an output event to the ModuleInterface. - * - * This function creates a shared_ptr to a ModuleOutputEvent and adds it to the ModuleInterface's list of output events. - * - * @param item Pointer to the output event function. - * @param name Name of the output event. - */ -void ModuleInterface::AddOutputEvent(void (*item)(const std::shared_ptr &args), const std::string &name) -{ - // Create a shared_ptr to the ModuleOutputEvent - std::shared_ptr p_event = std::make_shared(item, name); - - // Add the shared_ptr to the list of output events - this->m_output_events.push_back(p_event); -} - /** * @brief Gets a shared_ptr to a copy of the ModuleInterface. * @@ -705,14 +637,14 @@ void ModuleInterface::Stop() } } -void ModuleInterface::CallInputEvent(const std::shared_ptr &args, const std::string &event_name, const std::string &module_name, void (*callback)(std::shared_ptr _args)) -{ - VortexMaker::CallModuleEvent(args, event_name, module_name, callback, this->m_name); +void ModuleInterface::CallOutputEvent(const std::string &event_name, ArgumentValues& args, ReturnValues& ret) +{ + VortexMaker::CallOutputEvent(event_name, args, ret, this->m_name); } -void ModuleInterface::CallInputEvent(const std::shared_ptr &args, const std::string &event_name, const std::string &module_name) -{ - VortexMaker::CallModuleEvent(args, event_name, module_name, this->m_name); +void ModuleInterface::CallInputEvent(const std::string &module_name, const std::string &event_name, ArgumentValues& args, ReturnValues& ret) +{ + VortexMaker::CallInputEvent(module_name, event_name, args, ret, this->m_name); } void ModuleInterface::CheckVersion()