Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef ROSBAG_VIEW_H
00036 #define ROSBAG_VIEW_H
00037
00038 #include <boost/function.hpp>
00039 #include <boost/iterator/iterator_facade.hpp>
00040
00041 #include "rosbag/message_instance.h"
00042 #include "rosbag/query.h"
00043
00044 namespace rosbag {
00045
00046 class MessageRange;
00047 class IndexEntry;
00048 class ViewIterHelper;
00049
00050 class View
00051 {
00052 friend class Bag;
00053
00054 public:
00056
00062 class iterator : public boost::iterator_facade<iterator,
00063 MessageInstance,
00064 boost::forward_traversal_tag>
00065 {
00066 public:
00067 iterator(iterator const& i);
00068 iterator();
00069 ~iterator();
00070
00071 protected:
00072 iterator(View* view, bool end = false);
00073
00074 private:
00075 friend class View;
00076 friend class boost::iterator_core_access;
00077
00078 void populate();
00079 void populateSeek(std::multiset<IndexEntry>::const_iterator iter);
00080
00081 bool equal(iterator const& other) const;
00082
00083 void increment();
00084
00085 MessageInstance& dereference() const;
00086
00087 private:
00088 View* view_;
00089 std::vector<ViewIterHelper> iters_;
00090 uint32_t view_revision_;
00091 mutable MessageInstance* message_instance_;
00092 };
00093
00094 typedef iterator const_iterator;
00095
00096 struct TrueQuery {
00097 bool operator()(ConnectionInfo const*) const { return true; };
00098 };
00099
00101
00104 View(bool const& reduce_overlap = false);
00105
00107
00113 View(Bag const& bag, ros::Time const& start_time = ros::TIME_MIN, ros::Time const& end_time = ros::TIME_MAX, bool const& reduce_overlap = false);
00114
00116
00123 View(Bag const& bag, boost::function<bool(ConnectionInfo const*)> query,
00124 ros::Time const& start_time = ros::TIME_MIN, ros::Time const& end_time = ros::TIME_MAX, bool const& reduce_overlap = false);
00125
00126 ~View();
00127
00128 iterator begin();
00129 iterator end();
00130 uint32_t size();
00131
00133
00138 void addQuery(Bag const& bag, ros::Time const& start_time = ros::TIME_MIN, ros::Time const& end_time = ros::TIME_MAX);
00139
00141
00147 void addQuery(Bag const& bag, boost::function<bool(ConnectionInfo const*)> query,
00148 ros::Time const& start_time = ros::TIME_MIN, ros::Time const& end_time = ros::TIME_MAX);
00149
00150 std::vector<const ConnectionInfo*> getConnections();
00151
00152 ros::Time getBeginTime();
00153 ros::Time getEndTime();
00154
00155 protected:
00156 friend class iterator;
00157
00158 void updateQueries(BagQuery* q);
00159 void update();
00160
00161 MessageInstance* newMessageInstance(ConnectionInfo const* connection_info, IndexEntry const& index, Bag const& bag);
00162
00163 private:
00164 View(View const& view);
00165 View& operator=(View const& view);
00166
00167 protected:
00168 std::vector<MessageRange*> ranges_;
00169 std::vector<BagQuery*> queries_;
00170 uint32_t view_revision_;
00171
00172 uint32_t size_cache_;
00173 uint32_t size_revision_;
00174
00175 bool reduce_overlap_;
00176 };
00177
00178 }
00179
00180 #endif