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 #include <ros/macros.h>
44 
45 // Import/export for windows dll's and visibility for gcc shared libraries.
46 
47 #ifdef ROS_BUILD_SHARED_LIBS // ros is being built around shared libraries
48  #ifdef polled_camera_EXPORTS // we are building a shared lib/dll
49  #define POLLED_CAMERA_DECL ROS_HELPER_EXPORT
50  #else // we are using shared lib/dll
51  #define POLLED_CAMERA_DECL ROS_HELPER_IMPORT
52  #endif
53 #else // ros is being built around static libraries
54  #define POLLED_CAMERA_DECL
55 #endif
56 
57 namespace polled_camera {
58 
81 {
82 public:
83  typedef boost::function<void (polled_camera::GetPolledImage::Request&,
84  polled_camera::GetPolledImage::Response&,
85  sensor_msgs::Image&,
86  sensor_msgs::CameraInfo&)> DriverCallback;
87 
89 
93  void shutdown();
94 
95  std::string getService() const;
96 
97  operator void*() const;
98  bool operator< (const PublicationServer& rhs) const { return impl_ < rhs.impl_; }
99  bool operator==(const PublicationServer& rhs) const { return impl_ == rhs.impl_; }
100  bool operator!=(const PublicationServer& rhs) const { return impl_ != rhs.impl_; }
101 
102 private:
103  PublicationServer(const std::string& service, ros::NodeHandle& nh,
104  const DriverCallback& cb, const ros::VoidPtr& tracked_object);
105 
106  class Impl;
107 
109 
110  friend
111  PublicationServer advertise(ros::NodeHandle&, const std::string&, const DriverCallback&,
112  const ros::VoidPtr&);
113 };
114 
118 PublicationServer advertise(ros::NodeHandle& nh, const std::string& service,
120  const ros::VoidPtr& tracked_object = ros::VoidPtr());
121 
125 template<class T>
126 PublicationServer advertise(ros::NodeHandle& nh, const std::string& service,
127  void(T::*fp)(polled_camera::GetPolledImage::Request&,
128  polled_camera::GetPolledImage::Response&,
129  sensor_msgs::Image&, sensor_msgs::CameraInfo&),
130  T* obj)
131 {
132  return advertise(nh, service, boost::bind(fp, obj, _1, _2, _3, _4));
133 }
134 
138 template<class T>
139 PublicationServer advertise(ros::NodeHandle& nh, const std::string& service,
140  void(T::*fp)(polled_camera::GetPolledImage::Request&,
141  polled_camera::GetPolledImage::Response&,
142  sensor_msgs::Image&, sensor_msgs::CameraInfo&),
143  const boost::shared_ptr<T>& obj)
144 {
145  return advertise(nh, service, boost::bind(fp, obj.get(), _1, _2, _3, _4), obj);
146 }
147 
148 } //namespace polled_camera
149 
150 #endif
polled_camera::PublicationServer
Manage image requests from one or more clients.
Definition: publication_server.h:80
boost::shared_ptr< void >
polled_camera
Definition: publication_server.h:57
ros.h
polled_camera::PublicationServer::operator==
bool operator==(const PublicationServer &rhs) const
Definition: publication_server.h:99
polled_camera::PublicationServer::PublicationServer
PublicationServer()
Definition: publication_server.h:88
shutdown
ROSCONSOLE_DECL void shutdown()
polled_camera::advertise
PublicationServer advertise(ros::NodeHandle &nh, const std::string &service, const PublicationServer::DriverCallback &cb, const ros::VoidPtr &tracked_object=ros::VoidPtr())
Advertise a polled image service, version for arbitrary boost::function object.
Definition: publication_server.cpp:186
POLLED_CAMERA_DECL
#define POLLED_CAMERA_DECL
Definition: publication_server.h:54
macros.h
polled_camera::PublicationServer::impl_
boost::shared_ptr< Impl > impl_
Definition: publication_server.h:106
polled_camera::PublicationServer::DriverCallback
boost::function< void(polled_camera::GetPolledImage::Request &, polled_camera::GetPolledImage::Response &, sensor_msgs::Image &, sensor_msgs::CameraInfo &)> DriverCallback
Definition: publication_server.h:86
ros::NodeHandle
polled_camera::PublicationServer::operator!=
bool operator!=(const PublicationServer &rhs) const
Definition: publication_server.h:100


polled_camera
Author(s): Patrick Mihelich
autogenerated on Sun Nov 14 2021 03:14:24