Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | // Copyright 2019-2022 Cambridge Quantum Computing | |||
2 | // | |||
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |||
4 | // you may not use this file except in compliance with the License. | |||
5 | // You may obtain a copy of the License at | |||
6 | // | |||
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |||
8 | // | |||
9 | // Unless required by applicable law or agreed to in writing, software | |||
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |||
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
12 | // See the License for the specific language governing permissions and | |||
13 | // limitations under the License. | |||
14 | ||||
15 | #include "Mapping/RoutingMethodJson.hpp" | |||
16 | ||||
17 | #include "Mapping/LexiLabelling.hpp" | |||
18 | ||||
19 | namespace tket { | |||
20 | ||||
21 | 70 | void to_json(nlohmann::json& j, const RoutingMethod& rm) { j = rm.serialize(); } | ||
22 | ||||
23 | 1 | void from_json(const nlohmann::json& /*j*/, RoutingMethod& rm) { | ||
24 | 1 | rm = RoutingMethod(); | ||
25 | 1 | } | ||
26 | ||||
27 | 34 | void to_json(nlohmann::json& j, const std::vector<RoutingMethodPtr>& rmp_v) { | ||
28 |
2/2✓ Branch 4 taken 67 times.
✓ Branch 5 taken 34 times.
|
2/2✓ Decision 'true' taken 67 times.
✓ Decision 'false' taken 34 times.
|
101 | for (const auto& r : rmp_v) { |
29 |
2/4✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 67 times.
✗ Branch 6 not taken.
|
67 | j.push_back(*r); | |
30 | } | |||
31 | 34 | } | ||
32 | ||||
33 | 8 | void from_json(const nlohmann::json& j, std::vector<RoutingMethodPtr>& rmp_v) { | ||
34 |
5/8✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 17 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 25 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 17 times.
✓ Branch 12 taken 8 times.
|
0/1? Decision couldn't be analyzed.
|
25 | for (const auto& c : j) { |
35 |
2/4✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
|
17 | std::string name = c.at("name").get<std::string>(); | |
36 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 16 times.
|
2/2✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 16 times.
|
17 | if (name == "LexiLabellingMethod") { |
37 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | rmp_v.push_back(std::make_shared<LexiLabellingMethod>( | |
38 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | LexiLabellingMethod::deserialize(c))); | |
39 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
|
2/2✓ Decision 'true' taken 8 times.
✓ Decision 'false' taken 8 times.
|
16 | } else if (name == "LexiRouteRoutingMethod") { |
40 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | rmp_v.push_back(std::make_shared<LexiRouteRoutingMethod>( | |
41 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | LexiRouteRoutingMethod::deserialize(c))); | |
42 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 7 times.
|
2/2✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 7 times.
|
8 | } else if (name == "RoutingMethod") { |
43 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | rmp_v.push_back(std::make_shared<RoutingMethod>()); | |
44 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 6 times.
|
2/2✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 6 times.
|
7 | } else if (name == "AASRouteRoutingMethod") { |
45 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | rmp_v.push_back(std::make_shared<AASRouteRoutingMethod>( | |
46 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | AASRouteRoutingMethod::deserialize(c))); | |
47 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 5 times.
|
2/2✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 5 times.
|
6 | } else if (name == "AASLabellingMethod") { |
48 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | rmp_v.push_back(std::make_shared<AASLabellingMethod>( | |
49 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | AASLabellingMethod::deserialize(c))); | |
50 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
|
2/2✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 2 times.
|
5 | } else if (name == "MultiGateReorderRoutingMethod") { |
51 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
|
3 | rmp_v.push_back(std::make_shared<MultiGateReorderRoutingMethod>( | |
52 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | MultiGateReorderRoutingMethod::deserialize(c))); | |
53 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
1/2✓ Decision 'true' taken 2 times.
✗ Decision 'false' not taken.
|
2 | } else if (name == "BoxDecompositionRoutingMethod") { |
54 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | rmp_v.push_back(std::make_shared<BoxDecompositionRoutingMethod>( | |
55 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | BoxDecompositionRoutingMethod::deserialize(c))); | |
56 | } else { | |||
57 | ✗ | std::logic_error( | ||
58 | "Deserialization for given RoutingMethod not supported."); | |||
59 | } | |||
60 | 17 | } | ||
61 | 8 | } | ||
62 | ||||
63 | } // namespace tket | |||
64 |