Exemplo n.º 1
0
static void
AddProcessAfterState(StateModel& statemodel, const Process::ProcessModel& proc)
{
  ProcessStateDataInterface* state = proc.startStateData();
  if (!state)
    return;

  auto next_proc_fun = [&](const State::MessageList& ml) {
    auto& messages = statemodel.messages();

    for (const ProcessStateWrapper& prev_proc : statemodel.previousProcesses())
    {
      prev_proc.process().setMessages(ml, messages.rootNode());
    }

    updateTreeWithMessageList(
        messages.rootNode(), ml, proc.id(), ProcessPosition::Following);
    statemodel.sig_statesUpdated();
  };

  statemodel.followingProcesses().emplace_back(state);
  auto& wrapper = statemodel.followingProcesses().back();
  QObject::connect(
      state,
      &ProcessStateDataInterface::messagesChanged,
      &wrapper,
      next_proc_fun);

  next_proc_fun(state->messages());
}
Exemplo n.º 2
0
static void RemoveProcessAfterState(
    StateModel& statemodel,
    const Process::ProcessModel& proc)
{
  ProcessStateDataInterface* state = proc.startStateData();
  if (!state)
    return;

  auto it
      = ossia::find_if(statemodel.followingProcesses(), [&](const auto& elt) {
          return state == &elt.process();
        });

  updateTreeWithRemovedProcess(
      statemodel.messages().rootNode(), proc.id(), ProcessPosition::Following);
  statemodel.sig_statesUpdated();

  // TODO debug the need for this check
  if (it != statemodel.followingProcesses().end())
    statemodel.followingProcesses().erase(it);
}