rtt_rostopic_ros_publish_activity.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Ruben Smits  Tue Nov 16 09:18:49 CET 2010  ros_publish_activity.hpp
00003 
00004                         ros_publish_activity.hpp -  description
00005                            -------------------
00006     begin                : Tue November 16 2010
00007     copyright            : (C) 2010 Ruben Smits
00008     email                : first.last@mech.kuleuven.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place,                                    *
00024  *   Suite 330, Boston, MA  02111-1307  USA                                *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 #ifndef __RTT_ROSCOMM_ROS_MSG_ACTIVITY_HPP_
00030 #define __RTT_ROSCOMM_ROS_MSG_ACTIVITY_HPP_
00031 
00032 #include <rtt/Activity.hpp>
00033 #include <rtt/os/Mutex.hpp>
00034 #include <rtt/os/MutexLock.hpp>
00035 #include <boost/shared_ptr.hpp>
00036 #include <rtt/Logger.hpp>
00037 
00038 #include <ros/ros.h>
00039 
00040 #include <set>
00041 
00042 namespace rtt_roscomm{
00043 
00048   struct RosPublisher
00049   {
00050   public:
00054     virtual void publish()=0;
00055   };
00056 
00057 
00066   class RosPublishActivity : public RTT::Activity 
00067   {
00068   public:
00069     typedef boost::shared_ptr<RosPublishActivity> shared_ptr;
00070   private:
00071     typedef boost::weak_ptr<RosPublishActivity> weak_ptr;
00073     static weak_ptr ros_pub_act;
00074 
00078     typedef std::set< RosPublisher* > Publishers;
00079     typedef Publishers::iterator iterator;
00080     Publishers publishers;
00081     RTT::os::Mutex publishers_lock;
00082 
00083     RosPublishActivity( const std::string& name);
00084 
00085     void loop();
00086     
00087   public:
00095     static shared_ptr Instance();
00096       
00097     void addPublisher(RosPublisher* pub);
00098     void removePublisher(RosPublisher* pub);
00099     
00100     ~RosPublishActivity();
00101 
00102   };//class
00103 }//namespace
00104 #endif
00105 


rtt_roscomm
Author(s): Ruben Smits, Jonathan Bohren
autogenerated on Mon Apr 3 2017 03:34:43