Gorgon Game Engine
PointerStack Class Reference

This class manages a pointer stack that allows multiple pointers to be registered and switched. More...

Classes

class  Token
 Token type, automatically pops pointer stack when goes out of scope. More...
 

Public Member Functions

 PointerStack ()=default
 
 PointerStack (const PointerStack &)=delete
 
 PointerStack (PointerStack &&other)
 
 ~PointerStack ()
 
void Add (PointerType type, const Drawable &&image, Geometry::Point hotspot)=delete
 
void Add (PointerType type, const Drawable &image, Geometry::Point hotspot)
 Creates and adds a new pointer. More...
 
void Add (PointerType type, const Pointer &&pointer)
 Move variant that maps to assume. More...
 
void Add (PointerType type, const Pointer &pointer)
 Adds the given pointer to the stack. More...
 
void Assume (PointerType type, const Pointer &pointer)
 Adds the given pointer to the stack. More...
 
const PointerCurrent () const
 Returns the pointer on top of the stack, if no pointer is on the stack, first pointer in the order of PointerType enums will be returned. More...
 
bool Exists (PointerType type)
 Checks if the given pointer exists. More...
 
bool IsValid () const
 Returns if the stack is valid to be used. More...
 
void Reset (Token &token)
 Removes a pointer shape from the stack. More...
 
Token Set (const Pointer &pointer)
 Sets the current pointer in the stack to the given pointer. More...
 
Token Set (PointerType type)
 Set the current pointer to the given type. More...
 
void Swap (PointerStack &other)
 

Detailed Description

This class manages a pointer stack that allows multiple pointers to be registered and switched.

These pointers are pushed to the stack and can be reset, setting the pointer to the previous state.

Constructor & Destructor Documentation

◆ PointerStack() [1/3]

PointerStack ( )
default

◆ PointerStack() [2/3]

PointerStack ( const PointerStack )
delete

◆ PointerStack() [3/3]

PointerStack ( PointerStack &&  other)

References PointerStack::Swap().

◆ ~PointerStack()

Member Function Documentation

◆ Add() [1/4]

void Add ( PointerType  type,
const Drawable &&  image,
Geometry::Point  hotspot 
)
delete

◆ Add() [2/4]

void Add ( PointerType  type,
const Drawable image,
Geometry::Point  hotspot 
)

Creates and adds a new pointer.

Life time of this new pointer will be bound to the life time of the stack. If the given pointer type exists old one will be overridden. If the old pointer is managed by this stack then it will be deleted.

◆ Add() [3/4]

void Add ( PointerType  type,
const Pointer &&  pointer 
)

Move variant that maps to assume.

◆ Add() [4/4]

void Add ( PointerType  type,
const Pointer pointer 
)

Adds the given pointer to the stack.

Ownership of the pointer will not be transferred. If the given pointer type exists old one will be overridden. If the old pointer is managed by this stack then it will be deleted.

◆ Assume()

void Assume ( PointerType  type,
const Pointer pointer 
)

Adds the given pointer to the stack.

Ownership of the pointer will be transferred. If the given pointer type exists old one will be overridden. If the old pointer is managed by this stack then it will be deleted.

◆ Current()

const Pointer & Current ( ) const

Returns the pointer on top of the stack, if no pointer is on the stack, first pointer in the order of PointerType enums will be returned.

If no pointers are registered, this function will throw runtime_error

References Gorgon::Graphics::None.

◆ Exists()

bool Exists ( PointerType  type)

Checks if the given pointer exists.

◆ IsValid()

bool IsValid ( ) const

Returns if the stack is valid to be used.

A valid stack requires at least one registered or pushed pointer

References Gorgon::Graphics::None.

◆ Reset()

void Reset ( Token token)

Removes a pointer shape from the stack.

If the given token is null or does not belong to this stack, nothing is done.

◆ Set() [1/2]

PointerStack::Token Set ( const Pointer pointer)

Sets the current pointer in the stack to the given pointer.

This pointer will not be added to the list. The token should be stored in a variable otherwise the pointer would be reset immediately.

◆ Set() [2/2]

Set the current pointer to the given type.

This would return a token to be used to reset this operation. The token should be stored in a variable otherwise the pointer would be reset immediately.

◆ Swap()

void Swap ( PointerStack other)

References Gorgon::swap().


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