RobotsIO
Loading...
Searching...
No Matches
ClockedComponent.cpp
1/*
2 * Copyright (C) 2020 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This software may be modified and distributed under the terms of the
5 * BSD 3-Clause license. See the accompanying LICENSE file for details.
6 */
7
8#include <RobotsIO/Utils/ClockedComponent.h>
9
10using namespace RobotsIO::Utils;
11
12
13ClockedComponent::ClockedComponent()
14{
15 /* Initialize default clock. */
16 clock_ = std::make_shared<Clock>();
17}
18
19
20void ClockedComponent::start_count()
21{
22 current_time_ = clock_->now();
23}
24
25
26double ClockedComponent::stop_count() const
27{
28 return clock_->now() - current_time_;
29}
30
31
32Clock& ClockedComponent::clock()
33{
34 return *clock_;
35}
36
37
38void ClockedComponent::replace_clock(std::shared_ptr<Clock> clock)
39{
40 clock_ = clock;
41}