callback_queue.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Willow Garage, Inc.
3  * All rights reserved.
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  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
32 
33 #include <ros/callback_queue.h>
34 
35 namespace nodelet
36 {
37 namespace detail
38 {
39 
41  const ros::VoidConstPtr& tracked_object)
42 : parent_(parent)
43 , tracked_object_(tracked_object)
44 , has_tracked_object_(tracked_object)
45 {
46 }
47 
49 {
50 }
51 
52 void CallbackQueue::addCallback(const ros::CallbackInterfacePtr& cb, uint64_t owner_id)
53 {
54  if (queue_.isEnabled())
55  {
56  queue_.addCallback(cb, owner_id);
57  parent_->callbackAdded(shared_from_this());
58  }
59 }
60 
61 void CallbackQueue::removeByID(uint64_t owner_id)
62 {
63  queue_.removeByID(owner_id);
64 }
65 
67 {
68  // Don't try to call the callback after its nodelet has been destroyed!
69  ros::VoidConstPtr tracker;
71  {
72  tracker = tracked_object_.lock();
73 
74  if (!tracker)
76  }
77 
78  return queue_.callOne();
79 }
80 
82 {
83  queue_.enable();
84 }
85 
87 {
88  queue_.disable();
89 }
90 
91 
92 } // namespace detail
93 } // namespace nodelet
nodelet::detail::CallbackQueue::~CallbackQueue
~CallbackQueue()
Definition: callback_queue.cpp:48
ros::CallbackQueue::Disabled
Disabled
nodelet::detail::CallbackQueue::enable
void enable()
Enable the queue (queue is enabled by default)
Definition: callback_queue.cpp:81
boost::shared_ptr< void const >
ros::CallbackQueue::isEnabled
bool isEnabled()
nodelet::detail::CallbackQueue::has_tracked_object_
bool has_tracked_object_
Definition: callback_queue.h:79
nodelet::detail::CallbackQueue::removeByID
virtual void removeByID(uint64_t owner_id)
Definition: callback_queue.cpp:61
nodelet::detail::CallbackQueueManager::callbackAdded
void callbackAdded(const CallbackQueuePtr &queue)
Definition: callback_queue_manager.cpp:130
ros::CallbackQueue::addCallback
virtual void addCallback(const CallbackInterfacePtr &callback, uint64_t removal_id=0)
nodelet::detail::CallbackQueue::addCallback
virtual void addCallback(const ros::CallbackInterfacePtr &callback, uint64_t owner_id=0)
Definition: callback_queue.cpp:52
nodelet::detail::CallbackQueueManager
Internal use.
Definition: callback_queue_manager.h:65
nodelet::detail::CallbackQueue::disable
void disable()
Disable the queue, meaning any calls to addCallback() will have no effect.
Definition: callback_queue.cpp:86
nodelet::detail::CallbackQueue::CallbackQueue
CallbackQueue(CallbackQueueManager *parent, const ros::VoidConstPtr &tracked_object=ros::VoidConstPtr())
Definition: callback_queue.cpp:40
ros::CallbackQueue::removeByID
virtual void removeByID(uint64_t removal_id)
nodelet::detail::CallbackQueue::parent_
CallbackQueueManager * parent_
Definition: callback_queue.h:76
nodelet::detail::CallbackQueue::queue_
ros::CallbackQueue queue_
Definition: callback_queue.h:77
callback_queue.h
nodelet::detail::CallbackQueue::tracked_object_
ros::VoidConstWPtr tracked_object_
Definition: callback_queue.h:78
nodelet
Definition: callback_queue.h:44
ros::CallbackQueue::enable
void enable()
nodelet::detail::CallbackQueue::callOne
uint32_t callOne()
Definition: callback_queue.cpp:66
ros::CallbackQueue::callOne
CallOneResult callOne()
callback_queue.h
callback_queue_manager.h
ros::CallbackQueue::disable
void disable()


nodelet
Author(s): Tully Foote, Radu Bogdan Rusu, Michael Carroll
autogenerated on Fri Jan 12 2024 03:40:39