Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
DelegateFilter.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Misc/AssertionMacros.h"
7#include "Templates/SharedPointer.h"
8#include "Delegates/Delegate.h"
9#include "Misc/IFilter.h"
10
11/**
12 * A generic filter designed to call a predicate provided on construction to filter
13 */
14template< typename ItemType >
16 : public IFilter< ItemType >, public TSharedFromThis< TDelegateFilter< ItemType > >
17{
18public:
19
20 DECLARE_DELEGATE_RetVal_OneParam( bool, FPredicate, ItemType );
21
22 /**
23 * TDelegateFilter Constructor
24 *
25 * @param InPredicate A required delegate called to determine if an Item passes the filter
26 */
27 TDelegateFilter( FPredicate InPredicate )
29 {
31 }
32
33 DECLARE_DERIVED_EVENT( TDelegateFilter, IFilter<ItemType>::FChangedEvent, FChangedEvent );
34 virtual FChangedEvent& OnChanged() override { return ChangedEvent; }
35
36 /**
37 * Returns whether the specified Item passes the Filter's restrictions
38 *
39 * @param InItem The Item is check
40 * @return Whether the specified Item passed the filter
41 */
42 virtual bool PassesFilter( ItemType InItem ) const override
43 {
44 return Predicate.Execute( InItem );
45 }
46
47 /** Broadcasts the OnChanged event for this filter */
49 {
51 }
52
53private:
54
55 /** The delegate called to determine if an Item passes the filter */
56 FPredicate Predicate;
57
58 /** Fires whenever the filter changes */
59 FChangedEvent ChangedEvent;
60};
#define check(expr)
#define DECLARE_DERIVED_EVENT(OwningType, BaseTypeEvent, EventName)
Definition Delegate.h:231
#define DECLARE_DELEGATE_RetVal_OneParam(ReturnValueType, DelegateName, Param1Type)
TDelegateFilter(FPredicate InPredicate)
virtual bool PassesFilter(ItemType InItem) const override
virtual FChangedEvent & OnChanged() override
FPredicate Predicate
FChangedEvent ChangedEvent