Regina Calculation Engine
|
An object that can be registered to listen for packet events.
More...
#include <packet/packet.h>
Public Member Functions | |
PacketListener (const PacketListener &)=delete | |
PacketListener & | operator= (const PacketListener &)=delete |
Constructors and Destructors | |
virtual | ~PacketListener () |
Destroys this listener. More... | |
Packet Listener Interface | |
void | unregisterFromAllPackets () |
Unregisters this listener from any packets to which it is currently listening. More... | |
virtual void | packetToBeChanged (Packet *packet) |
Called before the contents of the packet are to be changed. More... | |
virtual void | packetWasChanged (Packet *packet) |
Called after the contents of the packet have been changed. More... | |
virtual void | packetToBeRenamed (Packet *packet) |
Called before the packet label or tags are to be changed. More... | |
virtual void | packetWasRenamed (Packet *packet) |
Called after the packet label or tags have been changed. More... | |
virtual void | packetToBeDestroyed (PacketShell packet) |
Called before the packet is about to be destroyed. More... | |
virtual void | childToBeAdded (Packet *packet, Packet *child) |
Called before a child packet is to be inserted directly beneath the packet. More... | |
virtual void | childWasAdded (Packet *packet, Packet *child) |
Called after a child packet has been inserted directly beneath the packet. More... | |
virtual void | childToBeRemoved (Packet *packet, Packet *child) |
Called before a child packet is to be removed from directly beneath the packet. More... | |
virtual void | childWasRemoved (Packet *packet, Packet *child) |
Called after a child packet has been removed from directly beneath the packet. More... | |
virtual void | childrenToBeReordered (Packet *packet) |
Called before the child packets directly beneath the packet are to be reordered. More... | |
virtual void | childrenWereReordered (Packet *packet) |
Called after the child packets directly beneath the packet have been reordered. More... | |
virtual void | childToBeRenamed (Packet *packet, Packet *child) |
Called before one of this packet's immediate children has its label or tags changed. More... | |
virtual void | childWasRenamed (Packet *packet, Packet *child) |
Called after one of this packet's immediate children has its label or tags changed. More... | |
Protected Member Functions | |
PacketListener ()=default | |
A default constructor that does nothing. More... | |
Friends | |
class | Packet |
Allow packets to automatically deregister listeners as they are destroyed. More... | |
An object that can be registered to listen for packet events.
A packet listener can be registered to listen for events on a packet by calling Packet::listen().
Each time that one of the events listed in this class occurs, the packet will call the appropriate routine for all registered packet listeners.
These events come in future/past pairs: packetToBeChanged() and packetWasChanged(), childToBeAdded() and childWasAdded(), and so on. These event pairs are mutually exclusive: any event will cause at most one pair of routines to be called for each (packet, listener) pair. For instance, if a packet is renamed then packetToBeRenamed() and packetWasRenamed() will be called but packetToBeChanged() and packetWasChanged() will not.
As a special case, when a packet is destroyed there is only the future event packetToBeDestroyed() with no matching "past" event, since after the packet has been destroyed the set of listeners is no longer available.
No guarantees are made as to the order in which the different packet listeners are notified of an event.
When a listener is destroyed, it is automatically unregistered from any packets to which it is currently listening. Similarly, when a packet is destroyed all listeners are automatically unregistered.