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 
62  void shutdown();
63 
64  std::string getTopic() const;
65 
69  uint32_t getNumPublishers() const;
70 
71  operator void*() const { return (impl_ && impl_->isValid()) ? (void*)1 : (void*)0; }
72 
73  bool operator<(const Subscriber& rhs) const
74  {
75  return impl_ < rhs.impl_;
76  }
77 
78  bool operator==(const Subscriber& rhs) const
79  {
80  return impl_ == rhs.impl_;
81  }
82 
83  bool operator!=(const Subscriber& rhs) const
84  {
85  return impl_ != rhs.impl_;
86  }
87 
88 private:
89 
90  Subscriber(const std::string& topic, const NodeHandle& node_handle,
91  const SubscriptionCallbackHelperPtr& helper);
92 
93  class Impl
94  {
95  public:
96  Impl();
97  ~Impl();
98 
99  void unsubscribe();
100  bool isValid() const;
101 
102  std::string topic_;
106  };
108  typedef boost::weak_ptr<Impl> ImplWPtr;
109 
110  ImplPtr impl_;
111 
112  friend class NodeHandle;
114 };
115 typedef std::vector<Subscriber> V_Subscriber;
116 
117 }
118 
119 #endif // ROSCPP_PUBLISHER_HANDLE_H
120 
121 
Manages an subscription callback on a specific topic.
Definition: subscriber.h:46
std::vector< Subscriber > V_Subscriber
Definition: subscriber.h:115
SubscriptionCallbackHelperPtr helper_
Definition: subscriber.h:104
bool operator<(const Subscriber &rhs) const
Definition: subscriber.h:73
roscpp&#39;s interface for creating subscribers, publishers, etc.
Definition: node_handle.h:87
boost::shared_ptr< Impl > ImplPtr
Definition: subscriber.h:107
boost::weak_ptr< Impl > ImplWPtr
Definition: subscriber.h:108
std::string topic_
Definition: subscriber.h:102
NodeHandlePtr node_handle_
Definition: subscriber.h:103
ROSCPP_DECL void shutdown()
Disconnects everything and unregisters from the master. It is generally not necessary to call this fu...
Definition: init.cpp:578
bool operator!=(const Subscriber &rhs) const
Definition: subscriber.h:83
bool operator==(const Subscriber &rhs) const
Definition: subscriber.h:78


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Sun Feb 3 2019 03:29:54