SatCat5
ptp_source.h
Go to the documentation of this file.
1 // Copyright 2024 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
7 
8 #pragma once
9 
10 #include <satcat5/list.h>
11 #include <satcat5/types.h>
12 
13 namespace satcat5 {
14  namespace ptp {
19  class Source {
20  public:
21  inline void add_callback(satcat5::ptp::Callback* callback)
22  { m_callbacks.add(callback); }
23 
24  inline void remove_callback(satcat5::ptp::Callback* callback)
25  { m_callbacks.remove(callback); }
26 
27  protected:
30 
33  };
34 
38  class Callback {
39  public:
40  // Callback method for incoming ptp::Measurement data.
42  virtual void ptp_ready(const satcat5::ptp::Measurement& data) = 0;
43  protected:
45  explicit Callback(satcat5::ptp::Source* source);
46  ~Callback();
47  satcat5::ptp::Source* const m_source;
48  private:
50  satcat5::ptp::Callback* m_next;
51  };
52  }
53 }
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
void notify_callbacks(const satcat5::ptp::Measurement &meas)
Notify all Callback objects of a new Measurement.
Definition: ptp_source.cc:13
satcat5::util::List< satcat5::ptp::Callback > m_callbacks
Linked list of registered callback objects.
Definition: ptp_source.h:32
Helper functions for manipulating singly-linked lists.
Definition: list.h:52
void add(T *item)
Add new item to front or back, whichever is simpler.
Definition: list.h:221
void remove(T *item)
Remove the designated item from the list.
Definition: list.h:277
Templated functions for manipulating singly-linked lists.
Timestamps and metadata for a two-way time-transfer handshake.
Basic type aliases and prototypes used throughout SatCat5.