コード例 #1
0
ファイル: VSTControl.cpp プロジェクト: OSSIA/Score
bool VSTControlPortItem::on_createAutomation(
    Scenario::IntervalModel& cst,
    std::function<void(score::Command*)> macro,
    const score::DocumentContext& ctx)
{
  auto make_cmd = new Scenario::Command::AddOnlyProcessToInterval{
      cst, Metadata<ConcreteKey_k, Automation::ProcessModel>::get(), {}};
  macro(make_cmd);

  auto lay_cmd
      = new Scenario::Command::AddLayerInNewSlot{cst, make_cmd->processId()};
  macro(lay_cmd);

  auto& autom = safe_cast<Automation::ProcessModel&>(
      cst.processes.at(make_cmd->processId()));
  macro(new Automation::SetMin{autom, 0.});
  macro(new Automation::SetMax{autom, 1.});

  auto& plug = ctx.model<Scenario::ScenarioDocumentModel>();
  Process::CableData cd;
  cd.type = Process::CableType::ImmediateGlutton;
  cd.source = *autom.outlet;
  cd.sink = port();

  macro(new Dataflow::CreateCable{
      plug, getStrongId(plug.cables), std::move(cd)});
  return true;
}
コード例 #2
0
/*
 * Protocol
 *
 * From clients:
 * Direction: "O2Up", 2 - id, Up - orientation (Up, Down, Left, Right)
 *
 * From server:
 * Timer: "T"
 * Id: "I5", 5 - id number
 * Dimensions: "D 15 20", 15 - width, 20 - height
 * Snakes: "S1 2 4 2 5 2 6; S2 3 10 3 11 3 12", 1 - client id, 2 4 - points x y in snake
 * GameStatus: "G1" - game over, 1 - loser
 * Food: "F 2 4 5 6"
 * Scores: "C1 5 C2 10", 1 - id
 *
 */
void Parser::process(const QString &t_message) const
{
    if (t_message.isEmpty())
        return;

    auto ch = t_message[0];
    auto rightStr = t_message.right(t_message.size() - 1);
    if (ch == 'I')
        processId(rightStr);
    else if (ch == 'O')
        processDirection(rightStr);
    else if (ch == 'D')
        processDimensions(rightStr);
    else if (ch == 'F')
        processFood(rightStr);
    else if (ch == 'S')
        processSnakes(t_message);
    else if (ch == 'G')
        processGameOver(rightStr);
    else if (ch == 'C')
        processScores(t_message);
    else if (ch == 'R')
        emit restartSignal();
}
コード例 #3
0
ファイル: processhandle.cpp プロジェクト: sakazuki/actiona
	int ProcessHandle::id() const
	{
        return processId();
    }
コード例 #4
0
ファイル: processhandle.cpp プロジェクト: sakazuki/actiona
	QString ProcessHandle::toString() const
	{
        return QString("ProcessHandle {id: %1}").arg(processId());
	}
