Workspace 6.21.5
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ItemHandle Class Reference

A base class for handles to some item in a MeshModelInterface such as a node, element or state. More...

#include <Mesh/DataStructures/MeshModelInterface/meshitemhandle.h>

Inheritance diagram for ItemHandle:
[legend]

Public Types

typedef quint32 size_type
 

Public Member Functions

size_type getIndex () const
 
size_typeindexData ()
 
bool isValid () const
 
bool operator!= (const ItemHandle &other) const
 
bool operator< (const ItemHandle &other) const
 
bool operator== (const ItemHandle &other) const
 

Static Public Member Functions

static constexpr bool isValidIndex (size_t index)
 

Protected Member Functions

 ItemHandle ()
 
 ItemHandle (size_type index)
 

Detailed Description

These handles are returned when adding nodes or element and can be use to later refer to or access that element. For example the NodeHandles returned by addNode() are used to refer to those nodes when calling addElement().

Note that ItemHandles are left in an undefined state after any call to a method on the MeshModelInterface that results in indicies changing such as MeshNodesInterface::remove().

A default constructed ItemHandle is considered (and used to indicate) invalid (it's index will be size_type's max value)

NOTE: We don't want to make this class larger than it's data (quint32) so it should contain no virtual methods. This is why StateHandle does not derive from it.

Member Typedef Documentation

◆ size_type

typedef quint32 size_type

The ItemHandle class uses a size_type variable to refer to any given node or element behind a MeshModelInterfaceso. It therefore defines the max range for any node or element index used by the interface. It has to be consistent between the 3 classes (ItemHandle, MeshNodeInterface and MeshElementsInterface) which is why it is defined once here.

Constructor & Destructor Documentation

◆ ItemHandle() [1/2]

ItemHandle ( )
inlineprotected

Constructs an invalid handle

◆ ItemHandle() [2/2]

ItemHandle ( size_type  index)
inlineprotected
Parameters
indexAn index for this ItemHandle between 0 -> getLargestValidIndex()

Calling code should use default constructor to indication deliberate construction of an invalid node rather than calling this constructor with an invalid index param. This allows us to detect unintended invalid ItemHandle creation in debug builds.

Member Function Documentation

◆ getIndex()

ItemHandle::size_type getIndex ( ) const
inline
Returns
The index associated with this handle. Using the method when !isValid() is undefined.
See also
isValid()

◆ indexData()

ItemHandle::size_type & indexData ( )
inline
Returns
A reference to the index data.

Should only be used by low level algorithms that need to modify the index directly.

◆ isValid()

bool isValid ( ) const
inline
See also
getIndex() getLargestValidIndex()

◆ isValidIndex()

constexpr bool isValidIndex ( size_t  index)
staticconstexpr

◆ operator!=()

bool operator!= ( const ItemHandle other) const
inline

◆ operator<()

bool operator< ( const ItemHandle other) const
inline

◆ operator==()

bool operator== ( const ItemHandle other) const
inline