Gazebo Transport

API Reference

11.4.1
gz/transport/log/QueryOptions.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_TRANSPORT_LOG_QUERYOPTIONS_HH_
19 #define GZ_TRANSPORT_LOG_QUERYOPTIONS_HH_
20 
21 #include <memory>
22 #include <regex>
23 #include <set>
24 #include <string>
25 #include <vector>
26 
27 #include <gz/transport/config.hh>
28 #include <gz/transport/log/Export.hh>
32 
34 {
35  // Inline bracket to help doxygen filtering.
36  inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
37  //
41  class IGNITION_TRANSPORT_LOG_VISIBLE QueryOptions
42  {
47  public: virtual std::vector<SqlStatement> GenerateStatements(
48  const Descriptor &_descriptor) const = 0;
49 
63  public: static SqlStatement StandardMessageQueryPreamble();
64 
70  public: static SqlStatement StandardMessageQueryClose();
71 
73  public: virtual ~QueryOptions() = default;
74  };
75 
79  class IGNITION_TRANSPORT_LOG_VISIBLE TimeRangeOption
80  {
83  public: explicit TimeRangeOption(const QualifiedTimeRange &_timeRange);
84 
87  public: TimeRangeOption(const TimeRangeOption &_other);
88 
91  public: TimeRangeOption(TimeRangeOption &&_other); // NOLINT
92 
96  public: QualifiedTimeRange &TimeRange();
97 
101  public: const QualifiedTimeRange &TimeRange() const;
102 
107  public: SqlStatement GenerateTimeConditions() const;
108 
110  public: ~TimeRangeOption();
111 
113  private: class Implementation;
114 
115 #ifdef _WIN32
116 // Disable warning C4251 which is triggered by
117 // std::*
118 #pragma warning(push)
119 #pragma warning(disable: 4251)
120 #endif
121  private: std::unique_ptr<Implementation> dataPtr;
123 #ifdef _WIN32
124 #pragma warning(pop)
125 #endif
126  };
127 
130  class IGNITION_TRANSPORT_LOG_VISIBLE TopicList final
131  : public virtual QueryOptions,
132  public virtual TimeRangeOption
133  {
138  public: TopicList(
139  const std::set<std::string> &_topics = { },
140  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
141 
147  public: template <typename Container>
148  static TopicList Create(
149  const Container &_topics,
150  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
151 
156  public: TopicList(
157  const std::string &_singleTopic,
158  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
159 
162  public: TopicList(const TopicList &_other);
163 
166  public: TopicList(TopicList &&_other); // NOLINT(whitespace/operators)
167 
171  public: std::set<std::string> &Topics();
172 
176  public: const std::set<std::string> &Topics() const;
177 
178  // Documentation inherited
179  public: std::vector<SqlStatement> GenerateStatements(
180  const Descriptor &_descriptor) const override;
181 
183  public: ~TopicList();
184 
186  private: class Implementation;
187 
188 #ifdef _WIN32
189 // Disable warning C4251 which is triggered by
190 // std::*
191 #pragma warning(push)
192 #pragma warning(disable: 4251)
193 #endif
194  private: std::unique_ptr<Implementation> dataPtr;
196 #ifdef _WIN32
197 #pragma warning(pop)
198 #endif
199  };
200 
203  class IGNITION_TRANSPORT_LOG_VISIBLE TopicPattern final
204  : public virtual QueryOptions,
205  public virtual TimeRangeOption
206  {
211  public: TopicPattern(
212  const std::regex &_pattern,
213  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
214 
217  public: TopicPattern(const TopicPattern &_other);
218 
221  public: TopicPattern(TopicPattern &&_other); // NOLINT
222 
226  public: std::regex &Pattern();
227 
231  public: const std::regex &Pattern() const;
232 
233  // Documentation inherited
234  public: std::vector<SqlStatement> GenerateStatements(
235  const Descriptor &_descriptor) const override;
236 
238  public: ~TopicPattern();
239 
241  private: class Implementation;
242 
243 #ifdef _WIN32
244 // Disable warning C4251 which is triggered by
245 // std::*
246 #pragma warning(push)
247 #pragma warning(disable: 4251)
248 #endif
249  private: std::unique_ptr<Implementation> dataPtr;
251 #ifdef _WIN32
252 #pragma warning(pop)
253 #endif
254  };
255 
258  class IGNITION_TRANSPORT_LOG_VISIBLE AllTopics final
259  : public virtual QueryOptions,
260  public virtual TimeRangeOption
261  {
265  public: explicit AllTopics(
266  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
267 
270  public: AllTopics(const AllTopics &_other);
271 
274  public: AllTopics(AllTopics &&_other); // NOLINT(whitespace/operators)
275 
276  // Documentation inherited
277  public: std::vector<SqlStatement> GenerateStatements(
278  const Descriptor &_descriptor) const override;
279 
281  public: ~AllTopics();
282 
284  private: class Implementation;
285 
286 #ifdef _WIN32
287 // Disable warning C4251 which is triggered by
288 // std::*
289 #pragma warning(push)
290 #pragma warning(disable: 4251)
291 #endif
292  private: std::unique_ptr<Implementation> dataPtr;
294 #ifdef _WIN32
295 #pragma warning(pop)
296 #endif
297  };
298  }
299 }
300 
301 #include <gz/transport/log/detail/QueryOptions.hh>
302 
303 #endif
Specify a pattern of topics to query.
Definition: gz/transport/log/QueryOptions.hh:203
STL class.
STL class.
The QualifiedTimeRange class provides a pair of qualified times that represent a range....
Definition: gz/transport/log/QualifiedTime.hh:188
static QualifiedTimeRange AllTime()
Construct a time range that has no beginning or end.
Base class which manages the time range settings for the native QueryOptions classes.
Definition: gz/transport/log/QueryOptions.hh:79
Specify a list of topics to query.
Definition: gz/transport/log/QueryOptions.hh:130
Query for all the topics.
Definition: gz/transport/log/QueryOptions.hh:258
A statement for a SQL query. These are generated by the QueryOptions class to control how messages ge...
Definition: gz/transport/log/SqlStatement.hh:149
The Descriptor class provides meta-information about what a log contains. This may be useful for dete...
Definition: gz/transport/log/Descriptor.hh:41
STL class.
Definition: gz/transport/log/Batch.hh:27
The QueryOptions interface is used by Log::QueryMessages() to determine which messages are retrieved ...
Definition: gz/transport/log/QueryOptions.hh:41