regina::PacketListener Class Reference
Basic Packet Types

An object that can be registered to listen for packet events. More...

`#include <packet/packetlistener.h>`

Inheritance diagram for regina::PacketListener:

## Public Member Functions

Constructors and Destructors
virtual | ~PacketListener ()
| Destroys this listener. More...

## Packet Listener Interface

class | Packet
| Allow packets to automatically deregister listeners as they are destroyed. More...
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 (Packet *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, bool inParentDestructor)
| Called before a child packet is to be removed from directly beneath the packet. More...
virtual void | childWasRemoved (Packet *packet, Packet *child, bool inParentDestructor)
| 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...

## Detailed Description

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.

Warning
  At the time of writing (admittedly long ago now), Qt has only limited support for multithreading. When working with an existing packet tree in a new thread (not the main thread), the only modification that you may make is to insert new packets. Modifications of any other type (such as changing, renaming, deleting or reordering existing packets) could lead to a crash within Qt or Xlib when running the GUI. Of course, a new thread may create, modify and delete its own temporary packet trees as it chooses (and it may in fact insert them into a pre-existing packet tree once all modifications are completed). Assuming these restrictions are respected, packet listeners may assume that no routines other than childWasAdded() will be called from a non-main thread.

Python:\n Not present.

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

- packet/packetlistener.h

Copyright © 1999-2016, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).