audibility_filter_interface.h 5.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
// simulation scheduler includes
8
#include <ITA/simulation_scheduler/audibility_filter/filter_condition_interface.h>
9

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

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

namespace ITA
{
	namespace simulation_scheduler
	{
		class CUpdateScene;

		namespace audibility_filter
		{
			///
			/// \brief The interface for an audibility filter.
			///
29
			/// An audibility filter is used to determine the audibility of the change between two CUpdateScenes.
30
			///
31
			/// An audibility filter is created by CAudibilityFilterFactory.
32
33
34
			/// For this, a function like this is necessary:
			/// \code{.cpp}
			/// ///
35
			/// /// \brief Factory function for an audibility filter.
36
37
			/// /// \remark This function should to be static.
			/// ///
Pascal Palenda's avatar
Pascal Palenda committed
38
			/// static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& );
39
40
			/// \endcode
			/// 
Pascal Palenda's avatar
Pascal Palenda committed
41
			class ITA_SIMULATION_SCHEDULER_API IAudibilityFilter
42
43
44
			{
			public:
				///
45
46
47
				/// \brief Configuration class for an audibility filter.
				///
				struct ITA_SIMULATION_SCHEDULER_API AudibilityFilterConfig : public VistaPropertyList
48
				{
49
50
51
52
53
54
55
					///
					/// \brief Set the condition filter config of the AudibilityFilterConfig.
					///
					/// The order of the condition filters is also saved in the config.
					/// \param vFilterConfig all filter to add to the config.
					/// \todo Do we set or add filter configs? If we set, do we overwrite?
					///
56
					void setConditionFilterConfig (	const std::vector<IFilterCondition::FilterConditionConfig>& vFilterConfig );
57
58
59
60
61
62
63

					///
					/// \brief Get all condition filter configs from the AudibilityFilterConfig.
					///
					/// The order in which the condition filters were set in the config is also represented in the vector.
					/// \return a vector with all condition filter configs.
					///
64
					std::vector<IFilterCondition::FilterConditionConfig> getConditionFilterConfig ( ) const;
65
				};
66
67

				///
68
				/// \brief Constructor for IAudibilityFilter.
69
				///
70
71
				/// This constructor configures the condition filters of the IAudibilityFilter.
				/// \param oConfig the AudibilityFilterConfig used to configure the IAudibilityFilter.
72
				/// 
73
74
75
76
77
78
79
80
81
82
				explicit IAudibilityFilter ( const AudibilityFilterConfig& oConfig );

				///
				/// \brief Pure virtual destructor.
				/// 
				virtual ~IAudibilityFilter ( ) = 0;

				IAudibilityFilter ( const IAudibilityFilter& other ) = delete;

				IAudibilityFilter& operator=( const IAudibilityFilter& other ) = delete;
83
84
85
86

				///
				/// \brief Check if the change between \p previousState and \p newUpdate is audible.
				///
Pascal Palenda's avatar
Pascal Palenda committed
87
				/// \note Default behaviour it to return the default result of IFilterCondition::conditionFulfilled.
88
89
90
				/// \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.
91
92
93
94
95
96
97
				///
				virtual bool changeIsAudible ( const CUpdateScene& previousState, const CUpdateScene& newUpdate );

			protected:
				///
				/// \brief Check if all conditions are met.
				///
Pascal Palenda's avatar
Pascal Palenda committed
98
				/// This functions calls IFilterCondition::conditionFulfilled of all IFilterCondition%s in ::m_lpConditionFilters.
99
100
101
102
103
104
105
106
				/// \param previousState the previous state of the scene to check against.
				/// \param newUpdate the CUpdateScene to check for audibility.
				/// \return true, if all conditions are fulfilled.
				///
				bool checkAllConditions ( const CUpdateScene& previousState, const CUpdateScene& newUpdate );

				///
				/// \brief Vector of the condition filters belonging to IAudibilityFilter.
107
				/// 
108
				std::vector<std::unique_ptr<IFilterCondition>> m_lpConditionFilters;
109
110
111
112
113
114
115
			};

			///
			/// \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
116
			///
117
118
119
120
			class ITA_SIMULATION_SCHEDULER_API CAudibilityFilterFactory
			{
			public:
				///
Pascal Palenda's avatar
Pascal Palenda committed
121
122
				/// \brief The function signature for a create function.
				///
123
124
125
126
127
128
				typedef std::function<std::unique_ptr<IAudibilityFilter> ( const IAudibilityFilter::AudibilityFilterConfig& )> CreateCallback;

				///
				/// \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
129
				///
130
131
132
133
134
				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
135
				///
136
137
138
139
140
141
				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
142
				///
143
144
				static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& pConfig );

Pascal Palenda's avatar
Pascal Palenda committed
145
			private:
146
147
				///
				/// \brief Map containing all creation functions.
Pascal Palenda's avatar
Pascal Palenda committed
148
				///
149
150
151
152
153
154
155
				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