Pakman
SerialMasterStatic.cc
1 #include <string>
2 #include <memory>
3 
4 #include <getopt.h>
5 
6 #include "core/common.h"
7 #include "core/Arguments.h"
8 #include "core/LongOptions.h"
9 #include "core/Command.h"
10 #include "system/signal_handler.h"
11 #include "system/debug.h"
12 #include "controller/AbstractController.h"
13 
14 #include "SerialMaster.h"
15 
16 // Static help function
17 std::string SerialMaster::help()
18 {
19  return
20 R"(* Help message for 'serial' master *
21 
22 Description:
23  When using a serial master, pakman executes simulations sequentially. It is
24  assumed that the simulator is a standard simulator, which means that it
25  communicates with pakman through its stdin and stdout.
26 )";
27 }
28 
30 {
31  // No SerialMaster-specific options to add
32 }
33 
34 // Static run function
35 void SerialMaster::run(controller_t controller, const Arguments& args)
36 {
37  // Set signal handlers
38  set_handlers();
39  set_signal_handler();
40 
41  // Create controller and SerialMaster
42  std::shared_ptr<AbstractController>
43  p_controller(AbstractController::makeController(controller, args));
44 
45  auto p_master =
46  std::make_shared<SerialMaster>(p_controller->getSimulator(),
48 
49  // Associate with each other
50  p_master->assignController(p_controller);
51  p_controller->assignMaster(p_master);
52 
53  // Start event loop
54  while (p_master->isActive())
55  {
56  p_master->iterate();
57  }
58 
59  // Destroy Master and Controller
60  p_master.reset();
61  p_controller.reset();
62 }
63 
64 // Static cleanup function
66 {
67 }
static void run(controller_t controller, const Arguments &args)
controller_t
Definition: common.h:45
bool g_program_terminated
Definition: main.cc:32
static void addLongOptions(LongOptions &lopts)
static void cleanup()
static std::string help()
static AbstractController * makeController(controller_t controller, const Arguments &args)