publication_server.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2009, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 #ifndef POLLED_CAMERA_PUBLICATION_SERVER_H
36 #define POLLED_CAMERA_PUBLICATION_SERVER_H
37 
38 #include <ros/ros.h>
39 #include <sensor_msgs/Image.h>
40 #include <sensor_msgs/CameraInfo.h>
41 #include "polled_camera/GetPolledImage.h"
42 
43 namespace polled_camera {
44 
67 {
68 public:
69  typedef boost::function<void (polled_camera::GetPolledImage::Request&,
70  polled_camera::GetPolledImage::Response&,
71  sensor_msgs::Image&,
72  sensor_msgs::CameraInfo&)> DriverCallback;
73 
75 
79  void shutdown();
80 
81  std::string getService() const;
82 
83  operator void*() const;
84  bool operator< (const PublicationServer& rhs) const { return impl_ < rhs.impl_; }
85  bool operator==(const PublicationServer& rhs) const { return impl_ == rhs.impl_; }
86  bool operator!=(const PublicationServer& rhs) const { return impl_ != rhs.impl_; }
87 
88 private:
89  PublicationServer(const std::string& service, ros::NodeHandle& nh,
90  const DriverCallback& cb, const ros::VoidPtr& tracked_object);
91 
92  class Impl;
93 
95 
96  friend
97  PublicationServer advertise(ros::NodeHandle&, const std::string&, const DriverCallback&,
98  const ros::VoidPtr&);
99 };
100 
104 PublicationServer advertise(ros::NodeHandle& nh, const std::string& service,
106  const ros::VoidPtr& tracked_object = ros::VoidPtr());
107 
111 template<class T>
112 PublicationServer advertise(ros::NodeHandle& nh, const std::string& service,
113  void(T::*fp)(polled_camera::GetPolledImage::Request&,
114  polled_camera::GetPolledImage::Response&,
115  sensor_msgs::Image&, sensor_msgs::CameraInfo&),
116  T* obj)
117 {
118  return advertise(nh, service, boost::bind(fp, obj, _1, _2, _3, _4));
119 }
120 
124 template<class T>
125 PublicationServer advertise(ros::NodeHandle& nh, const std::string& service,
126  void(T::*fp)(polled_camera::GetPolledImage::Request&,
127  polled_camera::GetPolledImage::Response&,
128  sensor_msgs::Image&, sensor_msgs::CameraInfo&),
129  const boost::shared_ptr<T>& obj)
130 {
131  return advertise(nh, service, boost::bind(fp, obj.get(), _1, _2, _3, _4), obj);
132 }
133 
134 } //namespace polled_camera
135 
136 #endif
bool operator!=(const PublicationServer &rhs) const
bool operator==(const PublicationServer &rhs) const
Manage image requests from one or more clients.
friend PublicationServer advertise(ros::NodeHandle &, const std::string &, const DriverCallback &, const ros::VoidPtr &)
Advertise a polled image service, version for arbitrary boost::function object.
void shutdown()
Unadvertise the request service and shut down all published topics.
boost::shared_ptr< Impl > impl_
bool operator<(const PublicationServer &rhs) const
boost::function< void(polled_camera::GetPolledImage::Request &, polled_camera::GetPolledImage::Response &, sensor_msgs::Image &, sensor_msgs::CameraInfo &)> DriverCallback


polled_camera
Author(s): Patrick Mihelich
autogenerated on Thu Jun 6 2019 19:22:57