![]() |
Gorgon Game Engine
|
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 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. 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) |
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.
|
default |
|
delete |
PointerStack | ( | PointerStack && | other | ) |
References PointerStack::Swap().
~PointerStack | ( | ) |
|
delete |
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.
void Add | ( | PointerType | type, |
const Pointer && | pointer | ||
) |
Move variant that maps to assume.
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.
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.
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.
bool Exists | ( | PointerType | type | ) |
Checks if the given pointer exists.
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.
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.
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.
PointerStack::Token Set | ( | PointerType | type | ) |
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.
void Swap | ( | PointerStack & | other | ) |
References Gorgon::swap().