1 | /* |
2 | * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. |
3 | * |
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property |
5 | * and proprietary rights in and to this software, related documentation |
6 | * and any modifications thereto. Any use, reproduction, disclosure or |
7 | * distribution of this software and related documentation without an express |
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. |
9 | */ |
10 | |
11 | #ifndef PX_PROFILE_EVENT_FILTER_H |
12 | #define PX_PROFILE_EVENT_FILTER_H |
13 | |
14 | #include "physxprofilesdk/PxProfileBase.h" |
15 | #include "physxprofilesdk/PxProfileEventId.h" |
16 | |
17 | namespace physx { |
18 | |
19 | //Called upon every event to give a quick-out before adding the event |
20 | //to the event buffer. |
21 | class PxProfileEventFilter |
22 | { |
23 | protected: |
24 | virtual ~PxProfileEventFilter(){} |
25 | public: |
26 | //Disabled events will not go into the event buffer and will not be |
27 | //transmitted to clients. |
28 | virtual void setEventEnabled( const PxProfileEventId& inId, bool isEnabled ) = 0; |
29 | virtual bool isEventEnabled( const PxProfileEventId& inId ) const = 0; |
30 | }; |
31 | |
32 | //Forwards the filter requests to another event filter. |
33 | template<typename TFilterType> |
34 | struct PxProfileEventFilterForward |
35 | { |
36 | TFilterType* mFilter; |
37 | PxProfileEventFilterForward( TFilterType* inFilter ) : mFilter( inFilter ) {} |
38 | void setEventEnabled( const PxProfileEventId& inId, bool isEnabled ) { mFilter->setEventEnabled( inId, isEnabled ); } |
39 | bool isEventEnabled( const PxProfileEventId& inId ) const { return mFilter->isEventEnabled( inId ); } |
40 | }; |
41 | |
42 | //Implements the event filter interface using another implementation |
43 | template<typename TFilterType> |
44 | struct PxProfileEventFilterImpl : public PxProfileEventFilter |
45 | { |
46 | PxProfileEventFilterForward<TFilterType> mFilter; |
47 | PxProfileEventFilterImpl( TFilterType* inFilter ) : mFilter( inFilter ) {} |
48 | virtual void setEventEnabled( const PxProfileEventId& inId, bool isEnabled ) { mFilter.setEventEnabled( inId, isEnabled ); } |
49 | virtual bool isEventEnabled( const PxProfileEventId& inId ) const { return mFilter.isEventEnabled( inId ); } |
50 | }; |
51 | |
52 | //simple event filter that enables all events. |
53 | struct PxProfileNullEventFilter |
54 | { |
55 | void setEventEnabled( const PxProfileEventId&, bool) { PX_ASSERT(false); } |
56 | bool isEventEnabled( const PxProfileEventId&) const { return true; } |
57 | }; |
58 | } |
59 | |
60 | #endif // PX_PROFILE_EVENT_FILTER_H |
61 | |