PLCnext API Documentation 25.0.2.69
ChronoTypes.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Core/Detail/BasicFormatter.hxx"
10#include <chrono>
11#include <iosfwd>
12
13#ifndef ARP_INSIDE_ARP_BASE_CORE_ARP_H
14 #error Never include 'ChronoTypes.hpp' directly, just include 'Arp.h'
15#endif
16
17namespace Arp { namespace Base { namespace Core
18{
19
22
23// chrono types
25using SteadyClock = std::chrono::steady_clock;
26
28using SystemClock = std::chrono::system_clock;
29
31using SteadyTimePoint = SteadyClock::time_point;
32
34using SystemTimePoint = SystemClock::time_point;
35
37using Nanoseconds = std::chrono::nanoseconds;
38
40using Microseconds = std::chrono::microseconds;
41
43using Milliseconds = std::chrono::milliseconds;
44
46using Seconds = std::chrono::seconds;
47
49using Minutes = std::chrono::minutes;
50
52using Hours = std::chrono::hours;
53
63
65struct ARP_BASE_CORE_EXPORT Timeout
66{
68 static const Duration Zero;
70 static const Duration Infinite;
71};
72
74}}} // end of namespace Arp::Base::Core
75
76namespace std
77{
78
79// declarations of ostream operators of all chrono duration types
80ARP_EXPORT std::ostream& operator<<(std::ostream& os, const Arp::Base::Core::Nanoseconds& value);
81ARP_EXPORT std::ostream& operator<<(std::ostream& os, const Arp::Base::Core::Microseconds& value);
82ARP_EXPORT std::ostream& operator<<(std::ostream& os, const Arp::Base::Core::Milliseconds& value);
83ARP_EXPORT std::ostream& operator<<(std::ostream& os, const Arp::Base::Core::Seconds& value);
84ARP_EXPORT std::ostream& operator<<(std::ostream& os, const Arp::Base::Core::Minutes& value);
85ARP_EXPORT std::ostream& operator<<(std::ostream& os, const Arp::Base::Core::Hours& value);
86
87// declarations of istream operators of all chrono duration types
88ARP_EXPORT std::istream& operator>>(std::istream& is, Arp::Base::Core::Nanoseconds& value);
89ARP_EXPORT std::istream& operator>>(std::istream& is, Arp::Base::Core::Microseconds& value);
90ARP_EXPORT std::istream& operator>>(std::istream& is, Arp::Base::Core::Milliseconds& value);
91ARP_EXPORT std::istream& operator>>(std::istream& is, Arp::Base::Core::Seconds& value);
92ARP_EXPORT std::istream& operator>>(std::istream& is, Arp::Base::Core::Minutes& value);
93ARP_EXPORT std::istream& operator>>(std::istream& is, Arp::Base::Core::Hours& value);
94} // end of namespace std
95
97// template specialization of chrono types formatter
98
100template<> struct fmt::formatter<Arp::Base::Core::Nanoseconds> : public fmt::ostream_formatter {};
101
103template<> struct fmt::formatter<Arp::Base::Core::Microseconds> : public fmt::ostream_formatter {};
104
106template<> struct fmt::formatter<Arp::Base::Core::Milliseconds> : public fmt::ostream_formatter {};
107
109template<> struct fmt::formatter<Arp::Base::Core::Seconds> : public fmt::ostream_formatter {};
110
112template<> struct fmt::formatter<Arp::Base::Core::Minutes> : public fmt::ostream_formatter {};
113
115template<> struct fmt::formatter<Arp::Base::Core::Hours> : public fmt::ostream_formatter {};
std::chrono::seconds Seconds
The Arp Seconds unit class.
Definition: ChronoTypes.hpp:46
std::chrono::system_clock SystemClock
Represents the system-wide real time wall clock.
Definition: ChronoTypes.hpp:28
SystemClock::time_point SystemTimePoint
Represents the type of a system clock time-point.
Definition: ChronoTypes.hpp:34
Nanoseconds Duration
Represents a duration in arbitrary units like ns, ms, s and more. The duration unit might not be omit...
Definition: ChronoTypes.hpp:62
std::chrono::minutes Minutes
The Arp Minutes unit class.
Definition: ChronoTypes.hpp:49
std::chrono::steady_clock SteadyClock
Represents the monotonic clock.
Definition: ChronoTypes.hpp:25
std::chrono::hours Hours
The Arp Hours unit class.
Definition: ChronoTypes.hpp:52
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: ChronoTypes.hpp:40
SteadyClock::time_point SteadyTimePoint
Represents the type of a monotonic clock time-point.
Definition: ChronoTypes.hpp:31
std::chrono::nanoseconds Nanoseconds
The Arp Nanoseconds unit class.
Definition: ChronoTypes.hpp:37
std::chrono::milliseconds Milliseconds
The Arp Milliseconds unit class.
Definition: ChronoTypes.hpp:43
Root namespace for the PLCnext API
Namespace of the C++ standard library
Defines some predefined timeouts.
Definition: ChronoTypes.hpp:66
static const Duration Zero
Defines the zero duration.
Definition: ChronoTypes.hpp:68
static const Duration Infinite
Defines the infinite duration.
Definition: ChronoTypes.hpp:70