SuperTuxKart
|
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< Protocol > | getFirstProtocol () |
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 |
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.
|
inline |
Returns the first protocol of a given type.
It is assumed that there is a protocol of that type.
|
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.
|
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.
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.
event | The event to deliver to the protocols. |
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.
p | The protocol to be removed. |
void ProtocolManager::OneProtocolType::update | ( | int | ticks, |
bool | async | ||
) |
Calls either the synchronous update or asynchronous update function in all protocols of this type.
dt | Time step size. |
async | True if asynchronousUpdate() should be called. |