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

Gives access to the final remains of a packet that is in the process of being destroyed. More...

#include <packet/packet.h>

Public Member Functions

 PacketShell (const Packet *packet)
 Creates a new shell referring to the given packet. More...
 
 PacketShell (const PacketShell &shell)=default
 Creates a copy of the given shell. More...
 
PacketShelloperator= (const PacketShell &shell)=default
 Sets this to be a copy of the given shell. More...
 
bool operator== (const PacketShell &shell) const
 Identifies if this and the given shell refer to the same underlying packet. More...
 
bool operator== (const Packet *packet) const
 Identifies if this shell refers to the given packet. More...
 
bool operator!= (const PacketShell &shell) const
 Identifies if this and the given shell refer to different underlying packets. More...
 
bool operator!= (const Packet *packet) const
 Identifies if this shell does not refer to the given packet. More...
 
const std::string & label () const
 Returns the label associated with this individual packet. More...
 
std::string humanLabel () const
 Returns the label associated with this individual packet, adjusted if necessary for human-readable output. More...
 
bool hasTag (const std::string &tag) const
 Determines whether this packet has the given associated tag. More...
 
bool hasTags () const
 Determines whether this packet has any associated tags at all. More...
 
const std::set< std::string > & tags () const
 Returns the set of all tags associated with this packet. More...
 
std::string internalID () const
 Returns a unique string ID that identifies this packet. More...
 

Detailed Description

Gives access to the final remains of a packet that is in the process of being destroyed.

The main use of this class is to pass packet details to the callback function PacketListener::packetBeingDestroyed().

All functions in this class mirror the corresponding Packet functions, and are safe to call during PacketListener::packetBeingDestroyed().

This class works with raw Packet pointers, not std::shared_ptr, because it typically only becomes relevant when a Packet is already in the process of being destroyed (and so it is improper for a new shared pointer to suddenly appear and try to claim ownership of the packet again).

These are lightweight objects, small enough to pass by value and swap with std::swap(), with no need for any specialised move operations or swap functions. Copies of a PacketShell will give access to the remains of the same underlying packet.

Constructor & Destructor Documentation

◆ PacketShell() [1/2]

regina::PacketShell::PacketShell ( const Packet packet)
inline

Creates a new shell referring to the given packet.

Parameters
packetthe packet to refer to.

◆ PacketShell() [2/2]

regina::PacketShell::PacketShell ( const PacketShell shell)
default

Creates a copy of the given shell.

Both shells will refer to the same underlying packet.

Parameters
shellthe shell to clone.

Member Function Documentation

◆ hasTag()

bool regina::PacketShell::hasTag ( const std::string &  tag) const
inline

Determines whether this packet has the given associated tag.

See Packet::tags() for further details on packet tags.

Parameters
tagthe tag to search for.
Returns
true if the given tag is found, false otherwise.

◆ hasTags()

bool regina::PacketShell::hasTags ( ) const
inline

Determines whether this packet has any associated tags at all.

See Packet::tags() for further details on packet tags.

Returns
true if this packet has any tags, false otherwise.

◆ humanLabel()

std::string regina::PacketShell::humanLabel ( ) const
inline

Returns the label associated with this individual packet, adjusted if necessary for human-readable output.

See Packet::label() and Packet::humanLabel() for further details on packet labels.

Returns
this individual packet's label.

◆ internalID()

std::string regina::PacketShell::internalID ( ) const
inline

Returns a unique string ID that identifies this packet.

The user has no control over this ID and it is not human readable, but it is guaranteed to be unique to this packet, and to remain fixed throughout the lifetime of the program for this packet.

See Packet::internalID() for further details.

Returns
a unique ID that identifies this packet.

◆ label()

const std::string & regina::PacketShell::label ( ) const
inline

Returns the label associated with this individual packet.

See Packet::label() and Packet::humanLabel() for further details on packet labels.

The reference that is returned should be only used as a temporary, since the underlying packet (and therefore the string that is referenced) is in the process of being destroyed.

Returns
this individual packet's label.

◆ operator!=() [1/2]

bool regina::PacketShell::operator!= ( const Packet packet) const
inline

Identifies if this shell does not refer to the given packet.

This test is also available the other way around (with PacketShell on the right); this reversed test is defined as a global function.

Parameters
packetthe packet to test against; this may be null.
Returns
true if and only if this shell does not refer to the given packet.

◆ operator!=() [2/2]

bool regina::PacketShell::operator!= ( const PacketShell shell) const
inline

Identifies if this and the given shell refer to different underlying packets.

Parameters
shellthe shell to compare with this.
Returns
true if and only if both shells refer to different packets.

◆ operator=()

PacketShell & regina::PacketShell::operator= ( const PacketShell shell)
default

Sets this to be a copy of the given shell.

Both shells will refer to the same underlying packet.

Parameters
shellthe shell to clone.

◆ operator==() [1/2]

bool regina::PacketShell::operator== ( const Packet packet) const
inline

Identifies if this shell refers to the given packet.

This test is also available the other way around (with PacketShell on the right); this reversed test is defined as a global function.

Parameters
packetthe packet to test against; this may be null.
Returns
true if and only if this shell refers to the given packet.

◆ operator==() [2/2]

bool regina::PacketShell::operator== ( const PacketShell shell) const
inline

Identifies if this and the given shell refer to the same underlying packet.

Parameters
shellthe shell to compare with this.
Returns
true if and only if both shells refer to the same packet.

◆ tags()

const std::set< std::string > & regina::PacketShell::tags ( ) const
inline

Returns the set of all tags associated with this packet.

See Packet::tags() for further details on packet tags.

The reference that is returned should be only used as a temporary, since the underlying packet (and therefore the set that is referenced) is in the process of being destroyed.

Python
This routine returns a python set.
Returns
the set of all tags associated with this 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).