audibility_filter_interface.h 4.6 KB
Newer Older
1
2
3
4
5
6
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_AUDIBILITY_FILTER_AUDIBILITY_FILTER_INTERFACE
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_AUDIBILITY_FILTER_AUDIBILITY_FILTER_INTERFACE

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

7
8
9
// simulation scheduler includes
#include <ITA/simulation_scheduler/config_interface.h>

10
11
12
// std includes
#include <memory>
#include <functional>
13
#include <vector>
14
15
16
17
18
19
20
21
22
23
24
25

namespace ITA
{
	namespace simulation_scheduler
	{
		class CUpdateScene;

		namespace audibility_filter
		{
			///
			/// \brief The interface for an audibility filter.
			///
26
			/// An audibility filter is used to determine the audibility of the change between two CUpdateScenes.
27
			///
28
			/// An audibility filter is created by CAudibilityFilterFactory.
29
30
31
			/// For this, a function like this is necessary:
			/// \code{.cpp}
			/// ///
32
			/// /// \brief Factory function for an audibility filter.
33
34
			/// /// \remark This function should to be static.
			/// ///
35
			/// static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
36
37
			/// \endcode
			/// 
Pascal Palenda's avatar
Pascal Palenda committed
38
			class ITA_SIMULATION_SCHEDULER_API IAudibilityFilter
39
40
			{
			public:
41
42
43
44
45
46
				enum class UsageMode
				{
					filter,
					condition
				};
				
47
				///
48
49
				/// \brief Configuration class for an audibility filter.
				///
50
				struct ITA_SIMULATION_SCHEDULER_API AudibilityFilterConfig : public IConfig
51
				{
52
					AudibilityFilterConfig ( );
53
					
54
					explicit AudibilityFilterConfig ( std::string sType );
55

56
57
58
59
60
61
62
					AudibilityFilterConfig ( const AudibilityFilterConfig& other );

					AudibilityFilterConfig& operator=( const AudibilityFilterConfig& other );

					std::string sFilterName = "Unknown";
					
					const std::string& sFilterType; 
63
64
65
66
67

					std::vector<std::string> sNextFilter;
					
					UsageMode eUsageMode = UsageMode::filter;

68
					bool bInvertCondition = false;
69
70
					
					VistaPropertyList store() const override;
71

72
					void load(const VistaPropertyList& oProperties) override;
73

74
75
76
				private:
					std::string m_sFilterType;
				};
77

78
79
80
				///
				/// \brief Check if the change between \p previousState and \p newUpdate is audible.
				///
Pascal Palenda's avatar
Pascal Palenda committed
81
				/// \note Default behaviour it to return false.
82
83
84
				/// \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.
85
				///
86
				virtual bool changeIsAudible ( const CUpdateScene& previousState, const CUpdateScene& newUpdate ) const = 0;
87
88
89

			protected:
				///
Pascal Palenda's avatar
Pascal Palenda committed
90
91
92
93
				/// \brief Checks weather the \p newUpdate happened after \p previousState.
				/// \throws ITAExcept when \p previousState happened after \p newUpdate.
				/// \param previousState CUpdateScene of the previous state.
				/// \param newUpdate new CUpdateScene.
94
				/// 
95
				static void checkUpdateTimestamp ( const CUpdateScene& previousState, const CUpdateScene& newUpdate );
96
97
98
99
100
101
102
			};

			///
			/// \brief Factory class for filter.
			///
			/// This class implements an extensible factory for filter.
			/// After a type of filter is registered with its IAudibilityFilter::createFilter, it can be created using this factory.
Pascal Palenda's avatar
Pascal Palenda committed
103
			///
104
105
106
107
			class ITA_SIMULATION_SCHEDULER_API CAudibilityFilterFactory
			{
			public:
				///
Pascal Palenda's avatar
Pascal Palenda committed
108
109
				/// \brief The function signature for a create function.
				///
110
				typedef std::function<std::unique_ptr<IAudibilityFilter> ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )> CreateCallback;
111
112
113
114
115

				///
				/// \brief Register a type of filter to the factory.
				/// \param type name of the filter type to be registered.
				/// \param createFunction the corresponding create function.
Pascal Palenda's avatar
Pascal Palenda committed
116
				///
117
118
119
120
121
				static void registerFilter ( const std::string& type, CreateCallback createFunction );

				///
				/// \brief Unregister a type of filter from the factory.
				/// \param type name of the filter type to be removed.
Pascal Palenda's avatar
Pascal Palenda committed
122
				///
123
124
125
126
127
128
				static void unregisterFilter ( const std::string& type );

				///
				/// \brief Factory method.
				/// \param pConfig the configuration for the filter.
				/// \return a pointer to the created filter.
Pascal Palenda's avatar
Pascal Palenda committed
129
				///
130
				static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
131

Pascal Palenda's avatar
Pascal Palenda committed
132
			private:
133
134
				///
				/// \brief Map containing all creation functions.
Pascal Palenda's avatar
Pascal Palenda committed
135
				///
136
137
138
139
140
141
142
				static std::map<std::string, CreateCallback> m_mFilters;
			};
		} // namespace audibility_filter
	} // namespace simulation_scheduler
} // namespace ITA

#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_AUDIBILITY_FILTER_AUDIBILITY_FILTER_INTERFACE