コード例 #5
0
void ScenarioContextMenuManager::createSlotContextMenu(
        const iscore::DocumentContext& ctx,
        QMenu& menu,
        const SlotPresenter& slotp)
{
    auto& slotm = slotp.model();

    // First changing the process in the current slot
    auto processes_submenu = menu.addMenu(tr("Focus process in this slot"));
    for(const LayerModel& proc : slotm.layers)
    {
        QAction* procAct = new QAction{
                           proc.processModel().prettyName(),
                           processes_submenu};
        QObject::connect(procAct, &QAction::triggered, [&] () {
            PutLayerModelToFront cmd{slotm, proc.id()};
            cmd.redo();
        } );
        processes_submenu->addAction(procAct);
    }

    // Then creation of a new slot with existing processes
    auto new_processes_submenu = menu.addMenu(tr("Show process in new slot"));
    for(const LayerModel& proc : slotm.layers)
    {
        QAction* procAct = new QAction{
                           proc.processModel().prettyName(),
                           new_processes_submenu};
        QObject::connect(procAct, &QAction::triggered, [&] () {
            auto cmd = new Scenario::Command::AddLayerInNewSlot{
                       slotm.parentConstraint(),
                       proc.processModel().id()};
            CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd);
        } );
        new_processes_submenu->addAction(procAct);
    }

    // Then removal of slot
    auto removeSlotAct = new QAction{tr("Remove this slot"), nullptr};
    QObject::connect(removeSlotAct, &QAction::triggered, [&] () {
        auto cmd = new Scenario::Command::RemoveSlotFromRack{slotm};
        CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd);
    });
    menu.addAction(removeSlotAct);

    menu.addSeparator();

    // Then Add process in this slot
    auto existing_processes_submenu = menu.addMenu(tr("Add existing process in this slot"));
    for(const Process& proc : slotm.parentConstraint().processes)
    {
        // OPTIMIZEME by filtering before.
        if(std::none_of(slotm.layers.begin(), slotm.layers.end(), [&] (const LayerModel& layer) {
                        return &layer.processModel() == &proc;
    }))
        {
            QAction* procAct = new QAction{proc.prettyName(), existing_processes_submenu};
            QObject::connect(procAct, &QAction::triggered, [&] () {

                auto cmd2 = new Scenario::Command::AddLayerModelToSlot{
                            slotm,
                            proc};
                CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd2);
            } );
            existing_processes_submenu->addAction(procAct);
        }
    }

    auto addNewProcessInExistingSlot = new QAction{tr("Add new process in this slot"), &menu};
    QObject::connect(addNewProcessInExistingSlot, &QAction::triggered,
            [&] () {
        auto& fact = ctx.app.components.factory<DynamicProcessList>();
        AddProcessDialog dialog{fact, qApp->activeWindow()};

        QObject::connect(&dialog, &AddProcessDialog::okPressed,
            [&] (const auto& proc) {
            auto& constraint = slotm.parentConstraint();
            QuietMacroCommandDispatcher disp{
                new CreateProcessInExistingSlot,
                        ctx.commandStack};

            auto cmd1 = new AddOnlyProcessToConstraint{constraint, proc};
            cmd1->redo();
            disp.submitCommand(cmd1);

            auto cmd2 = new Scenario::Command::AddLayerModelToSlot{
                        slotm,
                        constraint.processes.at(cmd1->processId())};
            cmd2->redo();
            disp.submitCommand(cmd2);

            disp.commit();
        });

        dialog.launchWindow();
    });
    menu.addAction(addNewProcessInExistingSlot);

    // Then Add process in a new slot
    auto addNewProcessInNewSlot = new QAction{tr("Add process in a new slot"), &menu};
    QObject::connect(addNewProcessInNewSlot, &QAction::triggered,
            [&] () {
        auto& fact = ctx.app.components.factory<DynamicProcessList>();
        AddProcessDialog dialog{fact, qApp->activeWindow()};

        QObject::connect(&dialog, &AddProcessDialog::okPressed,
            [&] (const auto& proc) {
            auto& constraint = slotm.parentConstraint();
            QuietMacroCommandDispatcher disp{
                new CreateProcessInNewSlot,
                        ctx.commandStack};

            auto cmd1 = new AddOnlyProcessToConstraint{constraint, proc};
            cmd1->redo();
            disp.submitCommand(cmd1);

            auto& rack = slotm.rack();
            auto cmd2 = new Scenario::Command::AddSlotToRack{rack};
            cmd2->redo();
            disp.submitCommand(cmd2);

            auto cmd3 = new Scenario::Command::AddLayerModelToSlot{
                        rack.slotmodels.at(cmd2->createdSlot()),
                        constraint.processes.at(cmd1->processId())};
            cmd3->redo();
            disp.submitCommand(cmd3);

            disp.commit();
        });

        dialog.launchWindow();
    });
    menu.addAction(addNewProcessInNewSlot);

    menu.addSeparator();
}
コード例 #6
0
void LipstickCompositorWindow::killProcess()
{
    kill(processId(), SIGKILL);
}
コード例 #7
0
void LipstickCompositorWindow::terminateProcess(int killTimeout)
{
    kill(processId(), SIGTERM);

    QTimer::singleShot(killTimeout, this, SLOT(killProcess()));
}