Pakman
AbstractMasterStatic.cc
1 #include <string>
2 
3 #include "core/common.h"
4 #include "core/LongOptions.h"
5 #include "core/Arguments.h"
6 #include "core/Command.h"
7 
8 #include "SerialMaster.h"
9 #include "MPIMaster.h"
10 
11 #include "AbstractMaster.h"
12 
13 // Return master type based on string
14 master_t AbstractMaster::getMaster(const std::string& arg)
15 {
16  // Check for serial master
17  if (arg.compare("serial") == 0)
18  return serial;
19 
20  // Check for mpi master
21  else if (arg.compare("mpi") == 0)
22  return mpi;
23 
24  // Else return no_master
25  return no_master;
26 }
27 
28 std::string AbstractMaster::help(master_t master)
29 {
30  switch (master)
31  {
32  case serial:
33  return SerialMaster::help();
34  case mpi:
35  return MPIMaster::help();
36  default:
37  throw std::runtime_error(
38  "Invalid master type in "
39  "AbstractMaster::help");
40  }
41 }
42 
44  LongOptions& lopts)
45 {
46  switch (master)
47  {
48  case serial:
50  return;
51  case mpi:
53  return;
54  default:
55  throw std::runtime_error(
56  "Invalid master type in "
57  "AbstractMaster::run");
58  }
59 }
60 
61 void AbstractMaster::run(master_t master, controller_t controller,
62  const Arguments& args)
63 {
64  switch (master)
65  {
66  case serial:
67  SerialMaster::run(controller, args);
68  return;
69  case mpi:
70  MPIMaster::run(controller, args);
71  return;
72  default:
73  throw std::runtime_error(
74  "Invalid master type in "
75  "AbstractMaster::run");
76  }
77 }
78 
80 {
81  switch (master)
82  {
83  case serial:
85  return;
86  case mpi:
88  return;
89  default:
90  throw std::runtime_error(
91  "Invalid master type in "
92  "AbstractMaster::cleanup");
93  }
94 }
static void run(controller_t controller, const Arguments &args)
static void cleanup()
static void cleanup(master_t master)
controller_t
Definition: common.h:45
static void run(master_t master, controller_t controller, const Arguments &args)
master_t
Definition: common.h:37
static void addLongOptions(LongOptions &lopts)
static void addLongOptions(master_t master, LongOptions &lopts)
static void run(controller_t controller, const Arguments &args)
static void cleanup()
static std::string help()
static master_t getMaster(const std::string &arg)
static std::string help()
static void addLongOptions(LongOptions &lopts)
static std::string help(master_t master)