YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Stamp.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <yarp/os/Stamp.h>
8
9#include <yarp/os/Bottle.h>
12#include <yarp/os/Time.h>
13
14#include <cfloat>
15#include <limits>
16
17yarp::os::Stamp::Stamp(int count, double time)
18{
19 sequenceNumber = count;
20 timeStamp = time;
21}
22
24{
25 sequenceNumber = -1;
26 timeStamp = 0;
27}
28
30{
31 return sequenceNumber;
32}
33
35{
36 return timeStamp;
37}
38
40{
41 return sequenceNumber >= 0;
42}
43
45{
46 return std::numeric_limits<int>::max();
47}
48
50{
51 double now = Time::now();
52
53 if (sequenceNumber >= getMaxCount() || sequenceNumber < 0) {
54 sequenceNumber = 0;
55 } else {
56 sequenceNumber++;
57 }
58 timeStamp = now;
59}
60
61void yarp::os::Stamp::update(double time)
62{
63 if (sequenceNumber >= getMaxCount() || sequenceNumber < 0) {
64 sequenceNumber = 0;
65 } else {
66 sequenceNumber++;
67 }
68 timeStamp = time;
69}
std::int32_t sequenceNumber
Definition StampData.h:29
int getMaxCount() const
Get the maximum sequence number, after which an incrementing sequence should return to zero.
Definition Stamp.cpp:44
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
Definition Stamp.cpp:49
double getTime() const
Get the time stamp.
Definition Stamp.cpp:34
bool isValid() const
Check if this Stamp is valid.
Definition Stamp.cpp:39
Stamp()
Construct an invalid Stamp.
Definition Stamp.cpp:23
int getCount() const
Get the sequence number.
Definition Stamp.cpp:29
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition Time.cpp:121