query.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009, Willow Garage, Inc.
2 // All rights reserved.
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 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of Willow Garage, Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived from
14 // this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE.
27 
28 #include "rosbag/query.h"
29 #include "rosbag/bag.h"
30 
31 #include <boost/foreach.hpp>
32 
33 #define foreach BOOST_FOREACH
34 
35 using std::map;
36 using std::string;
37 using std::vector;
38 using std::multiset;
39 
40 namespace rosbag {
41 
42 // Query
43 
45  : query_(query), start_time_(start_time), end_time_(end_time)
46 {
47 }
48 
50  return query_;
51 }
52 
55 
56 // TopicQuery
57 
59  topics_.push_back(topic);
60 }
61 
62 TopicQuery::TopicQuery(std::vector<std::string> const& topics) : topics_(topics) { }
63 
65  foreach(string const& topic, topics_)
66  if (topic == info->topic)
67  return true;
68 
69  return false;
70 }
71 
72 // TypeQuery
73 
75  types_.push_back(type);
76 }
77 
78 TypeQuery::TypeQuery(std::vector<std::string> const& types) : types_(types) { }
79 
81  foreach(string const& type, types_)
82  if (type == info->datatype)
83  return true;
84 
85  return false;
86 }
87 
88 // BagQuery
89 
90 BagQuery::BagQuery(Bag const* _bag, Query const& _query, uint32_t _bag_revision) : bag(_bag), query(_query), bag_revision(_bag_revision) {
91 }
92 
93 // MessageRange
94 
95 MessageRange::MessageRange(std::multiset<IndexEntry>::const_iterator const& _begin,
96  std::multiset<IndexEntry>::const_iterator const& _end,
97  ConnectionInfo const* _connection_info,
98  BagQuery const* _bag_query)
99  : begin(_begin), end(_end), connection_info(_connection_info), bag_query(_bag_query)
100 {
101 }
102 
103 // ViewIterHelper
104 
105 ViewIterHelper::ViewIterHelper(std::multiset<IndexEntry>::const_iterator _iter, MessageRange const* _range)
106  : iter(_iter), range(_range)
107 {
108 }
109 
111  return (a.iter)->time > (b.iter)->time;
112 }
113 
114 } // namespace rosbag
boost::function< bool(ConnectionInfo const *)> const & getQuery() const
Get the query functor.
Definition: query.cpp:49
bool operator()(ConnectionInfo const *) const
Definition: query.cpp:80
GLuint GLuint end
GLboolean GLboolean GLboolean b
TypeQuery(std::string const &type)
Definition: query.cpp:74
bool operator()(ViewIterHelper const &a, ViewIterHelper const &b)
Definition: query.cpp:110
boost::function< bool(ConnectionInfo const *)> query_
Definition: query.h:70
rs2rosinternal::Time start_time_
Definition: query.h:71
The actual iterator data structure.
Definition: query.h:123
std::vector< std::string > topics_
Definition: query.h:84
GLsizei const GLchar *const * string
ViewIterHelper(std::multiset< IndexEntry >::const_iterator _iter, MessageRange const *_range)
Definition: query.cpp:105
std::vector< std::string > types_
Definition: query.h:96
GLboolean GLboolean GLboolean GLboolean a
bool operator()(ConnectionInfo const *) const
Definition: query.cpp:64
def info(name, value, persistent=False)
Definition: test.py:301
not_this_one begin(...)
GLsizei GLenum GLenum * types
MessageRange(std::multiset< IndexEntry >::const_iterator const &_begin, std::multiset< IndexEntry >::const_iterator const &_end, ConnectionInfo const *_connection_info, BagQuery const *_bag_query)
Definition: query.cpp:95
unsigned int uint32_t
Definition: stdint.h:80
BagQuery(Bag const *_bag, Query const &_query, uint32_t _bag_revision)
Definition: query.cpp:90
std::multiset< IndexEntry >::const_iterator iter
Definition: query.h:127
Time representation. May either represent wall clock time or ROS clock time.
Definition: time.h:177
rs2rosinternal::Time const & getEndTime() const
Get the end-time.
Definition: query.cpp:54
Pairs of queries and the bags they come from (used internally by View)
Definition: query.h:100
Query(boost::function< bool(ConnectionInfo const *)> &query, rs2rosinternal::Time const &start_time=rs2rosinternal::TIME_MIN, rs2rosinternal::Time const &end_time=rs2rosinternal::TIME_MAX)
The base query takes an optional time-range.
Definition: query.cpp:44
std::string datatype
Definition: structures.h:54
rs2rosinternal::Time const & getStartTime() const
Get the start-time.
Definition: query.cpp:53
GLenum query
Definition: bag.h:66
GLenum type
GLsizei range
rs2rosinternal::Time end_time_
Definition: query.h:72
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
Definition: catch.hpp:4271
TopicQuery(std::string const &topic)
Definition: query.cpp:58


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:39