18 #ifndef GZ_TRANSPORT_TOPICSTORAGE_HH_
19 #define GZ_TRANSPORT_TOPICSTORAGE_HH_
26 #include "gz/transport/config.hh"
27 #include "gz/transport/Export.hh"
36 inline namespace GZ_TRANSPORT_VERSION_NAMESPACE {
56 if (this->data.find(_publisher.Topic()) == this->data.end())
59 this->data[_publisher.Topic()] =
64 auto &m = this->data[_publisher.Topic()];
65 if (m.find(_publisher.PUuid()) != m.end())
68 auto &v = m[_publisher.PUuid()];
72 return _pub.Addr() == _publisher.Addr() &&
73 _pub.NUuid() == _publisher.NUuid();
82 m[_publisher.PUuid()].push_back(T(_publisher));
91 return this->data.find(_topic) != this->data.end();
103 if (!this->HasTopic(_topic))
107 auto &m = this->data.at(_topic);
109 for (
auto const &procs : m)
112 auto &v = procs.second;
116 return _pub.MsgTypeName() == _type ||
117 _pub.MsgTypeName() == kGenericMessageType;
121 if (found != v.end())
137 if (!this->HasTopic(_topic))
140 return this->data.at(_topic).find(_pUuid) !=
141 this->data.at(_topic).end();
149 for (
auto const &topic : this->data)
151 for (
auto const &proc : topic.second)
153 for (
auto const &pub : proc.second)
155 if (pub.Addr() == _addr)
175 if (this->data.find(_topic) == this->data.end())
179 auto &m = this->data.at(_topic);
182 if (m.find(_pUuid) == m.end())
186 auto &v = m.at(_pUuid);
190 return _pub.NUuid() == _nUuid;
193 if (found != v.end())
210 if (!this->HasTopic(_topic))
213 _info = this->data.at(_topic);
229 if (this->data.find(_topic) != this->data.end())
232 auto &m = this->data[_topic];
235 if (m.find(_pUuid) != m.end())
239 auto priorSize = v.size();
243 return _pub.NUuid() == _nUuid;
246 counter = priorSize - v.size();
252 this->data.erase(_topic);
267 for (
auto it = this->data.begin(); it != this->data.end();)
270 auto &m = it->second;
271 counter += m.erase(_pUuid);
273 this->data.erase(it++);
292 for (
auto const &topic : this->data)
295 auto &m = topic.second;
296 if (m.find(_pUuid) != m.end())
298 auto &v = m.at(_pUuid);
299 for (
auto const &pub : v)
301 _pubs[pub.NUuid()].push_back(T(pub));
319 for (
auto const &topic : this->data)
322 auto const &m = topic.second;
323 if (m.find(_pUuid) != m.end())
325 auto const &v = m.at(_pUuid);
326 for (
auto const &pub : v)
328 if (pub.NUuid() == _nUuid)
341 for (
auto const &topic : this->data)
349 for (
auto const &topic : this->data)
352 auto &m = topic.second;
353 for (
auto const &proc : m)
356 auto &v = proc.second;
357 for (
auto const &publisher : v)