Gazebo Transport

API Reference

11.4.2
gz/transport/log/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 
28 {
29  // Inline bracket to help doxygen filtering.
30  inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
31  //
40  class IGNITION_TRANSPORT_LOG_VISIBLE QualifiedTime
41  {
44  public: enum class Qualifier : int64_t
45  {
49  INCLUSIVE = 0,
50 
55  EXCLUSIVE
56  };
57 
71 
77  public: QualifiedTime(const Time &_time,
78  Qualifier _qualifier = Qualifier::INCLUSIVE);
79 
86  public: template <typename Rep, typename Period>
88  Qualifier _qualifier = Qualifier::INCLUSIVE)
89  : QualifiedTime(static_cast<const Time &>(_time), _qualifier) { }
90 
95  public: QualifiedTime(/* Indeterminate */);
96 
99  public: QualifiedTime(const QualifiedTime &_other);
100 
104  public: QualifiedTime &operator=(const QualifiedTime &_other);
105 
108  public: QualifiedTime(QualifiedTime &&_old) = default; // NOLINT
109 
113  QualifiedTime &&) = default; // NOLINT(build/c++11)
114 
120  public: bool operator==(const QualifiedTime &_other) const;
121 
125  public: bool operator!=(const QualifiedTime &_other) const;
126 
136  public: bool IsIndeterminate() const;
137 
143  public: const Time *GetTime() const;
144 
150  public: const Qualifier *GetQualifier() const;
151 
157  public: void SetTime(const Time &_time,
158  Qualifier _qualifier = Qualifier::INCLUSIVE);
159 
162  public: void Clear();
163 
165  public: ~QualifiedTime();
166 
168  private: class Implementation;
169 
170 #ifdef _WIN32
171 // Disable warning C4251 which is triggered by
172 // std::*
173 #pragma warning(push)
174 #pragma warning(disable: 4251)
175 #endif
178  private: std::unique_ptr<Implementation, void (*)(Implementation*)> dataPtr;
179 #ifdef _WIN32
180 #pragma warning(pop)
181 #endif
182  };
183 
188  class IGNITION_TRANSPORT_LOG_VISIBLE QualifiedTimeRange
189  {
197  const QualifiedTime &_begin,
198  const QualifiedTime &_end);
199 
202  public: QualifiedTimeRange(const QualifiedTimeRange &_other);
203 
208 
211  public: QualifiedTimeRange(QualifiedTimeRange &&_old); // NOLINT
212 
216  QualifiedTimeRange &&) = default; // NOLINT(build/c++11)
217 
222  public: bool operator==(const QualifiedTimeRange &_other) const;
223 
227  public: bool operator!=(const QualifiedTimeRange &_other) const;
228 
232  public: static QualifiedTimeRange From(const QualifiedTime &_begin);
233 
238  public: static QualifiedTimeRange Until(const QualifiedTime &_end);
239 
242  public: static QualifiedTimeRange AllTime();
243 
246  public: const QualifiedTime &Beginning() const;
247 
250  public: const QualifiedTime &Ending() const;
251 
261  public: bool SetBeginning(const QualifiedTime &_begin);
262 
272  public: bool SetEnding(const QualifiedTime &_end);
273 
283  public: bool SetRange(const QualifiedTime &_begin,
284  const QualifiedTime &_end);
285 
290  public: bool Valid() const;
291 
294 
296  private: class Implementation;
297 
298 #ifdef _WIN32
299 // Disable warning C4251 which is triggered by
300 // std::*
301 #pragma warning(push)
302 #pragma warning(disable: 4251)
303 #endif
306  private: std::unique_ptr<Implementation, void(*)(Implementation*)> dataPtr;
307 #ifdef _WIN32
308 #pragma warning(pop)
309 #endif
310  };
311  }
312 }
313 
314 #endif
The QualifiedTimeRange class provides a pair of qualified times that represent a range....
Definition: gz/transport/log/QualifiedTime.hh:189
bool SetEnding(const QualifiedTime &_end)
Set the finish time of this range. Passing in an indeterminate QualifiedTime (its default constructor...
static QualifiedTimeRange AllTime()
Construct a time range that has no beginning or end.
QualifiedTimeRange(QualifiedTimeRange &&_old)
Default move constructor.
QualifiedTimeRange & operator=(QualifiedTimeRange &&)=default
Default move assignment.
static QualifiedTimeRange Until(const QualifiedTime &_end)
Construct a time range that ends at _end and has no beginning.
const QualifiedTime & Ending() const
Get a reference to the end time of this range.
QualifiedTimeRange(const QualifiedTimeRange &_other)
Copy constructor.
bool Valid() const
Check if the range is valid. A valid range means that the finish time is guaranteed to be later than ...
bool SetRange(const QualifiedTime &_begin, const QualifiedTime &_end)
Set both endpoints of the range.
static QualifiedTimeRange From(const QualifiedTime &_begin)
Construct a time range that begins at _begin and never ends.
const QualifiedTime & Beginning() const
Get a reference to the start time of this range.
QualifiedTimeRange & operator=(const QualifiedTimeRange &_other)
Copy assignment operator.
bool SetBeginning(const QualifiedTime &_begin)
Set the start time of this range. Passing in an indeterminate QualifiedTime (its default constructor)...
QualifiedTimeRange(const QualifiedTime &_begin, const QualifiedTime &_end)
Construct a time range.
bool operator!=(const QualifiedTimeRange &_other) const
Inequality operator.
bool operator==(const QualifiedTimeRange &_other) const
Equality operator.
Since time is continuous, it may be difficult to know the exact time stamp of a desired message....
Definition: gz/transport/log/QualifiedTime.hh:41
QualifiedTime(const QualifiedTime &_other)
Copy constructor.
QualifiedTime & operator=(QualifiedTime &&)=default
move assignment operator
QualifiedTime(const Time &_time, Qualifier _qualifier=Qualifier::INCLUSIVE)
Construct a qualified time specifier.
bool operator!=(const QualifiedTime &_other) const
Inequality operator.
const Qualifier * GetQualifier() const
Get the qualifier for this qualified time, unless the time is indeterminate.
bool operator==(const QualifiedTime &_other) const
Equality operator.
void SetTime(const Time &_time, Qualifier _qualifier=Qualifier::INCLUSIVE)
Set the time that this QualifiedTime object represents.
QualifiedTime & operator=(const QualifiedTime &_other)
Copy assignment operator.
QualifiedTime(const std::chrono::duration< Rep, Period > &_time, Qualifier _qualifier=Qualifier::INCLUSIVE)
Construct a qualified time specifier. This allows implicit conversion from any std::chrono::duration ...
Definition: gz/transport/log/QualifiedTime.hh:87
void Clear()
Set this QualifiedTime object to be indeterminate.
const Time * GetTime() const
Get the time stamp for this qualified time, unless the time is indeterminate.
bool IsIndeterminate() const
Indicates whether this QualifiedTime object is indeterminate.
Qualifier
The Qualifier determines the behavior of how a message is selected.
Definition: gz/transport/log/QualifiedTime.hh:45
QualifiedTime()
Default constructor. The time will be treated as indeterminate. This means that the QualifiedTime obj...
QualifiedTime(QualifiedTime &&_old)=default
move constructor
Definition: gz/transport/log/Batch.hh:28