UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FilterCollection.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 "Containers/Array.h"
9#include "Misc/IFilter.h"
10
14template< typename ItemType >
16 : public TSharedFromThis< TFilterCollection< ItemType > >
17{
18public:
19
24 {
25 for( auto Iterator = ChildFilters.CreateIterator(); Iterator; ++Iterator )
26 {
27 const TSharedPtr< IFilter< ItemType > >& Filter = *Iterator;
28
29 if ( Filter.IsValid() )
30 {
31 Filter->OnChanged().RemoveAll( this );
32 }
33 }
34 }
35
43 {
46 {
47 // The filter already exists, don't add a new one but return the index where it was found.
48 return ExistingIdx;
49 }
50
51 if( Filter.IsValid() )
52 {
53 Filter->OnChanged().AddSP( this, &TFilterCollection::OnChildFilterChanged );
54 }
55
56 int32 Result = ChildFilters.Add( Filter );
57 ChangedEvent.Broadcast();
58
59 return Result;
60 }
61
69 {
70 if (Filter.IsValid())
71 {
72 Filter->OnChanged().RemoveAll(this);
73 }
74
75 int32 Result = ChildFilters.Remove( Filter );
76
77 // Don't broadcast if the collection didn't change
78 if (Result > 0)
79 {
80 ChangedEvent.Broadcast();
81 }
82
83 return Result;
84 }
85
96
99 {
100 return ChildFilters.Num();
101 }
102
109 bool PassesAllFilters( ItemType InItem ) const
110 {
111 for (int Index = 0; Index < ChildFilters.Num(); Index++)
112 {
113 if( !ChildFilters[Index]->PassesFilter( InItem ) )
114 {
115 return false;
116 }
117 }
118
119 return true;
120 }
121
125
126protected:
127
133 {
134 ChangedEvent.Broadcast();
135 }
136
139
142};
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Array.h:670
SizeType Remove(const ElementType &Item)
Definition Array.h:3091
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG TIterator CreateIterator()
Definition Array.h:3355
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_NODEBUG UE_FORCEINLINE_HINT bool Find(const ElementType &Item, SizeType &Index) const
Definition Array.h:1302
Definition FilterCollection.h:17
TArray< TSharedPtr< IFilter< ItemType > > > ChildFilters
Definition FilterCollection.h:138
int32 Remove(const TSharedPtr< IFilter< ItemType > > &Filter)
Definition FilterCollection.h:68
UE_FORCEINLINE_HINT int32 Num() const
Definition FilterCollection.h:98
DECLARE_EVENT(TFilterCollection< ItemType >, FChangedEvent)
void OnChildFilterChanged()
Definition FilterCollection.h:132
FChangedEvent ChangedEvent
Definition FilterCollection.h:141
FChangedEvent & OnChanged()
Definition FilterCollection.h:124
TSharedPtr< IFilter< ItemType > > GetFilterAtIndex(int32 Index)
Definition FilterCollection.h:92
bool PassesAllFilters(ItemType InItem) const
Definition FilterCollection.h:109
~TFilterCollection()
Definition FilterCollection.h:23
int32 Add(const TSharedPtr< IFilter< ItemType > > &Filter)
Definition FilterCollection.h:42
Definition SharedPointer.h:1640
Definition SharedPointer.h:692
U16 Index
Definition radfft.cpp:71