mirror of
https://github.com/data61/MP-SPDZ.git
synced 2026-01-08 05:03:59 -05:00
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
/*
|
|
* ProcessorBase.cpp
|
|
*
|
|
*/
|
|
|
|
#include "ProcessorBase.hpp"
|
|
|
|
ProcessorBase::ProcessorBase() :
|
|
input_counter(0), arg(0)
|
|
{
|
|
}
|
|
|
|
string ProcessorBase::get_parameterized_filename(int my_num, int thread_num, const string& prefix)
|
|
{
|
|
string filename = prefix + "-P" + to_string(my_num) + "-" + to_string(thread_num);
|
|
return filename;
|
|
}
|
|
|
|
void ProcessorBase::open_input_file(int my_num, int thread_num,
|
|
const string& prefix)
|
|
{
|
|
string tmp = prefix;
|
|
if (prefix.empty())
|
|
tmp = "Player-Data/Input";
|
|
|
|
open_input_file(get_parameterized_filename(my_num, thread_num, tmp));
|
|
}
|
|
|
|
void ProcessorBase::setup_redirection(int my_num, int thread_num,
|
|
OnlineOptions& opts, SwitchableOutput& out, bool real)
|
|
{
|
|
// only output on party 0 if not interactive
|
|
bool always_stdout = opts.cmd_private_output_file == ".";
|
|
bool output = my_num == 0 or opts.interactive or always_stdout;
|
|
output &= real or always_stdout;
|
|
out.activate(output);
|
|
|
|
if (not (opts.cmd_private_output_file.empty() or always_stdout))
|
|
{
|
|
const string stdout_filename = get_parameterized_filename(my_num,
|
|
thread_num, opts.cmd_private_output_file);
|
|
stdout_redirect_file.open(stdout_filename.c_str(), ios_base::out);
|
|
out.redirect_to_file(stdout_redirect_file);
|
|
}
|
|
}
|