Gazebo Transport

API Reference

14.0.0~pre1
QualifiedTime.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#ifndef GZ_TRANSPORT_LOG_QUALIFIEDTIME_HH_
18#define GZ_TRANSPORT_LOG_QUALIFIEDTIME_HH_
19
20#include <chrono>
21#include <cstdint>
22#include <memory>
23
24#include <gz/transport/config.hh>
25#include <gz/transport/log/Export.hh>
26
27namespace gz
28{
29 namespace transport
30 {
31 namespace log
32 {
33 // Inline bracket to help doxygen filtering.
34 inline namespace GZ_TRANSPORT_VERSION_NAMESPACE {
35 //
44 class GZ_TRANSPORT_LOG_VISIBLE QualifiedTime
45 {
48 public: enum class Qualifier : int64_t
49 {
53 INCLUSIVE = 0,
54
59 EXCLUSIVE
60 };
61
75
81 public: QualifiedTime(const Time &_time,
82 Qualifier _qualifier = Qualifier::INCLUSIVE);
83
90 public: template <typename Rep, typename Period>
92 Qualifier _qualifier = Qualifier::INCLUSIVE)
93 : QualifiedTime(static_cast<const Time &>(_time), _qualifier) { }
94
99 public: QualifiedTime(/* Indeterminate */);
100
103 public: QualifiedTime(const QualifiedTime &_other);
104
108 public: QualifiedTime &operator=(const QualifiedTime &_other);
109
112 public: QualifiedTime(QualifiedTime &&_old) = default; // NOLINT
113
117 QualifiedTime &&) = default; // NOLINT(build/c++11)
118
124 public: bool operator==(const QualifiedTime &_other) const;
125
129 public: bool operator!=(const QualifiedTime &_other) const;
130
140 public: bool IsIndeterminate() const;
141
147 public: const Time *GetTime() const;
148
154 public: const Qualifier *GetQualifier() const;
155
161 public: void SetTime(const Time &_time,
162 Qualifier _qualifier = Qualifier::INCLUSIVE);
163
166 public: void Clear();
167
169 public: ~QualifiedTime();
170
172 private: class Implementation;
173
174#ifdef _WIN32
175// Disable warning C4251 which is triggered by
176// std::*
177#pragma warning(push)
178#pragma warning(disable: 4251)
179#endif
182 private: std::unique_ptr<Implementation,
183 void (*)(Implementation*)> dataPtr;
184#ifdef _WIN32
185#pragma warning(pop)
186#endif
187 };
188
193 class GZ_TRANSPORT_LOG_VISIBLE QualifiedTimeRange
194 {
202 const QualifiedTime &_begin,
203 const QualifiedTime &_end);
204
208
213
216 public: QualifiedTimeRange(QualifiedTimeRange &&_old); // NOLINT
217
221 QualifiedTimeRange &&) = default; // NOLINT(build/c++11)
222
227 public: bool operator==(const QualifiedTimeRange &_other) const;
228
232 public: bool operator!=(const QualifiedTimeRange &_other) const;
233
237 public: static QualifiedTimeRange From(const QualifiedTime &_begin);
238
243 public: static QualifiedTimeRange Until(const QualifiedTime &_end);
244
247 public: static QualifiedTimeRange AllTime();
248
251 public: const QualifiedTime &Beginning() const;
252
255 public: const QualifiedTime &Ending() const;
256
266 public: bool SetBeginning(const QualifiedTime &_begin);
267
277 public: bool SetEnding(const QualifiedTime &_end);
278
288 public: bool SetRange(const QualifiedTime &_begin,
289 const QualifiedTime &_end);
290
295 public: bool Valid() const;
296
299
301 private: class Implementation;
302
303#ifdef _WIN32
304// Disable warning C4251 which is triggered by
305// std::*
306#pragma warning(push)
307#pragma warning(disable: 4251)
308#endif
311 private: std::unique_ptr<Implementation,
312 void(*)(Implementation*)> dataPtr;
313#ifdef _WIN32
314#pragma warning(pop)
315#endif
316 };
317 }
318 }
319 }
320}
321
322#endif