intraprocess_subscriber_link.cpp
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 2008, Morgan Quigley and Willow Garage, Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
31 #include "ros/publication.h"
32 #include "ros/header.h"
33 #include "ros/connection.h"
35 #include "ros/this_node.h"
36 #include "ros/connection_manager.h"
37 #include "ros/topic_manager.h"
38 #include "ros/file_log.h"
39 
40 #include <boost/bind.hpp>
41 
42 namespace ros
43 {
44 
46 : dropped_(false)
47 {
48  ROS_ASSERT(parent);
49  parent_ = parent;
50  topic_ = parent->getName();
51 }
52 
54 {
55 }
56 
58 {
59  subscriber_ = subscriber;
60  connection_id_ = ConnectionManager::instance()->getNewConnectionID();
62 }
63 
65 {
66  if (PublicationPtr parent = parent_.lock())
67  {
68  return parent->isLatching();
69  }
70 
71  return false;
72 }
73 
75 {
76  boost::recursive_mutex::scoped_lock lock(drop_mutex_);
77  if (dropped_)
78  {
79  return;
80  }
81 
83  subscriber_->handleMessage(m, ser, nocopy);
84 }
85 
87 {
88  return std::string("INTRAPROCESS");
89 }
90 
92 {
93  // TODO: Check if we can dump more useful information here
94  return getTransportType();
95 }
96 
98 {
99  {
100  boost::recursive_mutex::scoped_lock lock(drop_mutex_);
101  if (dropped_)
102  {
103  return;
104  }
105 
106  dropped_ = true;
107  }
108 
109  if (subscriber_)
110  {
111  subscriber_->drop();
112  subscriber_.reset();
113  }
114 
115  if (PublicationPtr parent = parent_.lock())
116  {
117  ROSCPP_LOG_DEBUG("Connection to local subscriber on topic [%s] dropped", topic_.c_str());
118 
119  parent->removeSubscriberLink(shared_from_this());
120  }
121 }
122 
123 void IntraProcessSubscriberLink::getPublishTypes(bool& ser, bool& nocopy, const std::type_info& ti)
124 {
125  boost::recursive_mutex::scoped_lock lock(drop_mutex_);
126  if (dropped_)
127  {
128  return;
129  }
130 
131  subscriber_->getPublishTypes(ser, nocopy, ti);
132 }
133 
134 } // namespace ros
ROSCPP_DECL const std::string & getName()
Returns the name of the current node.
Definition: this_node.cpp:74
#define ROSCPP_LOG_DEBUG(...)
Definition: file_log.h:35
static const ConnectionManagerPtr & instance()
#define ROS_ASSERT(cond)


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
autogenerated on Mon Feb 28 2022 23:33:27