LuciadCPillar 2023.1.04
luciad::LayerListEvent Class Referencefinal

An event object, describing a change in a LayerList instance. More...

#include <luciad/layers/LayerList.h>

Public Types

enum class  Type { Added , Moved , Removed }
 The type of LayerListEvent. More...
 

Public Member Functions

LayerListEvent::Type getEventType () const
 Returns the event type. More...
 
std::shared_ptr< LayergetLayer () const
 Returns the layer for which a change was made. More...
 
std::optional< size_t > getNewIndex () const
 Returns the new index of the layer, or nothing in case of an LayerListChangeType::Removed event. More...
 
std::optional< size_t > getOldIndex () const
 Returns the old index of the layer, or nothing in case of an LayerListChangeType::Added event. More...
 

Static Public Member Functions

static LayerListEvent added (std::shared_ptr< Layer > layer, size_t index)
 Returns a new event that indicates that a layer has been added to the LayerList. More...
 
static LayerListEvent moved (std::shared_ptr< Layer > layer, size_t oldIndex, size_t newIndex)
 Returns a new event that indicates that a layer has been moved in the LayerList. More...
 
static LayerListEvent removed (std::shared_ptr< Layer > layer, size_t oldIndex)
 Returns a new event that indicates that a layer has been removed from the LayerList. More...
 

Detailed Description

An event object, describing a change in a LayerList instance.

Member Enumeration Documentation

◆ Type

enum class luciad::LayerListEvent::Type
strong

The type of LayerListEvent.

Enumerator
Added 

When the layer list event is for a layer that is added.

Moved 

When the layer list event is for a layer that is moved.

Removed 

When the layer list event is for a layer that is removed.

Member Function Documentation

◆ added()

static LayerListEvent luciad::LayerListEvent::added ( std::shared_ptr< Layer layer,
size_t  index 
)
static

Returns a new event that indicates that a layer has been added to the LayerList.

Parameters
layerthe layer that was added, must not be nullptr
indexthe index if the layer in the LayerList
Returns
a new event that indicates that a layer has been added to the LayerList
Exceptions
luciad::NullArgumentExceptionwhen the layer is nullptr.
Since
2021.1

◆ getEventType()

LayerListEvent::Type luciad::LayerListEvent::getEventType ( ) const

Returns the event type.

Depending on this type, the LayerListEvent::getOldIndex and LayerListEvent::getNewIndex methods return different values:

  • Added: getOldIndex returns std::nullopt, getNewIndex returns the index at which the layer was added
  • Moved: both getOldIndex and getNewIndex return a value
  • Removed: getNewIndex returns std::nullopt, getOldIndex return the index from which the layer was removed
Returns
the event type.

◆ getLayer()

std::shared_ptr< Layer > luciad::LayerListEvent::getLayer ( ) const

Returns the layer for which a change was made.

Returns
the layer for which a change was made.

◆ getNewIndex()

std::optional< size_t > luciad::LayerListEvent::getNewIndex ( ) const

Returns the new index of the layer, or nothing in case of an LayerListChangeType::Removed event.

Returns
the new index of the layer, or nothing in case of an LayerListChangeType::Removed event.

◆ getOldIndex()

std::optional< size_t > luciad::LayerListEvent::getOldIndex ( ) const

Returns the old index of the layer, or nothing in case of an LayerListChangeType::Added event.

Returns
the old index of the layer, or nothing in case of an LayerListChangeType::Added event.

◆ moved()

static LayerListEvent luciad::LayerListEvent::moved ( std::shared_ptr< Layer layer,
size_t  oldIndex,
size_t  newIndex 
)
static

Returns a new event that indicates that a layer has been moved in the LayerList.

Parameters
layerthe layer that was moved, must not be nullptr
oldIndexthe previous index in the LayerList
newIndexthe new index in the LayerList
Returns
a new event that indicates that a layer has been moved in the LayerList
Exceptions
luciad::NullArgumentExceptionwhen the layer is nullptr.
Since
2021.1

◆ removed()

static LayerListEvent luciad::LayerListEvent::removed ( std::shared_ptr< Layer layer,
size_t  oldIndex 
)
static

Returns a new event that indicates that a layer has been removed from the LayerList.

Parameters
layerthe layer that was removed, must not be nullptr
oldIndexthe index of the layer in the LayerList before it was removed
Returns
a new event that indicates that a layer has been removed from the LayerList
Exceptions
luciad::NullArgumentExceptionwhen the layer is nullptr.
Since
2021.1