audibility_filter_interface.h 4.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#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>

// std includes
#include <memory>
#include <functional>

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

namespace ITA
{
	namespace simulation_scheduler
	{
		class CUpdateScene;

		namespace audibility_filter
		{
			///
			/// \brief The interface for an audibility filter.
			///
			/// A audibility filter is used to determine the audibility of the change between two CUpdateScenes.
			/// These filters can deploy other filters to increase their possibilities.
			///
			/// A filter is created by CFilterFactory.
			/// For this, a function like this is necessary:
			/// \code{.cpp}
			/// ///
			/// /// \brief Factory function for a filter.
			/// /// \remark This function should to be static.
			/// ///
Pascal Palenda's avatar
Pascal Palenda committed
35
			/// static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& );
36
37
			/// \endcode
			/// 
Pascal Palenda's avatar
Pascal Palenda committed
38
			class ITA_SIMULATION_SCHEDULER_API IAudibilityFilter
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
			{
			public:
				///
				/// \brief Configuration class for filter.
				/// \todo This class might be only used to hold other filter configs. See if we should keep this.
				/// 
				class ITA_SIMULATION_SCHEDULER_API AudibilityFilterConfig : public VistaPropertyList
				{
					int i = 6;
				};

				virtual ~IAudibilityFilter ( ) = 0;

				///
				/// \brief Check if the condition is met.
				///
				/// A filter might have a condition that has to be fulfilled to be actually useful.
				/// Another filter might just be a conditional filter.
				/// This function should handle both of these cases.
58
				/// \note Default behaviour it to return true if \p previousState was created before \p newUpdate.
59
60
61
62
63
64
65
66
67
68
69
				/// \param previousState the previous state of the scene to check against.
				/// \param newUpdate the CUpdateScene to check.
				/// \return true if the condition is fulfilled, else false.
				/// 
				virtual bool conditionFulfilled(const CUpdateScene& previousState, const CUpdateScene& newUpdate);

				// 
				///
				/// \brief Check if the change between \p previousState and \p newUpdate is audible.
				///
				///	This function might call ::conditionFulfilled to check if the condition for its test is fulfilled.
70
				/// \note Default behaviour it to return the result of conditionFulfilled.
71
72
73
74
75
76
77
78
79
80
81
82
				/// \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.
				/// 
				virtual bool changeIsAudible(const CUpdateScene& previousState, const CUpdateScene& newUpdate);
			};

			///
			/// \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
83
			///
84
85
86
87
			class ITA_SIMULATION_SCHEDULER_API CAudibilityFilterFactory
			{
			public:
				///
Pascal Palenda's avatar
Pascal Palenda committed
88
89
				/// \brief The function signature for a create function.
				///
90
91
92
93
94
95
				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
96
				///
97
98
99
100
101
				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
102
				///
103
104
105
106
107
108
				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
109
				///
110
111
				static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& pConfig );

Pascal Palenda's avatar
Pascal Palenda committed
112
			private:
113
114
				///
				/// \brief Map containing all creation functions.
Pascal Palenda's avatar
Pascal Palenda committed
115
				///
116
117
118
119
120
121
122
				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