• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sfc-aqua / quisp / 4175941712

pending completion
4175941712

push

github

GitHub
Merge pull request #492 from sfc-aqua/backend-cleanup

187 of 187 new or added lines in 16 files covered. (100.0%)

2582 of 5597 relevant lines covered (46.13%)

48697.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/quisp/utils/DefaultComponentProviderStrategy.cc
1
#include "DefaultComponentProviderStrategy.h"
2
#include "modules/QNIC/StationaryQubit/IStationaryQubit.h"
3
#include "modules/QRSA/HardwareMonitor/HardwareMonitor.h"
4
#include "modules/QRSA/RealTimeController/IRealTimeController.h"
5
#include "modules/QRSA/RoutingDaemon/RoutingDaemon.h"
6
#include "omnetpp/cexception.h"
7
#include "omnetpp/cmodule.h"
8
#include "utils/utils.h"
9

10
namespace quisp::utils {
11

12
DefaultComponentProviderStrategy::DefaultComponentProviderStrategy(cModule *_self) : self(_self) {}
×
13

14
cModule *DefaultComponentProviderStrategy::getQNode() {
×
15
  cModule *currentModule = self->getParentModule();
×
16
  while (currentModule->getModuleType() != QNodeType) {
×
17
    currentModule = currentModule->getParentModule();
×
18
    if (currentModule == nullptr) {
×
19
      throw cRuntimeError("QNode module not found. Have you changed the type name in ned file?");
×
20
    }
×
21
  }
×
22
  return currentModule;
×
23
}
×
24
cModule *DefaultComponentProviderStrategy::getNeighborNode(cModule *qnic) {
×
25
  if (qnic == nullptr) throw cRuntimeError("failed to get neighbor node. given qnic is nullptr");
×
26
  auto *neighbor_node = qnic->gate("qnic_quantum_port$o")->getNextGate()->getNextGate()->getOwnerModule();
×
27
  if (neighbor_node == nullptr) throw cRuntimeError("failed to get neighbor node. neighbor node is nullptr");
×
28
  return neighbor_node;
×
29
}
×
30

31
IStationaryQubit *DefaultComponentProviderStrategy::getStationaryQubit(int qnic_index, int qubit_index, QNIC_type qnic_type) {
×
32
  auto *qnic = getQNIC(qnic_index, qnic_type);
×
33
  if (qnic == nullptr) {
×
34
    throw cRuntimeError("QNIC not found. index: %d, type: %d", qnic_index, qnic_type);
×
35
  }
×
36
  auto *qubit = qnic->getSubmodule("statQubit", qubit_index);
×
37
  auto *casted_qubit = dynamic_cast<IStationaryQubit *>(qubit);
×
38
  if (casted_qubit == nullptr) {
×
39
    throw cRuntimeError("FAIL TO CAST QUBITS qubit index %d", qubit_index);
×
40
  }
×
41
  return check_and_cast<IStationaryQubit *>(qubit);
×
42
}
×
43

44
cModule *DefaultComponentProviderStrategy::getQNIC(int qnic_index, QNIC_type qnic_type) {
×
45
  if (qnic_type > QNIC_N) {
×
46
    throw cRuntimeError("got invalid qnic type: %d", qnic_type);
×
47
  }
×
48
  auto qnode = getQNode();
×
49
  return qnode->getSubmodule(QNIC_names[qnic_type], qnic_index);
×
50
}
×
51
int DefaultComponentProviderStrategy::getNumQubits(int qnic_index, QNIC_type qnic_type) {
×
52
  auto *qnic = getQNIC(qnic_index, qnic_type);
×
53
  if (qnic == nullptr) {
×
54
    throw cRuntimeError("DefaultComponentProviderStrategy::getNumQubits: QNIC not found. index: %d, type: %d", qnic_index, qnic_type);
×
55
  }
×
56
  return qnic->par("num_buffer").intValue();
×
57
}
×
58

59
IRoutingDaemon *DefaultComponentProviderStrategy::getRoutingDaemon() {
×
60
  auto *qrsa = getQRSA();
×
61
  return check_and_cast<IRoutingDaemon *>(qrsa->getSubmodule("rd"));
×
62
}
×
63
IHardwareMonitor *DefaultComponentProviderStrategy::getHardwareMonitor() {
×
64
  auto *qrsa = getQRSA();
×
65
  return check_and_cast<IHardwareMonitor *>(qrsa->getSubmodule("hm"));
×
66
}
×
67
modules::IRealTimeController *DefaultComponentProviderStrategy::getRealTimeController() {
×
68
  auto *qrsa = getQRSA();
×
69
  return check_and_cast<IRealTimeController *>(qrsa->getSubmodule("rt"));
×
70
}
×
71
IQuantumBackend *DefaultComponentProviderStrategy::getQuantumBackend() {
×
72
  cModule *currentModule = self->getParentModule();
×
73
  auto *mod = currentModule->findModuleByPath("backend");
×
74
  if (mod == nullptr) {
×
75
    throw cRuntimeError("Quantum backend not found");
×
76
  }
×
77
  auto *backend_container = check_and_cast<BackendContainer *>(mod);
×
78
  return backend_container->getQuantumBackend();
×
79
}
×
80

81
ILogger *DefaultComponentProviderStrategy::getLogger() {
×
82
  auto *qnode = getQNode();
×
83
  auto *mod = qnode->findModuleByPath("logger");
×
84
  if (mod == nullptr) {
×
85
    throw cRuntimeError("LoggerModule not found");
×
86
  }
×
87
  auto *logger_module = check_and_cast<LoggerModule *>(mod);
×
88
  return logger_module->getLogger();
×
89
}
×
90

91
cModule *DefaultComponentProviderStrategy::getQRSA() {
×
92
  auto *qnode = getQNode();
×
93
  auto *qrsa = qnode->getSubmodule("qrsa");
×
94
  if (qrsa == nullptr) {
×
95
    throw cRuntimeError("QRSA module not found.");
×
96
  }
×
97
  return qrsa;
×
98
}
×
99

100
bool DefaultComponentProviderStrategy::isBSANodeType(const cModuleType *const type) { return type == BSAType; }
×
101
bool DefaultComponentProviderStrategy::isQNodeType(const cModuleType *const type) { return type == QNodeType; }
×
102
bool DefaultComponentProviderStrategy::isSPDCNodeType(const cModuleType *const type) { return type == SPDCType; }
×
103
}  // namespace quisp::utils
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc