Gazebo Transport

API Reference

8.5.0
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 
33 namespace ignition
34 {
35  namespace transport
36  {
37  namespace log
38  {
39  // Inline bracket to help doxygen filtering.
40  inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
41  //
45  class IGNITION_TRANSPORT_LOG_VISIBLE QueryOptions
46  {
51  public: virtual std::vector<SqlStatement> GenerateStatements(
52  const Descriptor &_descriptor) const = 0;
53 
67  public: static SqlStatement StandardMessageQueryPreamble();
68 
74  public: static SqlStatement StandardMessageQueryClose();
75 
77  public: virtual ~QueryOptions() = default;
78  };
79 
83  class IGNITION_TRANSPORT_LOG_VISIBLE TimeRangeOption
84  {
87  public: explicit TimeRangeOption(const QualifiedTimeRange &_timeRange);
88 
91  public: TimeRangeOption(const TimeRangeOption &_other);
92 
95  public: TimeRangeOption(TimeRangeOption &&_other); // NOLINT
96 
100  public: QualifiedTimeRange &TimeRange();
101 
105  public: const QualifiedTimeRange &TimeRange() const;
106 
111  public: SqlStatement GenerateTimeConditions() const;
112 
114  public: ~TimeRangeOption();
115 
117  private: class Implementation;
118 
119 #ifdef _WIN32
120 // Disable warning C4251 which is triggered by
121 // std::*
122 #pragma warning(push)
123 #pragma warning(disable: 4251)
124 #endif
125  private: std::unique_ptr<Implementation> dataPtr;
127 #ifdef _WIN32
128 #pragma warning(pop)
129 #endif
130  };
131 
134  class IGNITION_TRANSPORT_LOG_VISIBLE TopicList final
135  : public virtual QueryOptions,
136  public virtual TimeRangeOption
137  {
142  public: TopicList(
143  const std::set<std::string> &_topics = { },
144  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
145 
151  public: template <typename Container>
152  static TopicList Create(
153  const Container &_topics,
154  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
155 
160  public: TopicList(
161  const std::string &_singleTopic,
162  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
163 
166  public: TopicList(const TopicList &_other);
167 
170  public: TopicList(TopicList &&_other); // NOLINT(whitespace/operators)
171 
175  public: std::set<std::string> &Topics();
176 
180  public: const std::set<std::string> &Topics() const;
181 
182  // Documentation inherited
183  public: std::vector<SqlStatement> GenerateStatements(
184  const Descriptor &_descriptor) const override;
185 
187  public: ~TopicList();
188 
190  private: class Implementation;
191 
192 #ifdef _WIN32
193 // Disable warning C4251 which is triggered by
194 // std::*
195 #pragma warning(push)
196 #pragma warning(disable: 4251)
197 #endif
198  private: std::unique_ptr<Implementation> dataPtr;
200 #ifdef _WIN32
201 #pragma warning(pop)
202 #endif
203  };
204 
207  class IGNITION_TRANSPORT_LOG_VISIBLE TopicPattern final
208  : public virtual QueryOptions,
209  public virtual TimeRangeOption
210  {
215  public: TopicPattern(
216  const std::regex &_pattern,
217  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
218 
221  public: TopicPattern(const TopicPattern &_other);
222 
225  public: TopicPattern(TopicPattern &&_other); // NOLINT
226 
230  public: std::regex &Pattern();
231 
235  public: const std::regex &Pattern() const;
236 
237  // Documentation inherited
238  public: std::vector<SqlStatement> GenerateStatements(
239  const Descriptor &_descriptor) const override;
240 
242  public: ~TopicPattern();
243 
245  private: class Implementation;
246 
247 #ifdef _WIN32
248 // Disable warning C4251 which is triggered by
249 // std::*
250 #pragma warning(push)
251 #pragma warning(disable: 4251)
252 #endif
253  private: std::unique_ptr<Implementation> dataPtr;
255 #ifdef _WIN32
256 #pragma warning(pop)
257 #endif
258  };
259 
262  class IGNITION_TRANSPORT_LOG_VISIBLE AllTopics final
263  : public virtual QueryOptions,
264  public virtual TimeRangeOption
265  {
269  public: explicit AllTopics(
270  const QualifiedTimeRange &_timeRange = QualifiedTimeRange::AllTime());
271 
274  public: AllTopics(const AllTopics &_other);
275 
278  public: AllTopics(AllTopics &&_other); // NOLINT(whitespace/operators)
279 
280  // Documentation inherited
281  public: std::vector<SqlStatement> GenerateStatements(
282  const Descriptor &_descriptor) const override;
283 
285  public: ~AllTopics();
286 
288  private: class Implementation;
289 
290 #ifdef _WIN32
291 // Disable warning C4251 which is triggered by
292 // std::*
293 #pragma warning(push)
294 #pragma warning(disable: 4251)
295 #endif
296  private: std::unique_ptr<Implementation> dataPtr;
298 #ifdef _WIN32
299 #pragma warning(pop)
300 #endif
301  };
302  }
303  }
304  }
305 }
306 
307 #include <gz/transport/log/detail/QueryOptions.hh>
308 
309 #endif
Specify a pattern of topics to query.
Definition: gz/transport/log/QueryOptions.hh:207
Definition: gz/transport/AdvertiseOptions.hh:28
STL class.
STL class.
The QualifiedTimeRange class provides a pair of qualified times that represent a range....
Definition: gz/transport/log/QualifiedTime.hh:193
T log(T... args)
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:83
Specify a list of topics to query.
Definition: gz/transport/log/QueryOptions.hh:134
Query for all the topics.
Definition: gz/transport/log/QueryOptions.hh:262
A statement for a SQL query. These are generated by the QueryOptions class to control how messages ge...
Definition: gz/transport/log/SqlStatement.hh:153
The Descriptor class provides meta-information about what a log contains. This may be useful for dete...
Definition: gz/transport/log/Descriptor.hh:45
STL class.
The QueryOptions interface is used by Log::QueryMessages() to determine which messages are retrieved ...
Definition: gz/transport/log/QueryOptions.hh:45