CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::WeakEventConnection Class Referencefinal

Connection class. More...

#include <CeresEngine/Foundation/Event.hpp>

Public Member Functions

 WeakEventConnection () noexcept
 Default constructor.
 
 WeakEventConnection (WeakEventConnection const &)=delete
 
WeakEventConnectionoperator= (WeakEventConnection const &)=delete
 
 WeakEventConnection (WeakEventConnection &&other) noexcept
 Move constructor.
 
WeakEventConnectionoperator= (WeakEventConnection &&other) noexcept
 Move assign operator.
 
bool connected () const noexcept
 
void disconnect ()
 Disconnect the slot from the connection.
 

Private Member Functions

 WeakEventConnection (SPtr< EventDisconnector > const &sharedDisconnector, const std::size_t index)
 Create a connection.
 

Private Attributes

WPtr< EventDisconnectorweakDisconnector
 Weak pointer to the current disconnector functor.
 
std::size_t index
 Slot index of the connected slot.
 

Friends

template<typename P , typename T , template< typename > typename F>
class TEvent
 The event template is a friend of the connection, since it is the only one allowed to create instances using the meaningful constructor.
 

Detailed Description

Connection class.

This is used to be able to disconnect slots after they have been connected. Used as return type for the connect method of the events.

  • Connections are default constructible.
  • Connections are not copy constructible or copy assignable.
  • Connections are move constructible and move assignable.

Constructor & Destructor Documentation

◆ WeakEventConnection() [1/4]

CeresEngine::WeakEventConnection::WeakEventConnection ( )
inlinenoexcept

Default constructor.

◆ WeakEventConnection() [2/4]

CeresEngine::WeakEventConnection::WeakEventConnection ( WeakEventConnection const )
delete

◆ WeakEventConnection() [3/4]

CeresEngine::WeakEventConnection::WeakEventConnection ( WeakEventConnection &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThe instance to move from.

◆ WeakEventConnection() [4/4]

CeresEngine::WeakEventConnection::WeakEventConnection ( SPtr< EventDisconnector > const sharedDisconnector,
const std::size_t  index 
)
inlineprivate

Create a connection.

Parameters
sharedDisconnectorDisconnector instance that will be used to disconnect the connection when the time comes. A weak pointer to the disconnector will be held within the connection object.
indexThe slot index of the connection.

Member Function Documentation

◆ connected()

bool CeresEngine::WeakEventConnection::connected ( ) const
inlinenoexcept
Returns
true if the connection is connected to a event object, and false otherwise.

◆ disconnect()

void CeresEngine::WeakEventConnection::disconnect ( )
inline

Disconnect the slot from the connection.

If the connection represents a slot that is connected to a event object, calling this method will disconnect the slot from that object. The result of this operation is that the slot will stop receiving calls when the event is invoked.

◆ operator=() [1/2]

WeakEventConnection & CeresEngine::WeakEventConnection::operator= ( WeakEventConnection &&  other)
inlinenoexcept

Move assign operator.

Parameters
otherThe instance to move from.

◆ operator=() [2/2]

WeakEventConnection & CeresEngine::WeakEventConnection::operator= ( WeakEventConnection const )
delete

Friends And Related Symbol Documentation

◆ TEvent

The event template is a friend of the connection, since it is the only one allowed to create instances using the meaningful constructor.

Member Data Documentation

◆ index

std::size_t CeresEngine::WeakEventConnection::index
private

Slot index of the connected slot.

◆ weakDisconnector

WPtr<EventDisconnector> CeresEngine::WeakEventConnection::weakDisconnector
private

Weak pointer to the current disconnector functor.


The documentation for this class was generated from the following file: