10 #include "swCommonLib/External/FastDelegate/FastDelegate.h"
25 class DelegatesContainerBase;
30 template<
typename EventArgType >
31 using EventDelegate = fastdelegate::FastDelegate2< UIElement*, EventArgType* >;
73 void AddContainer ( DelegatesContainerBaseOPtr&& container );
90 template<
typename EventArgType >
107 inline void operator+= ( DelegateType delegate );
111 bool Exists ( DelegateType delegate );
126 : m_eventType( eventID )
135 m_next = std::move( container );
137 m_next->AddContainer( std::move( container ) );
155 return std::move(
m_next );
167 template<
typename EventArgType >
174 template<
typename EventArgType >
177 AddDelegate( delegate );
182 template<
typename EventArgType >
185 if( !Exists( delegate ) )
186 m_delegates.push_back( delegate );
191 template<
typename EventArgType >
194 bool removed =
false;
195 for(
auto iter = m_delegates.begin(); iter != m_delegates.end(); )
197 if( *iter == delegate )
199 iter = m_delegates.erase( iter );
211 template<
typename EventArgType >
214 for(
auto& exisitingDelegate : m_delegates )
216 if( exisitingDelegate == delegate )
224 template<
typename EventArgType >
227 return m_delegates.empty();
232 template<
typename EventArgType >
236 EventArgType* typedArgs =
static_cast< EventArgType*
>( arguments );
237 for(
auto& delegateFun : m_delegates )
238 delegateFun( sender, typedArgs );
Derived template class for delegates.
Definition: DelegateContainer.h:91
Base class for delegates containers.
Definition: DelegateContainer.h:52
Base class for events.
Definition: IEventArgs.h:27
virtual void CallDelegates(UIElement *sender, IEventArgs *arguments)=0
Invokes delegates functions.
EventType GetEventType()
Call this function to check event type holded by derived class.
Definition: DelegateContainer.h:66
Definition: DirectInputModule.cpp:11
EventType m_eventType
Type of event used to distinguish between Delegates Containers.
Definition: DelegateContainer.h:57
DelegatesContainerBase * GetNextContainer()
Gets next element on linked list.
Definition: DelegateContainer.h:70
Interface for all controls in tree.
Definition: UIElement.h:57
uint32 EventType
Event type identifier.
Definition: RegisteredEvent.h:19
Plik zawiera definicje podstawowych typów zmiennych.
virtual ~DelegatesContainer()=default
bool RemoveDelegate(DelegateType delegate)
Definition: DelegateContainer.h:192
DelegatesContainerBaseOPtr m_next
Intrusive list.
Definition: DelegateContainer.h:56
void RemoveNext()
Removed element following this object.
Definition: DelegateContainer.h:142
virtual void CallDelegates(UIElement *sender, IEventArgs *arguments) override
Invokes delegates functions.
Definition: DelegateContainer.h:233
virtual ~DelegatesContainerBase()=default
void operator+=(DelegateType delegate)
Definition: DelegateContainer.h:175
void AddContainer(DelegatesContainerBaseOPtr &&container)
Adds container on the end of list.
Definition: DelegateContainer.h:132
fastdelegate::FastDelegate2< UIElement *, EventArgType * > EventDelegate
Definition: DelegateContainer.h:31
DelegatesContainerBaseOPtr StealRestOfList()
Steal list following this.
Definition: DelegateContainer.h:153
DEFINE_OPTR_TYPE(UIElement)
void AddDelegate(DelegateType delegate)
Definition: DelegateContainer.h:183
DelegatesContainerBase(EventType eventID)
Definition: DelegateContainer.h:125
std::vector< DelegateType > m_delegates
Delegates for EventType defined in DelegatesContainerBase.
Definition: DelegateContainer.h:99
EventDelegate< EventArgType > DelegateType
Definition: DelegateContainer.h:95
bool IsEmpty() const
Definition: DelegateContainer.h:225
DelegatesContainer(EventType type)
Definition: DelegateContainer.h:168
bool Exists(DelegateType delegate)
Definition: DelegateContainer.h:212