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 #include "rosbag/macros.h"
00044 #include "rosbag/structures.h"
00045
00046 namespace rosbag {
00047
00048 class ROSBAG_DECL View
00049 {
00050 friend class Bag;
00051
00052 public:
00054
00060 class iterator : public boost::iterator_facade<iterator,
00061 MessageInstance,
00062 boost::forward_traversal_tag>
00063 {
00064 public:
00065 iterator(iterator const& i);
00066 iterator();
00067 ~iterator();
00068
00069 protected:
00070 iterator(View* view, bool end = false);
00071
00072 private:
00073 friend class View;
00074 friend class boost::iterator_core_access;
00075
00076 void populate();
00077 void populateSeek(std::multiset<IndexEntry>::const_iterator iter);
00078
00079 bool equal(iterator const& other) const;
00080
00081 void increment();
00082
00083 MessageInstance& dereference() const;
00084
00085 private:
00086 View* view_;
00087 std::vector<ViewIterHelper> iters_;
00088 uint32_t view_revision_;
00089 mutable MessageInstance* message_instance_;
00090 };
00091
00092 typedef iterator const_iterator;
00093
00094 struct TrueQuery {
00095 bool operator()(ConnectionInfo const*) const { return true; };
00096 };
00097
00099
00102 View(bool const& reduce_overlap = false);
00103
00105
00111 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);
00112
00114
00121 View(Bag const& bag, boost::function<bool(ConnectionInfo const*)> query,
00122 ros::Time const& start_time = ros::TIME_MIN, ros::Time const& end_time = ros::TIME_MAX, bool const& reduce_overlap = false);
00123
00124 ~View();
00125
00126 iterator begin();
00127 iterator end();
00128 uint32_t size();
00129
00131
00136 void addQuery(Bag const& bag, ros::Time const& start_time = ros::TIME_MIN, ros::Time const& end_time = ros::TIME_MAX);
00137
00139
00145 void addQuery(Bag const& bag, boost::function<bool(ConnectionInfo const*)> query,
00146 ros::Time const& start_time = ros::TIME_MIN, ros::Time const& end_time = ros::TIME_MAX);
00147
00148 std::vector<const ConnectionInfo*> getConnections();
00149
00150 ros::Time getBeginTime();
00151 ros::Time getEndTime();
00152
00153 protected:
00154 friend class iterator;
00155
00156 void updateQueries(BagQuery* q);
00157 void update();
00158
00159 MessageInstance* newMessageInstance(ConnectionInfo const* connection_info, IndexEntry const& index, Bag const& bag);
00160
00161 private:
00162 View(View const& view);
00163 View& operator=(View const& view);
00164
00165 protected:
00166 std::vector<MessageRange*> ranges_;
00167 std::vector<BagQuery*> queries_;
00168 uint32_t view_revision_;
00169
00170 uint32_t size_cache_;
00171 uint32_t size_revision_;
00172
00173 bool reduce_overlap_;
00174 };
00175
00176 }
00177
00178 #endif