22 #ifndef QTPDCOM_TRANSMISSION_H 23 #define QTPDCOM_TRANSMISSION_H 25 #include <pdcom5/Subscriber.h> 49 template <
typename T,
typename R>
50 constexpr
Poll(std::chrono::duration<T, R> d):
51 interval_(checkInterval(
52 std::chrono::duration_cast<std::chrono::duration<double>>(d)))
63 std::chrono::duration<double> d)
65 return d.count() <= 0 ?
throw std::invalid_argument(
66 "Poll period must be greater than zero")
81 constexpr
double getInterval() const noexcept {
return interval_; }
83 template <
typename T,
typename R>
86 interval_(checkInterval(
87 std::chrono::duration_cast<std::chrono::duration<double>>(d)
92 mode_(Event), interval_(0.0) {}
95 mode_(
Poll), interval_(checkInterval(interval)) {}
98 mode_(
Poll), interval_(poll.getInterval().count()) {}
102 return o.interval_ == interval_ and o.mode_ == mode_;
107 return mode_ == Continuous and interval_ > 0.0;
112 return mode_ ==
Poll and interval_ > 0.0;
115 PdCom::Transmission toPdCom()
const;
116 QString toString()
const;
129 return d <= 0 ?
throw std::invalid_argument(
130 "Interval must be greater than zero")
static constexpr double checkInterval(double d)
Definition: Transmission.h:127
constexpr double getInterval() const noexcept
Definition: Transmission.h:81
Tag for event-based subscription.
Definition: Transmission.h:37
Transmission mode for subscriptions.
Definition: Transmission.h:77
constexpr bool isContinuous() const
Definition: Transmission.h:105
Definition: BroadcastModel.h:32
constexpr Poll(std::chrono::duration< T, R > d)
Definition: Transmission.h:50
constexpr Transmission(const Poll &poll)
Definition: Transmission.h:97
#define QTPDCOM_PUBLIC
Definition: Export.h:30
std::chrono::duration< double > interval_
Definition: Transmission.h:60
static constexpr std::chrono::duration< double > checkInterval(std::chrono::duration< double > d)
Definition: Transmission.h:62
Definition: Transmission.h:121
constexpr bool isPoll() const
Definition: Transmission.h:110
double interval_
Definition: Transmission.h:125
Tag for poll-based subscription.
Definition: Transmission.h:42
constexpr std::chrono::duration< double > getInterval() const
Definition: Transmission.h:55
constexpr Transmission(poll_mode_tag, double interval)
Definition: Transmission.h:94
constexpr Transmission(event_mode_tag) noexcept
Definition: Transmission.h:91
Definition: Transmission.h:46
bool operator==(const Transmission &o) const noexcept
Definition: Transmission.h:100
constexpr struct QtPdCom::poll_mode_tag poll_mode
constexpr Transmission(std::chrono::duration< T, R > d)
Definition: Transmission.h:84
constexpr struct QtPdCom::event_mode_tag event_mode