-
Notifications
You must be signed in to change notification settings - Fork 355
Expand file tree
/
Copy pathProcessorBase.cpp
More file actions
44 lines (37 loc) · 1.23 KB
/
ProcessorBase.cpp
File metadata and controls
44 lines (37 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* 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 = PREP_DIR "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)
{
// 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;
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);
}
}