Skip to content

Commit

Permalink
data-container: Only return names of multi-id topics once, add getter…
Browse files Browse the repository at this point in the history
… for subscription message-id map
  • Loading branch information
ThomasDebrunner committed Sep 25, 2023
1 parent c2c2c48 commit 0343380
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ulog_cpp/data_container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include "data_handler_interface.hpp"
Expand Down Expand Up @@ -87,13 +88,18 @@ class DataContainer : public DataHandlerInterface {
return _subscriptions_by_name_and_multi_id;
}

const std::map<uint16_t, std::shared_ptr<Subscription>>& subscriptionsByMessageId()
{
return _subscriptions_by_message_id;
}

std::vector<std::string> subscriptionNames() const
{
std::vector<std::string> names;
std::unordered_set<std::string> names;
for (const auto& kv : _subscriptions_by_name_and_multi_id) {
names.push_back(kv.first.name);
names.insert(kv.first.name);
}
return names;
return std::vector<std::string>(names.begin(), names.end());
}

std::shared_ptr<Subscription> subscription(const std::string& name, int multi_id) const
Expand Down

0 comments on commit 0343380

Please sign in to comment.