00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2008, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 *********************************************************************/ 00034 00035 #ifndef ROSBAG_QUERY_H 00036 #define ROSBAG_QUERY_H 00037 00038 #include "ros/time.h" 00039 00040 #include <vector> 00041 #include <map> 00042 #include <set> 00043 00044 #include <boost/function.hpp> 00045 #include "macros.h" 00046 00047 namespace rosbag { 00048 00049 class Bag; 00050 struct ConnectionInfo; 00051 struct IndexEntry; 00052 00053 class ROSBAG_DECL Query 00054 { 00055 public: 00057 00061 Query(boost::function<bool(ConnectionInfo const*)>& query, 00062 ros::Time const& start_time = ros::TIME_MIN, 00063 ros::Time const& end_time = ros::TIME_MAX); 00064 00065 boost::function<bool(ConnectionInfo const*)> const& getQuery() const; 00066 00067 ros::Time const& getStartTime() const; 00068 ros::Time const& getEndTime() const; 00069 00070 private: 00071 boost::function<bool(ConnectionInfo const*)> query_; 00072 ros::Time start_time_; 00073 ros::Time end_time_; 00074 }; 00075 00076 class ROSBAG_DECL TopicQuery 00077 { 00078 public: 00079 TopicQuery(std::string const& topic); 00080 TopicQuery(std::vector<std::string> const& topics); 00081 00082 bool operator()(ConnectionInfo const*) const; 00083 00084 private: 00085 std::vector<std::string> topics_; 00086 }; 00087 00088 class ROSBAG_DECL TypeQuery 00089 { 00090 public: 00091 TypeQuery(std::string const& type); 00092 TypeQuery(std::vector<std::string> const& types); 00093 00094 bool operator()(ConnectionInfo const*) const; 00095 00096 private: 00097 std::vector<std::string> types_; 00098 }; 00099 00101 struct ROSBAG_DECL BagQuery 00102 { 00103 BagQuery(Bag const* _bag, Query const& _query, uint32_t _bag_revision); 00104 00105 Bag const* bag; 00106 Query query; 00107 uint32_t bag_revision; 00108 }; 00109 00110 struct ROSBAG_DECL MessageRange 00111 { 00112 MessageRange(std::multiset<IndexEntry>::const_iterator const& _begin, 00113 std::multiset<IndexEntry>::const_iterator const& _end, 00114 ConnectionInfo const* _connection_info, 00115 BagQuery const* _bag_query); 00116 00117 std::multiset<IndexEntry>::const_iterator begin; 00118 std::multiset<IndexEntry>::const_iterator end; 00119 ConnectionInfo const* connection_info; 00120 BagQuery const* bag_query; 00121 }; 00122 00124 struct ROSBAG_DECL ViewIterHelper 00125 { 00126 ViewIterHelper(std::multiset<IndexEntry>::const_iterator _iter, MessageRange const* _range); 00127 00128 std::multiset<IndexEntry>::const_iterator iter; 00129 MessageRange const* range; 00130 }; 00131 00132 struct ROSBAG_DECL ViewIterHelperCompare 00133 { 00134 bool operator()(ViewIterHelper const& a, ViewIterHelper const& b); 00135 }; 00136 00137 } // namespace rosbag 00138 00139 #endif