Regina Calculation Engine
Public Member Functions | List of all members
regina::NPacket::ChangeEventSpan Class Reference

An object that facilitates firing packetToBeChanged() and packetWasChanged() events. More...

#include <packet/npacket.h>

Inheritance diagram for regina::NPacket::ChangeEventSpan:
regina::boost::noncopyable

Public Member Functions

 ChangeEventSpan (NPacket *packet)
 Creates a new change event object for the given packet. More...
 
 ~ChangeEventSpan ()
 Destroys this change event object. More...
 

Detailed Description

An object that facilitates firing packetToBeChanged() and packetWasChanged() events.

Objects of this type should be created on the stack before data within a packet is changed. On creation, this object will fire a NPacketListener::packetToBeChanged() event to all registered listeners. On destruction (i.e., when the object goes out of scope), it will fire a NPacketListener::packetWasChanged() event.

It may be the case that several objects of this type all exist at the same time for the same packet. In this case, only the outermost object will fire events; that is, only the first object to be constructed will fire NPacketListener::packetToBeChanged(), and only the last object to be destroyed will fire NPacketListener::packetWasChanged(). This is because the "inner" ChangeEventSpan objects earlier represent smaller events that are part of a larger suite of changes.

If you are writing code that makes a large number of changes to a packet, it is highly recommended that you declare a ChangeEventSpan at the beginning of your code. This will ensure that listeners only receive one pair of events for the entire change set, instead of many events representing each individual modification.

Constructor & Destructor Documentation

regina::NPacket::ChangeEventSpan::ChangeEventSpan ( NPacket packet)
inline

Creates a new change event object for the given packet.

If this is the only ChangeEventSpan currently in existence for the given packet, this constructor will call NPacketListener::packetToBeChanged() for all registered listeners for the given packet.

Parameters
packetthe packet whose data is about to change.
regina::NPacket::ChangeEventSpan::~ChangeEventSpan ( )
inline

Destroys this change event object.

If this is the only ChangeEventSpan currently in existence for the given packet, this destructor will call NPacketListener::packetWasChanged() for all registered listeners for the given packet.


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).