add publish specialization for shared_ptr<const MessageT>

This commit is contained in:
Jackie Kay 2015-10-13 15:22:03 -07:00
parent ae682baf1c
commit 581e5213f2

View file

@ -157,6 +157,24 @@ public:
return this->publish(unique_msg);
}
template<typename MessageT>
void
publish(std::shared_ptr<const MessageT> msg)
{
// Avoid allocating when not using intra process.
if (!store_intra_process_message_) {
// In this case we're not using intra process.
return this->do_inter_process_publish(msg.get());
}
// Otherwise we have to allocate memory in a unique_ptr and pass it along.
// TODO(wjwwood):
// The intra process manager should probably also be able to store
// shared_ptr's and do the "smart" thing based on other intra process
// subscriptions. For now call the other publish().
std::unique_ptr<MessageT> unique_msg(new MessageT(*msg.get()));
return this->publish(unique_msg);
}
template<typename MessageT>
void
publish(const MessageT & msg)