subscription_queue.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 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_SUBSCRIPTION_QUEUE_H
29 #define ROSCPP_SUBSCRIPTION_QUEUE_H
30 
31 #include "forwards.h"
32 #include "common.h"
33 #include "ros/message_event.h"
35 
36 #include <boost/thread/recursive_mutex.hpp>
37 #include <boost/thread/mutex.hpp>
38 #include <boost/enable_shared_from_this.hpp>
39 #include <deque>
40 
41 namespace ros
42 {
43 
44 class MessageDeserializer;
46 
47 class SubscriptionCallbackHelper;
49 
50 class ROSCPP_DECL SubscriptionQueue : public CallbackInterface, public boost::enable_shared_from_this<SubscriptionQueue>
51 {
52 private:
53  struct Item
54  {
55  SubscriptionCallbackHelperPtr helper;
56  MessageDeserializerPtr deserializer;
57 
60 
63  };
64  typedef std::deque<Item> D_Item;
65 
66 public:
67  SubscriptionQueue(const std::string& topic, int32_t queue_size, bool allow_concurrent_callbacks);
69 
70  void push(const SubscriptionCallbackHelperPtr& helper, const MessageDeserializerPtr& deserializer,
71  bool has_tracked_object, const VoidConstWPtr& tracked_object, bool nonconst_need_copy,
72  ros::Time receipt_time = ros::Time(), bool* was_full = 0);
73  void clear();
74 
76  virtual bool ready();
77  bool full();
78 
79 private:
80  bool fullNoLock();
81  std::string topic_;
82  int32_t size_;
83  bool full_;
84 
85  boost::mutex queue_mutex_;
86  D_Item queue_;
87  uint32_t queue_size_;
89 
90  boost::recursive_mutex callback_mutex_;
91 };
92 
93 }
94 
95 #endif // ROSCPP_SUBSCRIPTION_QUEUE_H
CallResult
Possible results for the call() method.
MessageDeserializerPtr deserializer
bool call(const std::string &service_name, MReq &req, MRes &res)
Invoke an RPC service.
Definition: service.h:65
Abstract interface for items which can be added to a CallbackQueueInterface.
SubscriptionCallbackHelperPtr helper
boost::shared_ptr< SubscriptionCallbackHelper > SubscriptionCallbackHelperPtr
boost::recursive_mutex callback_mutex_
boost::weak_ptr< void const > VoidConstWPtr
Definition: forwards.h:53
boost::shared_ptr< MessageDeserializer > MessageDeserializerPtr
std::deque< Item > D_Item


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