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

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

#include <packet/packet.h>

Public Member Functions

 ChangeEventSpan (Packet &packet)
 Creates a new change event object for the given packet. More...
 
 ~ChangeEventSpan ()
 Destroys this change event object. More...
 
 ChangeEventSpan (const ChangeEventSpan &)=delete
 
ChangeEventSpanoperator= (const ChangeEventSpan &)=delete
 

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 PacketListener::packetToBeChanged() event to all registered listeners. On destruction (i.e., when the object goes out of scope), it will fire a PacketListener::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 PacketListener::packetToBeChanged(), and only the last object to be destroyed will fire PacketListener::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.

ChangeEventSpan objects are not copyable, movable or swappable. In particular, Regina does not offer any way for a ChangeEventSpan to transfer its duty (i.e., firing events upon destruction) to another object.

Python
Not present.

Constructor & Destructor Documentation

◆ ChangeEventSpan()

regina::Packet::ChangeEventSpan::ChangeEventSpan ( Packet 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 PacketListener::packetToBeChanged() for all registered listeners for the given packet.

Parameters
packetthe packet whose data is about to change.

◆ ~ChangeEventSpan()

regina::Packet::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 PacketListener::packetWasChanged() for all registered listeners for the given packet.


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

Copyright © 1999-2023, 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).