audibility_filter_interface.h 3.9 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
#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.
			///
25
			/// An audibility filter is used to determine the audibility of the change between two CUpdateScenes.
26
			///
27
			/// An audibility filter is created by CAudibilityFilterFactory.
28
29
30
			/// For this, a function like this is necessary:
			/// \code{.cpp}
			/// ///
31
			/// /// \brief Factory function for an audibility filter.
32
33
			/// /// \remark This function should to be static.
			/// ///
Pascal Palenda's avatar
Pascal Palenda committed
34
			/// static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& );
35
36
			/// \endcode
			/// 
Pascal Palenda's avatar
Pascal Palenda committed
37
			class ITA_SIMULATION_SCHEDULER_API IAudibilityFilter
38
39
40
			{
			public:
				///
41
42
43
				/// \brief Configuration class for an audibility filter.
				///
				struct ITA_SIMULATION_SCHEDULER_API AudibilityFilterConfig : public VistaPropertyList
44
				{
45
				};
46

47
48
49
50
51
				///
				/// \brief Pure virtual destructor.
				/// 
				virtual ~IAudibilityFilter ( ) = 0;

52
53
54
				///
				/// \brief Check if the change between \p previousState and \p newUpdate is audible.
				///
Pascal Palenda's avatar
Pascal Palenda committed
55
				/// \note Default behaviour it to return false.
56
57
58
				/// \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.
59
				///
Pascal Palenda's avatar
Pascal Palenda committed
60
				virtual bool changeIsAudible ( const CUpdateScene& previousState, const CUpdateScene& newUpdate ) = 0;
61
62
63

			protected:
				///
Pascal Palenda's avatar
Pascal Palenda committed
64
65
66
67
				/// \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.
68
				/// 
Pascal Palenda's avatar
Pascal Palenda committed
69
				void checkUpdateTimestamp ( const CUpdateScene& previousState, const CUpdateScene& newUpdate );
70
71
72
73
74
75
76
			};

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

Pascal Palenda's avatar
Pascal Palenda committed
106
			private:
107
108
				///
				/// \brief Map containing all creation functions.
Pascal Palenda's avatar
Pascal Palenda committed
109
				///
110
111
112
113
114
115
116
				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