SatCat5
ptp_source.cc
1 // Copyright 2024 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 
7 #include <satcat5/ptp_source.h>
8 
12 
13 void Source::notify_callbacks(const Measurement& meas) {
14  Callback* current = m_callbacks.head();
15  while (current) {
16  current->ptp_ready(meas);
17  current = m_callbacks.next(current);
18  }
19 }
20 
22  : m_source(source), m_next(0)
23 {
24  if (m_source) {
25  m_source->add_callback(this);
26  }
27 }
28 
29 Callback::~Callback() {
30  if (m_source) {
31  m_source->remove_callback(this);
32  }
33 }
PTP callback accepts each complete measurement from the Source.
Definition: ptp_source.h:38
Callback(satcat5::ptp::Source *source)
If a source pointer is provided, call add_callback.
Definition: ptp_source.cc:21
virtual void ptp_ready(const satcat5::ptp::Measurement &data)=0
The child class MUST override this method.
A source for ptp::Measurement events, usually a ptp::Client.
Definition: ptp_source.h:19
satcat5::util::List< satcat5::ptp::Callback > m_callbacks
Linked list of registered callback objects.
Definition: ptp_source.h:32
T * next(const T *item) const
Fetch pointer to the next item.
Definition: list.h:261
Define the data structure for a two-way time transfer handshake.
Define the API for generating ptp::Measurement events.
Timestamps and metadata for a two-way time-transfer handshake.