rate_filter.h 2.76 KB
Newer Older
Pascal Palenda's avatar
Pascal Palenda committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_AUDIBILITY_FILTER_RATE_FILTER
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_AUDIBILITY_FILTER_RATE_FILTER

// API includes
#include <ITA/simulation_scheduler/definitions.h>

// simulation scheduler includes
#include <ITA/simulation_scheduler/audibility_filter/audibility_filter_interface.h>

// Vista includes
#include <VistaAspects/VistaPropertyList.h>

namespace ITA
{
15
	namespace SimulationScheduler
Pascal Palenda's avatar
Pascal Palenda committed
16
17
18
	{
		class CUpdateScene;

19
		namespace AudibilityFilter
Pascal Palenda's avatar
Pascal Palenda committed
20
21
22
23
24
		{
			///
			/// \brief Rate filter
			///
			/// This class implements a simple rate filter.
Pascal Palenda's avatar
Pascal Palenda committed
25
			/// Only if the time interval between the two updates exceeds the configured rate, the update is considered audible.
Pascal Palenda's avatar
Pascal Palenda committed
26
27
28
29
30
31
32
33
34
			/// 
			class ITA_SIMULATION_SCHEDULER_API CRateFilter : public IAudibilityFilter
			{
			public:
				///
				/// \brief Configuration class for the rate filter.
				///
				struct ITA_SIMULATION_SCHEDULER_API RateFilterConfig : public IAudibilityFilter::AudibilityFilterConfig
				{
35
					explicit RateFilterConfig ( );
Pascal Palenda's avatar
Pascal Palenda committed
36
					
37
38
					double dRate = 1.0;

39
					VistaPropertyList Store ( ) const override;
40

41
					void Load ( const VistaPropertyList& oProperties ) override;
Pascal Palenda's avatar
Pascal Palenda committed
42
43
44
45
				};

				CRateFilter ( ) = delete;

Pascal Palenda's avatar
Pascal Palenda committed
46
47
48
49
50
51
52
				///
				/// \brief Constructor for a CRateFilter.
				///
				/// This constructor configures the CRateFilter with the given \p oConfig.
				/// \param oConfig the configuration for the CRateFilter.
				/// 
				explicit CRateFilter ( const RateFilterConfig& oConfig );
Pascal Palenda's avatar
Pascal Palenda committed
53
54
55
56
57

				// 
				///
				/// \brief Check if the change between \p previousState and \p newUpdate is audible.
				///
Pascal Palenda's avatar
Pascal Palenda committed
58
				/// The change between \p previousState and \p newUpdate is audible when the time between the two updates is larger than the configured rate.
Pascal Palenda's avatar
Pascal Palenda committed
59
60
61
62
				/// \param previousState the previous state of the scene to check against.
				/// \param newUpdate the CUpdateScene to check for audibility.
				/// \return true if the change between \p previousState and \p newUpdate is audible, else false.
				/// 
63
				virtual bool ChangeIsAudible ( const CUpdateScene& previousState, const CUpdateScene& newUpdate ) const override;
Pascal Palenda's avatar
Pascal Palenda committed
64

65
66
67
68
				///
				/// \brief Return a unique type identifying string.
				/// \return a unique type identifying string.
				/// 
69
				static std::string GetType();
70
				
Pascal Palenda's avatar
Pascal Palenda committed
71
72
73
74
				///
				/// \brief Factory function for a filter.
				/// \remark This function should to be static.
				///
75
				static std::unique_ptr<IAudibilityFilter> CreateFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
Pascal Palenda's avatar
Pascal Palenda committed
76
77

			private:
Pascal Palenda's avatar
Pascal Palenda committed
78
79
80
				///
				/// \brief The minimum rate of the filter.
				/// 
Pascal Palenda's avatar
Pascal Palenda committed
81
82
				double m_dRate;
			};
83
84
		} // namespace AudibilityFilter
	} // namespace SimulationScheduler
Pascal Palenda's avatar
Pascal Palenda committed
85
86
87
} // namespace ITA

#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_AUDIBILITY_FILTER_RATE_FILTER