00001 #include "image_transport/single_subscriber_publisher.h" 00002 #include "image_transport/publisher.h" 00003 00004 namespace image_transport { 00005 00006 SingleSubscriberPublisher::SingleSubscriberPublisher(const std::string& caller_id, const std::string& topic, 00007 const GetNumSubscribersFn& num_subscribers_fn, 00008 const PublishFn& publish_fn) 00009 : caller_id_(caller_id), topic_(topic), 00010 num_subscribers_fn_(num_subscribers_fn), 00011 publish_fn_(publish_fn) 00012 { 00013 } 00014 00015 std::string SingleSubscriberPublisher::getSubscriberName() const 00016 { 00017 return caller_id_; 00018 } 00019 00020 std::string SingleSubscriberPublisher::getTopic() const 00021 { 00022 return topic_; 00023 } 00024 00025 uint32_t SingleSubscriberPublisher::getNumSubscribers() const 00026 { 00027 return num_subscribers_fn_(); 00028 } 00029 00030 void SingleSubscriberPublisher::publish(const sensor_msgs::Image& message) const 00031 { 00032 publish_fn_(message); 00033 } 00034 00035 void SingleSubscriberPublisher::publish(const sensor_msgs::ImageConstPtr& message) const 00036 { 00037 publish_fn_(*message); 00038 } 00039 00040 } //namespace image_transport