Coverage Report

Created: 2025-09-03 03:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/nix/store/i1aar97n7b4yf8rk94p66if25brfvvdx-gqvzl8a5pvrg3xj44q0msrndcripi8dk-source/src/controllers/controllermanager.cc
Line
Count
Source
1
#include "controllers/controllermanager.h"
2
3
#include <map>
4
#include <memory>
5
#include <string>
6
#include <utility>
7
#include <vector>
8
9
namespace mahjong {
10
class PlayerController;
11
12
0
std::vector<std::string> ControllerManager::GetAvailableControllers() {
13
0
  std::vector<std::string> names;
14
0
  names.reserve(available_controllers_.size());
15
0
  for (const auto& [name, _] : available_controllers_) {
16
0
    names.push_back(name);
17
0
  }
18
0
  return names;
19
0
}
20
21
std::unique_ptr<mahjong::PlayerController> ControllerManager::NewController(
22
28
    const std::string& controller) {
23
28
  if (available_controllers_.contains(controller)) {
24
28
    return available_controllers_[controller]();
25
28
  }
26
0
  throw "No Such Controller";
27
28
}
28
29
bool ControllerManager::RegisterController(newControllerInst newFunc,
30
1.09k
                                           const std::string& name) {
31
1.09k
  if (available_controllers_.contains(name)) {
32
0
    return false;
33
0
  }
34
1.09k
  available_controllers_[name] = std::move(newFunc);
35
1.09k
  return true;
36
1.09k
}
37
38
}  // namespace mahjong