subscription_queue.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009, Willow Garage, Inc.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *   * Redistributions of source code must retain the above copyright notice,
00007  *     this list of conditions and the following disclaimer.
00008  *   * Redistributions in binary form must reproduce the above copyright
00009  *     notice, this list of conditions and the following disclaimer in the
00010  *     documentation and/or other materials provided with the distribution.
00011  *   * Neither the names of Willow Garage, Inc. nor the names of its
00012  *     contributors may be used to endorse or promote products derived from
00013  *     this software without specific prior written permission.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00016  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00018  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00019  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00020  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00021  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00024  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00025  * POSSIBILITY OF SUCH DAMAGE.
00026  */
00027 
00028 #ifndef ROSCPP_SUBSCRIPTION_QUEUE_H
00029 #define ROSCPP_SUBSCRIPTION_QUEUE_H
00030 
00031 #include "forwards.h"
00032 #include "common.h"
00033 #include "ros/message_event.h"
00034 #include "callback_queue_interface.h"
00035 
00036 #include <boost/thread/recursive_mutex.hpp>
00037 #include <boost/thread/mutex.hpp>
00038 #include <boost/enable_shared_from_this.hpp>
00039 #include <deque>
00040 
00041 namespace ros
00042 {
00043 
00044 class MessageDeserializer;
00045 typedef boost::shared_ptr<MessageDeserializer> MessageDeserializerPtr;
00046 
00047 class SubscriptionCallbackHelper;
00048 typedef boost::shared_ptr<SubscriptionCallbackHelper> SubscriptionCallbackHelperPtr;
00049 
00050 class ROSCPP_DECL SubscriptionQueue : public CallbackInterface, public boost::enable_shared_from_this<SubscriptionQueue>
00051 {
00052 private:
00053   struct Item
00054   {
00055     SubscriptionCallbackHelperPtr helper;
00056     MessageDeserializerPtr deserializer;
00057 
00058     bool has_tracked_object;
00059     VoidConstWPtr tracked_object;
00060 
00061     bool nonconst_need_copy;
00062     ros::Time receipt_time;
00063   };
00064   typedef std::deque<Item> D_Item;
00065 
00066 public:
00067   SubscriptionQueue(const std::string& topic, int32_t queue_size, bool allow_concurrent_callbacks);
00068   ~SubscriptionQueue();
00069 
00070   void push(const SubscriptionCallbackHelperPtr& helper, const MessageDeserializerPtr& deserializer, 
00071             bool has_tracked_object, const VoidConstWPtr& tracked_object, bool nonconst_need_copy, 
00072             ros::Time receipt_time = ros::Time(), bool* was_full = 0);
00073   void clear();
00074 
00075   virtual CallbackInterface::CallResult call();
00076   virtual bool ready();
00077   bool full();
00078 
00079 private:
00080   bool fullNoLock();
00081   std::string topic_;
00082   int32_t size_;
00083   bool full_;
00084 
00085   boost::mutex queue_mutex_;
00086   D_Item queue_;
00087   uint32_t queue_size_;
00088   bool allow_concurrent_callbacks_;
00089 
00090   boost::recursive_mutex callback_mutex_;
00091 };
00092 
00093 }
00094 
00095 #endif // ROSCPP_SUBSCRIPTION_QUEUE_H


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Thu Jun 6 2019 21:10:05