subscriber.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, Willow Garage, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef ROSCPP_SUBSCRIBER_HANDLE_H
29 #define ROSCPP_SUBSCRIBER_HANDLE_H
30 
31 #include "common.h"
32 #include "ros/forwards.h"
34 
35 namespace ros
36 {
37 
46 class ROSCPP_DECL Subscriber
47 {
48 public:
50  Subscriber(const Subscriber& rhs);
51  ~Subscriber();
52  Subscriber& operator=(const Subscriber& other) = default;
53 
63  void shutdown();
64 
65  std::string getTopic() const;
66 
70  uint32_t getNumPublishers() const;
71 
72  operator void*() const { return (impl_ && impl_->isValid()) ? (void*)1 : (void*)0; }
73 
74  bool operator<(const Subscriber& rhs) const
75  {
76  return impl_ < rhs.impl_;
77  }
78 
79  bool operator==(const Subscriber& rhs) const
80  {
81  return impl_ == rhs.impl_;
82  }
83 
84  bool operator!=(const Subscriber& rhs) const
85  {
86  return impl_ != rhs.impl_;
87  }
88 
89 private:
90 
91  Subscriber(const std::string& topic, const NodeHandle& node_handle,
92  const SubscriptionCallbackHelperPtr& helper);
93 
94  class Impl
95  {
96  public:
97  Impl();
98  ~Impl();
99 
100  void unsubscribe();
101  bool isValid() const;
102 
103  std::string topic_;
107  };
109  typedef boost::weak_ptr<Impl> ImplWPtr;
110 
112 
113  friend class NodeHandle;
115 };
116 typedef std::vector<Subscriber> V_Subscriber;
117 
118 }
119 
120 #endif // ROSCPP_PUBLISHER_HANDLE_H
121 
122 
boost::shared_ptr< SubscriptionCallbackHelper >
forwards.h
ros::Subscriber::Impl::topic_
std::string topic_
Definition: subscriber.h:103
ros
ros::Subscriber::Impl::unsubscribed_
bool unsubscribed_
Definition: subscriber.h:106
ros::shutdown
ROSCPP_DECL void shutdown()
Disconnects everything and unregisters from the master. It is generally not necessary to call this fu...
Definition: init.cpp:605
ros::Subscriber::operator==
bool operator==(const Subscriber &rhs) const
Definition: subscriber.h:79
subscription_callback_helper.h
ros::NodeHandleBackingCollection
Definition: node_handle.cpp:58
ros::Subscriber::operator<
bool operator<(const Subscriber &rhs) const
Definition: subscriber.h:74
ros::Subscriber::impl_
ImplPtr impl_
Definition: subscriber.h:111
ros::Subscriber::Subscriber
Subscriber()
Definition: subscriber.h:49
ros::Subscriber::Impl::helper_
SubscriptionCallbackHelperPtr helper_
Definition: subscriber.h:105
ros::V_Subscriber
std::vector< Subscriber > V_Subscriber
Definition: subscriber.h:116
ros::Subscriber::operator!=
bool operator!=(const Subscriber &rhs) const
Definition: subscriber.h:84
ros::Subscriber::ImplWPtr
boost::weak_ptr< Impl > ImplWPtr
Definition: subscriber.h:109
ros::NodeHandle
roscpp's interface for creating subscribers, publishers, etc.
Definition: node_handle.h:87
ros::Subscriber::ImplPtr
boost::shared_ptr< Impl > ImplPtr
Definition: subscriber.h:108
ros::Subscriber::Impl::node_handle_
NodeHandlePtr node_handle_
Definition: subscriber.h:104
ros::Subscriber
Manages an subscription callback on a specific topic.
Definition: subscriber.h:46
ros::Subscriber::Impl
Definition: subscriber.h:94


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas , Jacob Perron
autogenerated on Thu Nov 23 2023 04:01:44