Regina Calculation Engine
Friends | List of all members
regina::NPacketListener Class Reference

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

#include <packet/npacketlistener.h>

Inheritance diagram for regina::NPacketListener:
regina::NScript regina::NSnapPeaTriangulation

Public Member Functions

Constructors and Destructors
virtual ~NPacketListener ()
 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 (NPacket *packet)
 Called before the contents of the packet are to be changed. More...
 
virtual void packetWasChanged (NPacket *packet)
 Called after the contents of the packet have been changed. More...
 
virtual void packetToBeRenamed (NPacket *packet)
 Called before the packet label or tags are to be changed. More...
 
virtual void packetWasRenamed (NPacket *packet)
 Called after the packet label or tags have been changed. More...
 
virtual void packetToBeDestroyed (NPacket *packet)
 Called before the packet is about to be destroyed. More...
 
virtual void childToBeAdded (NPacket *packet, NPacket *child)
 Called before a child packet is to be inserted directly beneath the packet. More...
 
virtual void childWasAdded (NPacket *packet, NPacket *child)
 Called after a child packet has been inserted directly beneath the packet. More...
 
virtual void childToBeRemoved (NPacket *packet, NPacket *child, bool inParentDestructor)
 Called before a child packet is to be removed from directly beneath the packet. More...
 
virtual void childWasRemoved (NPacket *packet, NPacket *child, bool inParentDestructor)
 Called after a child packet has been removed from directly beneath the packet. More...
 
virtual void childrenToBeReordered (NPacket *packet)
 Called before the child packets directly beneath the packet are to be reordered. More...
 
virtual void childrenWereReordered (NPacket *packet)
 Called after the child packets directly beneath the packet have been reordered. More...
 

Friends

class NPacket
 Allow packets to automatically deregister listeners as they are destroyed. 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 NPacket::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 listener. 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.

When using multiple threads, there are restrictions upon what any thread other than the main thread may do. If these restrictions are properly adhered to, packet listeners may assume that no routines other than childWasAdded() will be called from a non-main thread. Of course it is up to the multithreading code to ensure that these restrictions are in fact met; see the NThread class notes for further information.

Warning
If the multithreading restrictions noted above are not adhered to, this can result in the GUI crashing within either Qt or Xlib. Again, see the NThread class notes for further information.
Python:
Not present.

Constructor & Destructor Documentation

virtual regina::NPacketListener::~NPacketListener ( )
virtual

Destroys this listener.

This listener will be unregistered from any packets to which it is currently listening.

Member Function Documentation

void regina::NPacketListener::childrenToBeReordered ( NPacket packet)
inlinevirtual

Called before the child packets directly beneath the packet are to be reordered.

Once the reordering is done, childrenWereReordered() will be called also.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.
void regina::NPacketListener::childrenWereReordered ( NPacket packet)
inlinevirtual

Called after the child packets directly beneath the packet have been reordered.

Before this reordering is done, childrenToBeReordered() will be called also.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.
void regina::NPacketListener::childToBeAdded ( NPacket packet,
NPacket child 
)
inlinevirtual

Called before a child packet is to be inserted directly beneath the packet.

Once the child is removed, childWasAdded() will be called also.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.
childthe child packet to be added.
void regina::NPacketListener::childToBeRemoved ( NPacket packet,
NPacket child,
bool  inParentDestructor 
)
inlinevirtual

Called before a child packet is to be removed from directly beneath the packet.

Note that the child packet may be about to be destroyed (although this destruction will not have happened yet). Once the child is removed, childWasRemoved() will be called also.

Note also that this packet (the parent) may have already entered its destructor (which removes and destroys all child packets as a matter of course). In this situation it may be unsafe to query or update this packet, and so the third argument inParentDestructor is provided to indicate such a situation.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.
childthe child packet to be removed.
inParentDestructorset to true if the parent packet is in fact being destroyed, and the child was simply removed as part of the standard subtree destruction.
void regina::NPacketListener::childWasAdded ( NPacket packet,
NPacket child 
)
inlinevirtual

Called after a child packet has been inserted directly beneath the packet.

Before this child is added, childToBeAdded() will be called also.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.
childthe child packet that was added.
void regina::NPacketListener::childWasRemoved ( NPacket packet,
NPacket child,
bool  inParentDestructor 
)
inlinevirtual

Called after a child packet has been removed from directly beneath the packet.

Note that the child packet may be about to be destroyed (although this destruction will not have happened yet). Before this child is removed, childToBeRemoved() will be called also.

Note also that this packet (the parent) may have already entered its destructor (which removes and destroys all child packets as a matter of course). In this situation it may be unsafe to query or update this packet, and so the third argument inParentDestructor is provided to indicate such a situation.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.
childthe child packet that was removed.
inParentDestructorset to true if the parent packet is in fact being destroyed, and the child was simply removed as part of the standard subtree destruction.
void regina::NPacketListener::packetToBeChanged ( NPacket packet)
inlinevirtual

Called before the contents of the packet are to be changed.

Once the contents are changed, packetWasChanged() will be called also.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.
void regina::NPacketListener::packetToBeDestroyed ( NPacket packet)
inlinevirtual

Called before the packet is about to be destroyed.

Note that there is no matching function called after the packet is destroyed, since the set of listeners will no longer be available at that stage.

When an entire packet subtree is to be destroyed, child packets will notify their listeners of the impending destruction before parent packets will.

Note that the packet will forcibly unregister this listener immediately before packetToBeDestroyed() is called, to avoid any unpleasant consequences if this listener should also try to unregister itself. This means that, by the time this routine is called, this listener will no longer be registered with the packet in question (and any attempt to unregister it again will be harmless).

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.

Reimplemented in regina::NScript.

void regina::NPacketListener::packetToBeRenamed ( NPacket packet)
inlinevirtual

Called before the packet label or tags are to be changed.

Once the label or tags are changed, packetWasRenamed() will be called also.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.
void regina::NPacketListener::packetWasChanged ( NPacket packet)
inlinevirtual

Called after the contents of the packet have been changed.

Before the contents are changed, packetToBeChanged() will be called also.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.

Reimplemented in regina::NSnapPeaTriangulation.

void regina::NPacketListener::packetWasRenamed ( NPacket packet)
inlinevirtual

Called after the packet label or tags have been changed.

Before the label or tags are changed, packetToBeRenamed() will be called also.

The default implementation of this routine is to do nothing.

Parameters
packetthe packet being listened to.

Reimplemented in regina::NScript.

void regina::NPacketListener::unregisterFromAllPackets ( )

Unregisters this listener from any packets to which it is currently listening.

Friends And Related Function Documentation

friend class NPacket
friend

Allow packets to automatically deregister listeners as they are destroyed.


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

Copyright © 1999-2014, 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@debian.org).