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

sfc-aqua / quisp / 4336246632

pending completion
4336246632

Pull #515

github

GitHub
Merge 30f7f6fc1 into 726f00e65
Pull Request #515: Add ComponentProvider::getNodeAddr

23 of 23 new or added lines in 12 files covered. (100.0%)

2285 of 5761 relevant lines covered (39.66%)

47304.13 hits per line

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

0.0
/quisp/utils/DefaultComponentProviderStrategy.cc
1
#include <omnetpp.h>
2

3
#include "DefaultComponentProviderStrategy.h"
4

5
namespace quisp::utils {
6

7
DefaultComponentProviderStrategy::DefaultComponentProviderStrategy(cModule *_self) : self(_self) {}
×
8

9
cModule *DefaultComponentProviderStrategy::getQNode() {
×
10
  cModule *currentModule = self->getParentModule();
×
11
  while (currentModule->getModuleType() != QNodeType) {
×
12
    currentModule = currentModule->getParentModule();
×
13
    if (currentModule == nullptr) {
×
14
      throw cRuntimeError("QNode module not found. Have you changed the type name in ned file?");
×
15
    }
×
16
  }
×
17
  return currentModule;
×
18
}
×
19

20
cModule *DefaultComponentProviderStrategy::getNode() {
×
21
  cModule *currentModule = self->getParentModule();
×
22
  auto *mod_type = currentModule->getModuleType();
×
23
  while (mod_type != QNodeType && mod_type != BSAType && mod_type != SPDCType) {
×
24
    currentModule = currentModule->getParentModule();
×
25
    mod_type = currentModule->getModuleType();
×
26
    if (currentModule == nullptr) {
×
27
      throw cRuntimeError("Node module not found. Have you changed the type name in ned file?");
×
28
    }
×
29
  }
×
30
  return currentModule;
×
31
}
×
32

33
int DefaultComponentProviderStrategy::getNodeAddr() { return getNode()->par("address"); }
×
34

35
cModule *DefaultComponentProviderStrategy::getNeighborNode(cModule *qnic) {
×
36
  if (qnic == nullptr) throw cRuntimeError("failed to get neighbor node. given qnic is nullptr");
×
37
  auto *neighbor_node = qnic->gate("qnic_quantum_port$o")->getNextGate()->getNextGate()->getOwnerModule();
×
38
  if (neighbor_node == nullptr) throw cRuntimeError("failed to get neighbor node. neighbor node is nullptr");
×
39
  return neighbor_node;
×
40
}
×
41

42
IStationaryQubit *DefaultComponentProviderStrategy::getStationaryQubit(int qnic_index, int qubit_index, QNIC_type qnic_type) {
×
43
  auto *qnic = getQNIC(qnic_index, qnic_type);
×
44
  if (qnic == nullptr) {
×
45
    throw cRuntimeError("QNIC not found. index: %d, type: %d", qnic_index, qnic_type);
×
46
  }
×
47
  auto *qubit = qnic->getSubmodule("statQubit", qubit_index);
×
48
  auto *casted_qubit = dynamic_cast<IStationaryQubit *>(qubit);
×
49
  if (casted_qubit == nullptr) {
×
50
    throw cRuntimeError("FAIL TO CAST QUBITS qubit index %d", qubit_index);
×
51
  }
×
52
  return check_and_cast<IStationaryQubit *>(qubit);
×
53
}
×
54

55
cModule *DefaultComponentProviderStrategy::getQNIC(int qnic_index, QNIC_type qnic_type) {
×
56
  if (qnic_type > QNIC_N) {
×
57
    throw cRuntimeError("got invalid qnic type: %d", qnic_type);
×
58
  }
×
59
  auto qnode = getQNode();
×
60
  return qnode->getSubmodule(QNIC_names[qnic_type], qnic_index);
×
61
}
×
62
int DefaultComponentProviderStrategy::getNumQubits(int qnic_index, QNIC_type qnic_type) {
×
63
  auto *qnic = getQNIC(qnic_index, qnic_type);
×
64
  if (qnic == nullptr) {
×
65
    throw cRuntimeError("DefaultComponentProviderStrategy::getNumQubits: QNIC not found. index: %d, type: %d", qnic_index, qnic_type);
×
66
  }
×
67
  return qnic->par("num_buffer").intValue();
×
68
}
×
69

70
IRoutingDaemon *DefaultComponentProviderStrategy::getRoutingDaemon() {
×
71
  auto *qrsa = getQRSA();
×
72
  return check_and_cast<IRoutingDaemon *>(qrsa->getSubmodule("rd"));
×
73
}
×
74
IHardwareMonitor *DefaultComponentProviderStrategy::getHardwareMonitor() {
×
75
  auto *qrsa = getQRSA();
×
76
  return check_and_cast<IHardwareMonitor *>(qrsa->getSubmodule("hm"));
×
77
}
×
78
modules::IRealTimeController *DefaultComponentProviderStrategy::getRealTimeController() {
×
79
  auto *qrsa = getQRSA();
×
80
  return check_and_cast<IRealTimeController *>(qrsa->getSubmodule("rt"));
×
81
}
×
82
IQuantumBackend *DefaultComponentProviderStrategy::getQuantumBackend() {
×
83
  cModule *currentModule = self->getParentModule();
×
84
  auto *mod = currentModule->findModuleByPath("backend");
×
85
  if (mod == nullptr) {
×
86
    throw cRuntimeError("Quantum backend not found");
×
87
  }
×
88
  auto *backend_container = check_and_cast<BackendContainer *>(mod);
×
89
  return backend_container->getQuantumBackend();
×
90
}
×
91

92
ILogger *DefaultComponentProviderStrategy::getLogger() {
×
93
  auto *qnode = getQNode();
×
94
  auto *mod = qnode->findModuleByPath("logger");
×
95
  if (mod == nullptr) {
×
96
    throw cRuntimeError("LoggerModule not found");
×
97
  }
×
98
  auto *logger_module = check_and_cast<LoggerModule *>(mod);
×
99
  return logger_module->getLogger();
×
100
}
×
101

102
cModule *DefaultComponentProviderStrategy::getQRSA() {
×
103
  auto *qnode = getQNode();
×
104
  auto *qrsa = qnode->getSubmodule("qrsa");
×
105
  if (qrsa == nullptr) {
×
106
    throw cRuntimeError("QRSA module not found.");
×
107
  }
×
108
  return qrsa;
×
109
}
×
110

111
bool DefaultComponentProviderStrategy::isBSANodeType(const cModuleType *const type) { return type == BSAType; }
×
112
bool DefaultComponentProviderStrategy::isQNodeType(const cModuleType *const type) { return type == QNodeType; }
×
113
bool DefaultComponentProviderStrategy::isSPDCNodeType(const cModuleType *const type) { return type == SPDCType; }
×
114
}  // 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