Skip to content

Commit

Permalink
fix: Remove all stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrno committed Nov 19, 2024
1 parent 30dd550 commit 909ab44
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 83 deletions.
2 changes: 0 additions & 2 deletions main/include/modules/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class ModuleInputEvent
std::function<void(ArgumentValues&, ReturnValues&)> m_function;
void trigger_happening(const std::string& trigger_name, HappeningState state, const std::string& log);

void(*m_foo)(const std::shared_ptr<hArgs>& args);
std::string m_name;
std::string m_description;
std::vector<std::tuple<std::string, std::string, std::string>> m_params;
Expand All @@ -78,7 +77,6 @@ class ModuleOutputEvent

virtual void execute() {};

void(*m_foo)(const std::shared_ptr<hArgs>& args);
std::string m_name;
std::vector<std::shared_ptr<ModuleOutputEventHappening>> m_happenings;
};
Expand Down
11 changes: 4 additions & 7 deletions main/include/modules/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class ModuleInterface
void OnInputEvent();
void OnOutputEvent();

void AddInputEventHandler();
void AddOutputEventHandler();

template<typename T>
void AddArg(const std::string& key, T value);
Expand Down Expand Up @@ -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<hArgs>& args), const std::string& name);
void AddInputEvent(void (*item)(const std::shared_ptr<hArgs>& args), const std::string& name, DevFlag devflag, const std::string& description, const std::vector<std::tuple<std::string, std::string, std::string>>& args_def, const bool& can_callback);
void AddOutputEvent(void (*item)(const std::shared_ptr<hArgs>& args), const std::string& name);
std::shared_ptr<ModuleInterface> GetInterface();

void ExecuteFunction(const std::string& name);
Expand Down Expand Up @@ -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<hArgs> &args, const std::string &event_name, const std::string &module_name, void (*callback)(std::shared_ptr<hArgs> _args));
void CallInputEvent(const std::shared_ptr<hArgs> &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<ModuleInterface> GetEditorModuleByName(const std::string& name);

Expand Down
80 changes: 6 additions & 74 deletions main/src/modules/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,74 +214,6 @@ void ModuleInterface::AddFunction(std::function<void(ArgumentValues &, ReturnVal
this->m_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<hArgs> &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<ModuleInputEvent> p_event = std::make_shared<ModuleInputEvent>(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<hArgs> &args), const std::string &name, DevFlag devflag, const std::string &description, const std::vector<std::tuple<std::string, std::string, std::string>> &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<ModuleInputEvent> p_event = std::make_shared<ModuleInputEvent>(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<hArgs> &args), const std::string &name)
{
// Create a shared_ptr to the ModuleOutputEvent
std::shared_ptr<ModuleOutputEvent> p_event = std::make_shared<ModuleOutputEvent>(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.
*
Expand Down Expand Up @@ -705,14 +637,14 @@ void ModuleInterface::Stop()
}
}

void ModuleInterface::CallInputEvent(const std::shared_ptr<hArgs> &args, const std::string &event_name, const std::string &module_name, void (*callback)(std::shared_ptr<hArgs> _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<hArgs> &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()
Expand Down

0 comments on commit 909ab44

Please sign in to comment.