예제 #1
0
void Process::setEnvironment(const ProcessEnvironment &e)
{
    QProcessEnvironment qpenv;
    for (ProcessEnvironment::const_iterator it = e.constBegin(); it != e.constEnd(); ++it)
        qpenv.insert(it.key().toQString(), it.value());
    QProcess::setProcessEnvironment(qpenv);
}
예제 #2
0
ProcessEnvironment Process::environment() const
{
    ProcessEnvironment env;
    const QProcessEnvironment qpenv = QProcess::processEnvironment();
    foreach (const QString &key, qpenv.keys())
        env.insert(key, qpenv.value(key));
    return env;
}
void PartitionedPostMaster::SendMessage(Event const & event) {
    assert(engine_map_.find(event.target_process_id()) != engine_map_.end());

    // Register the event with the input queue of the |ProcessEnvironment| hosted
    // in the appropriate engine.
    ProcessEnvironment* env =
        engine_map_[event.target_process_id()]->environment();
    env->event_queue().RegisterEvent(event);
}
예제 #4
0
void PartitionedTopologyBuilder::BuildOutputPartition(SimulationEngine* engine) {
  ProcessEnvironment* env = engine->environment();
  int id = 100;

  end_cap_ = new ConsumerProcess(id);
  end_cap_->set_name("End Cap");
  env->RegisterLogicalProcess(end_cap_);
  post_master_->RegisterRemoteLP(end_cap_->id(), engine);
  Logger* logger_end =
      new Logger(InitOutputStream(end_cap_->name().c_str()));
  end_cap_->set_logger(logger_end);
  log_manager_.RegisterLogger(logger_end);
}
예제 #5
0
void PartitionedTopologyBuilder::BuildInputPartition(SimulationEngine* engine) {
  ProcessEnvironment* env = engine->environment();

  int id = 0;
  RandomConstant<1> random;
  input_1_ = new GeneratorProcess(++id, &random);
  input_1_->set_name("Input 1");
  env->RegisterLogicalProcess(input_1_);
  post_master_->RegisterRemoteLP(input_1_->id(), engine);
  Logger* logger_1 = new Logger(InitOutputStream(input_1_->name().c_str()));
  input_1_->set_logger(logger_1);
  log_manager_.RegisterLogger(logger_1);


  input_2_ = new GeneratorProcess(++id, &random);
  input_2_->set_name("Input 2");
  env->RegisterLogicalProcess(input_2_);
  post_master_->RegisterRemoteLP(input_2_->id(), engine);
  Logger* logger_2 = new Logger(InitOutputStream(input_2_->name().c_str()));
  input_2_->set_logger(logger_2);
  log_manager_.RegisterLogger(logger_2);

  middle_pipe_ = new PipelineProcess(++id, &random);
  middle_pipe_->set_name("Middle Pipe");
  env->RegisterLogicalProcess(middle_pipe_);
  post_master_->RegisterRemoteLP(middle_pipe_->id(), engine);
  Logger* logger_m =
      new Logger(InitOutputStream(middle_pipe_->name().c_str()));
  middle_pipe_->set_logger(logger_m);
  log_manager_.RegisterLogger(logger_m);


  input_1_->set_target(middle_pipe_->id());
  input_1_->set_count(20000);

  input_2_->set_target(middle_pipe_->id());
  input_2_->set_count(20000);

  middle_pipe_->set_target(100);
}
static void readEnvironment(const ProcessEnvironment &environment, MacroTable *macroTable, bool forceReadOnly)
{
    ProcessEnvironment::const_iterator it = environment.begin();
    for (; it != environment.end(); ++it)
        macroTable->defineEnvironmentMacroValue(it.key().toQString(), it.value(), forceReadOnly);
}
예제 #7
0
static QByteArray createEnvBlock(const ProcessEnvironment &environment)
{
    QByteArray envlist;
    if (!environment.isEmpty()) {
        ProcessEnvironment copy = environment;

        const QString pathKey(QLatin1String("Path"));
        if (copy.contains(pathKey)) {
            // PATH has been altered.
            // It must be set in this environment to start the correct executable.
            // ### Note that this doesn't work if a batch file is supposed to shadow an exe or com.
            if (!qSetEnvironmentVariable(pathKey, environment.value(pathKey)))
                qWarning("jom: setting PATH failed");
        } else {
            // add PATH (for DLL loading)
            QString path = qGetEnvironmentVariable(L"PATH");
            if (!path.isEmpty())
                copy.insert(pathKey, path);
        }

        // add systemroot if needed
        const ProcessEnvironmentKey rootKey(QLatin1String("SystemRoot"));
        if (!copy.contains(rootKey)) {
            QString systemRoot = qGetEnvironmentVariable(L"SystemRoot");
            if (!systemRoot.isEmpty())
                copy.insert(rootKey, systemRoot);
        }

        int pos = 0;
        ProcessEnvironment::const_iterator it = copy.constBegin();
        const ProcessEnvironment::const_iterator end = copy.constEnd();

        static const wchar_t equal = L'=';
        static const wchar_t nul = L'\0';

        for ( ; it != end; ++it) {
            const QString &keystr = it.key().toQString();
            uint tmpSize = sizeof(wchar_t) * (keystr.length() + it.value().length() + 2);
            // ignore empty strings
            if (tmpSize == sizeof(wchar_t) * 2)
                continue;
            envlist.resize(envlist.size() + tmpSize);

            tmpSize = keystr.length() * sizeof(wchar_t);
            memcpy(envlist.data() + pos, keystr.utf16(), tmpSize);
            pos += tmpSize;

            memcpy(envlist.data()+pos, &equal, sizeof(wchar_t));
            pos += sizeof(wchar_t);

            tmpSize = it.value().length() * sizeof(wchar_t);
            memcpy(envlist.data()+pos, it.value().utf16(), tmpSize);
            pos += tmpSize;

            memcpy(envlist.data()+pos, &nul, sizeof(wchar_t));
            pos += sizeof(wchar_t);
        }
        // add the 2 terminating 0 (actually 4, just to be on the safe side)
        envlist.resize( envlist.size()+4 );
        envlist[pos++] = 0;
        envlist[pos++] = 0;
        envlist[pos++] = 0;
        envlist[pos++] = 0;
    }
    return envlist;
}