swift
interpolatormulti.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
7 
8 using namespace swift::misc::aviation;
9 
10 namespace swift::misc::simulation
11 {
12  CInterpolatorMulti::CInterpolatorMulti(const CCallsign &callsign, ISimulationEnvironmentProvider *p1,
14  CInterpolationLogger *logger)
15  : m_spline(callsign, p1, p2, p3, logger), m_linear(callsign, p1, p2, p3, logger)
16  {}
17 
20  uint32_t aircraftNumber)
21  {
22  switch (setup.getInterpolatorMode())
23  {
24  case CInterpolationAndRenderingSetupBase::Linear:
25  return m_linear.getInterpolation(currentTimeSinceEpoch, setup, aircraftNumber);
26  case CInterpolationAndRenderingSetupBase::Spline:
27  return m_spline.getInterpolation(currentTimeSinceEpoch, setup, aircraftNumber);
28  default: break;
29  }
30 
31  return CInterpolationResult();
32  }
33 
34  const CAircraftSituation &
36  {
37  switch (mode)
38  {
39  case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getLastInterpolatedSituation();
40  case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getLastInterpolatedSituation();
41  default: break;
42  }
43  return CAircraftSituation::null();
44  }
45 
47  {
48  m_linear.attachLogger(logger);
49  m_spline.attachLogger(logger);
50  }
51 
53  {
54  m_linear.initCorrespondingModel(model);
55  m_spline.initCorrespondingModel(model);
56  }
57 
58  const CStatusMessageList &
60  {
61  switch (mode)
62  {
63  case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolationMessages();
64  case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolationMessages();
65  default: break;
66  }
67  static const CStatusMessageList empty;
68  return empty;
69  }
70 
72  {
73  switch (mode)
74  {
75  case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolatorInfo();
76  case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolatorInfo();
77  default: break;
78  }
79  return ("Illegal mode");
80  }
81 
83 
87  CInterpolationLogger *logger)
88  {
89  m_interpolator.reset(new CInterpolatorMulti(callsign, p1, p2, p3));
90  m_interpolator->attachLogger(logger);
91  }
92 } // namespace swift::misc::simulation
Status messages, e.g. from Core -> GUI.
Value object encapsulating information of an aircraft's situation.
Value object encapsulating information of a callsign.
Definition: callsign.h:30
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
Value object for interpolator and rendering per callsign.
Record internal state of interpolator for debugging.
CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber)
Get interpolated situation.
void attachLogger(CInterpolationLogger *logger)
Attach an observer to read the interpolator's state for debugging.
Definition: interpolator.h:65
QString getInterpolatorInfo() const
Get an interpolator info string (for debug info)
const aviation::CAircraftSituation & getLastInterpolatedSituation() const
Latest interpolation result.
Definition: interpolator.h:52
const CStatusMessageList & getInterpolationMessages() const
Interpolation messages.
Definition: interpolator.h:88
void initCorrespondingModel(const CAircraftModel &model={})
Init, or re-init the corressponding model.
Multiplexed interpolator which allows switching between modes at runtime.
void initCorrespondingModel(const CAircraftModel &model)
Init, or re-init the corressponding model.
CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber)
Get interpolated situation.
const aviation::CAircraftSituation & getLastInterpolatedSituation(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
Latest interpolation result.
QString getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
Info string.
const CStatusMessageList & getInterpolationMessages(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
Interpolation messages.
void attachLogger(CInterpolationLogger *logger)
Attach an observer to read the interpolator's state for debugging.
CInterpolatorMultiWrapper()
Default ctor, needed for QMap/QHash.
Direct in memory access to interpolation setup, normally implemented by simulator.
Direct thread safe in memory access to remote aircraft.