WSF
IntervalUpdater.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI//REL TO USA ONLY
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11#ifndef L16_INTERVALUPDATER_HPP
12#define L16_INTERVALUPDATER_HPP
13
14#include "UtCallback.hpp"
15#include "UtInput.hpp"
16class WsfSimulation;
17
18namespace WsfL16
19{
21{
22class UpdateEvent;
23}
24
25// Classes such as Processors and Movers have an Update() function called
26// on a regular interval. This feature is useful in other places.
27// This class may either be used as a base class by overriding the Update() method
28// or using callbacks added to the OnUpdate callback list.
30{
31public:
33 explicit IntervalUpdater(double aTimeInterval);
35 virtual ~IntervalUpdater();
36
38
39 double GetUpdateInterval() const { return mUpdateInterval; }
40
44 void SetUpdateInterval(double aUpdateInterval);
45
46 double GetLastUpdateTime() { return mLastUpdateTime; }
47
48 virtual void Update(double aSimTime);
49
50 void Initialize(double aSimTime, WsfSimulation& aSimulation, bool aAutoStart = true);
51
52 bool ProcessInput(UtInput& aInput);
53
54 UtCallbackListN<void(double)> OnUpdate;
55
56 double UpdatePrivate(double aSimTime);
57
58 void TurnOn(double aSimTime);
59
60 void TurnOff(double aSimTime);
61
62private:
63 void HandleSimulationComplete(double aSimTime);
64
65 void StartUpdates(double aSimTime);
66
67 void DeleteEvent();
68
69 bool mIsInitialized;
70 double mLastUpdateTime;
71 double mUpdateInterval;
72 IntervalUpdaterPrivate::UpdateEvent* mEventPtr;
73 std::unique_ptr<UtCallback> mSimCompleteCallbackPtr;
74 WsfSimulation* mSimulationPtr;
75};
76} // namespace WsfL16
77
78#endif
void TurnOn(double aSimTime)
Definition IntervalUpdater.cpp:169
void Initialize(double aSimTime, WsfSimulation &aSimulation, bool aAutoStart=true)
Begins creating the update events.
Definition IntervalUpdater.cpp:87
double GetLastUpdateTime()
Definition IntervalUpdater.hpp:46
UtCallbackListN< void(double)> OnUpdate
Definition IntervalUpdater.hpp:54
bool ProcessInput(UtInput &aInput)
Definition IntervalUpdater.cpp:100
double UpdatePrivate(double aSimTime)
Definition IntervalUpdater.cpp:115
virtual ~IntervalUpdater()
Definition IntervalUpdater.cpp:81
void SetUpdateInterval(double aUpdateInterval)
Definition IntervalUpdater.cpp:134
IntervalUpdater()
Definition IntervalUpdater.cpp:53
IntervalUpdater & operator=(const IntervalUpdater &aRhs)=delete
virtual void Update(double aSimTime)
Definition IntervalUpdater.cpp:113
void TurnOff(double aSimTime)
Definition IntervalUpdater.cpp:177
double GetUpdateInterval() const
Definition IntervalUpdater.hpp:39
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition IntervalUpdater.cpp:20
This file should be included prior to defining a message. Currently there is a limit of 32 fields per...
Definition AllMessages.hpp:55
Copyrights Multiple, All Rights Reserved