File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -432,6 +432,12 @@ export namespace CppUtils::Container
432432 return nodeAccessor->value.value.sharedAccess();
433433 }
434434
435+ [[nodiscard]] auto getBranches() const -> Thread::ReadOnlyAccessor<Branches>
436+ {
437+ auto nodeAccessor = m_node->sharedAccess();
438+ return nodeAccessor->value.branches.sharedAccess();
439+ }
440+
435441 private:
436442 SharedPtr m_node = nullptr;
437443 };
Original file line number Diff line number Diff line change @@ -541,5 +541,29 @@ namespace CppUtils::UnitTest::Container::MeshNetwork
541541 suite.expect(it < std::cend(branch));
542542 suite.expectEqual(std::cend(branch) - std::cbegin(branch), 3);
543543 });
544+
545+ suite.addTest("Get branches", [&] {
546+ auto root = StringMeshNodePtr::makeRoot("root");
547+ auto child1 = StringMeshNodePtr::make("child1");
548+ auto child2 = StringMeshNodePtr::make("child2");
549+ auto child3 = StringMeshNodePtr::make("child3");
550+
551+ root["A"] >> child1;
552+ root["B"] >> child2;
553+ root["B"] >> child3;
554+
555+ auto branchesAccessor = root.getBranches();
556+ const auto& branches = branchesAccessor.value();
557+
558+ suite.expectEqual(std::size(branches), 2uz);
559+ suite.expect(branches.contains("A"));
560+ suite.expect(branches.contains("B"));
561+
562+ auto aBranches = branches.at("A")->sharedAccess();
563+ suite.expectEqual(std::size(aBranches.value()), 1uz);
564+
565+ auto bBranches = branches.at("B")->sharedAccess();
566+ suite.expectEqual(std::size(bBranches.value()), 2uz);
567+ });
544568 }};
545569}
You can’t perform that action at this time.
0 commit comments