SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
ProtocolManager::OneProtocolType Class Reference

A simple class that stores all protocols of a certain type. More...

Public Member Functions

void removeProtocol (std::shared_ptr< Protocol > p)
 Removes a protocol from the list of protocols of a certain type.
 
bool notifyEvent (Event *event)
 Calls either notifyEvent(event) or notifyEventAsynchronous(evet) on all protocols.
 
void update (int ticks, bool async)
 Calls either the synchronous update or asynchronous update function in all protocols of this type.
 
void abort ()
 
std::shared_ptr< ProtocolgetFirstProtocol ()
 Returns the first protocol of a given type.
 
bool handleConnects () const
 Returns if this protocol class handles connect events.
 
bool handleDisconnects () const
 Returns if this protocol class handles disconnect events.
 
void addProtocol (std::shared_ptr< Protocol > p)
 
bool isEmpty () const
 Returns if there are no protocols of this type registered.
 

Private Attributes

std::vector< std::shared_ptr< Protocol > > m_protocols
 

Detailed Description

A simple class that stores all protocols of a certain type.

While many protocols have at most one instance running, some (e.g. GetPublicAddress, ConntectToPeer, ...) can have several instances active at the same time.

Member Function Documentation

◆ getFirstProtocol()

std::shared_ptr< Protocol > ProtocolManager::OneProtocolType::getFirstProtocol ( )
inline

Returns the first protocol of a given type.

It is assumed that there is a protocol of that type.

◆ handleConnects()

bool ProtocolManager::OneProtocolType::handleConnects ( ) const
inline

Returns if this protocol class handles connect events.

Protocols of the same class either all handle a connect event, or none, so only the first protocol is actually tested.

◆ handleDisconnects()

bool ProtocolManager::OneProtocolType::handleDisconnects ( ) const
inline

Returns if this protocol class handles disconnect events.

Protocols of the same class either all handle a disconnect event, or none, so only the first protocol is actually tested.

◆ notifyEvent()

bool ProtocolManager::OneProtocolType::notifyEvent ( Event event)

Calls either notifyEvent(event) or notifyEventAsynchronous(evet) on all protocols.

Note that no locking is done, it is the responsibility of the caller to avoid race conditions.

Parameters
eventThe event to deliver to the protocols.

◆ removeProtocol()

void ProtocolManager::OneProtocolType::removeProtocol ( std::shared_ptr< Protocol p)

Removes a protocol from the list of protocols of a certain type.

Note that the protocol is not deleted.

Parameters
pThe protocol to be removed.

◆ update()

void ProtocolManager::OneProtocolType::update ( int  ticks,
bool  async 
)

Calls either the synchronous update or asynchronous update function in all protocols of this type.

Parameters
dtTime step size.
asyncTrue if asynchronousUpdate() should be called.

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