00001 #ifndef ROSRTT_PUBLISHER_HANDLE_H 00002 #define ROSRTT_PUBLISHER_HANDLE_H 00003 00004 #include "ros/publisher.h" 00005 #include "topic_manager.h" 00006 00007 namespace hpcl_rtt 00008 { 00009 00010 class Publisher 00011 { 00012 public: 00013 Publisher(); 00014 Publisher(ros::Publisher ros_publisher); 00015 Publisher(ConnectionBasePtr pub_connection, ros::Publisher ros_publisher); 00016 ~Publisher(); 00017 00018 template <class M> 00019 void publish(M message) 00020 { 00021 //ROS_INFO("finding pub %s.", topic_.c_str()); 00022 if (publication) 00023 { 00024 //ROS_INFO("publishing topic %s.", pub->getTopic ().c_str ()); 00025 //typename Publication<M>::shared_ptr output = static_cast< Publication<M>* >( pub.get() ); 00026 typename Publication<M>::shared_ptr output = boost::static_pointer_cast< Publication<M> >(publication); 00027 output->publish(message); 00028 } 00029 else 00030 { 00031 //ROS_INFO("ros publishing."); 00032 ros_pub.publish<M>(message); 00033 } 00034 00035 return; 00036 } 00037 00038 private: 00039 ros::Publisher ros_pub; 00040 ConnectionBasePtr publication; 00041 }; 00042 00043 } 00044 00045 #endif