CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::InputContext Class Referencefinal

#include <CeresEngine/Input/InputContext.hpp>

Public Member Functions

 InputContext (InputManager &manager) noexcept
 Creates a new InputContext.
 
 InputContext (const InputContext &)=delete
 
InputContextoperator= (const InputContext &)=delete
 
 ~InputContext ()
 Destroys the input context.
 
template<typename T , typename... Args>
Tadd (const StringView &name, Args &&... args)
 Add a new Action or Range to the context.
 
void active (bool state) noexcept
 Changes the active or inactive state of the context.
 
bool isActive () const noexcept
 
InputActionaction (const StringView &name)
 Gets a action by it's name.
 
const InputActionaction (const StringView &name) const
 Gets a action by it's name.
 
bool hasAction (const StringView &name) const
 Checks if the context contains a action named name.
 
InputRangerange (const StringView &name)
 Gets a range by it's name.
 
const InputRangerange (const StringView &name) const
 Gets a range by it's name.
 
bool hasRange (const StringView &name) const
 Checks if the context contains a range named name.
 

Private Member Functions

template<CInputAction Action, typename... Args>
Action & createAction (const StringView &name, Args &&... args)
 Creates a new action with the given name and type Action.
 
InputActionaddAction (const StringView &name, UPtr< InputAction > action)
 Add a new action with the given name.
 
template<CInputRange Range, typename... Args>
Range & createRange (const StringView &name, Args &&... args)
 Creates a new range with the given name and type Action.
 
InputRangeaddRange (const StringView &name, UPtr< InputRange > range)
 Add a new range with the given name.
 
void update (const InputState &state)
 Update all actions and ranges with the given input state.
 

Private Attributes

InputManagermanager
 The input manager.
 
Map< String, UPtr< InputAction > > actions
 A map of all actions registered with the context.
 
Map< String, UPtr< InputRange > > ranges
 A map of all ranges registered with the context.
 
bool mActive = true
 The context active or inactive state.
 

Friends

class InputManager
 

Constructor & Destructor Documentation

◆ InputContext() [1/2]

CeresEngine::InputContext::InputContext ( InputManager manager)
explicitnoexcept

Creates a new InputContext.

Parameters
managerThe owning input manager

◆ InputContext() [2/2]

CeresEngine::InputContext::InputContext ( const InputContext )
delete

◆ ~InputContext()

CeresEngine::InputContext::~InputContext ( )

Destroys the input context.

Member Function Documentation

◆ action() [1/2]

InputAction & CeresEngine::InputContext::action ( const StringView name)

Gets a action by it's name.

Parameters
nameThe action name
Returns
A reference to the action

◆ action() [2/2]

const InputAction & CeresEngine::InputContext::action ( const StringView name) const

Gets a action by it's name.

Parameters
nameThe action name
Returns
A reference to the action

◆ active()

void CeresEngine::InputContext::active ( bool  state)
noexcept

Changes the active or inactive state of the context.

Parameters
stateIf true, will activate the context, if false will deactivate it.

◆ add()

template<typename T , typename... Args>
T & CeresEngine::InputContext::add ( const StringView name,
Args &&...  args 
)

Add a new Action or Range to the context.

Template Parameters
Tthe Action or Range subtype
Argsthe action or range constructor types
Parameters
nameThe action or range name
argsThe action or range constructor types
Returns
A reference to the newly created Action or Range object.

◆ addAction()

InputAction & CeresEngine::InputContext::addAction ( const StringView name,
UPtr< InputAction action 
)
private

Add a new action with the given name.

Parameters
nameThe action name
actionA pointer to the action to be added
Returns
A reference to the added action

◆ addRange()

InputRange & CeresEngine::InputContext::addRange ( const StringView name,
UPtr< InputRange range 
)
private

Add a new range with the given name.

Parameters
nameThe range name
rangeA pointer to the range to be added
Returns
A reference to the added range

◆ createAction()

template<CInputAction Action, typename... Args>
Action & CeresEngine::InputContext::createAction ( const StringView name,
Args &&...  args 
)
inlineprivate

Creates a new action with the given name and type Action.

Template Parameters
Actionthe action type
Argsthe action constructor argument types
Parameters
nameThe action name
argsThe action constructor arguments
Returns
A reference to the created action

◆ createRange()

template<CInputRange Range, typename... Args>
Range & CeresEngine::InputContext::createRange ( const StringView name,
Args &&...  args 
)
inlineprivate

Creates a new range with the given name and type Action.

Template Parameters
Rangethe range type
Argsthe range constructor argument types
Parameters
nameThe range name
argsThe range constructor arguments
Returns
A reference to the created range

◆ hasAction()

bool CeresEngine::InputContext::hasAction ( const StringView name) const

Checks if the context contains a action named name.

Parameters
nameThe action name
Returns
True if the action exists

◆ hasRange()

bool CeresEngine::InputContext::hasRange ( const StringView name) const

Checks if the context contains a range named name.

Parameters
nameThe range name
Returns
True if the range exists

◆ isActive()

bool CeresEngine::InputContext::isActive ( ) const
noexcept
Returns
True if the context is active, false otherwise

◆ operator=()

InputContext & CeresEngine::InputContext::operator= ( const InputContext )
delete

◆ range() [1/2]

InputRange & CeresEngine::InputContext::range ( const StringView name)

Gets a range by it's name.

Parameters
nameThe range name
Returns
A reference to the range

◆ range() [2/2]

const InputRange & CeresEngine::InputContext::range ( const StringView name) const

Gets a range by it's name.

Parameters
nameThe range name
Returns
A reference to the range

◆ update()

void CeresEngine::InputContext::update ( const InputState state)
private

Update all actions and ranges with the given input state.

Parameters
stateThe input state to update with

Friends And Related Symbol Documentation

◆ InputManager

Member Data Documentation

◆ actions

Map<String, UPtr<InputAction> > CeresEngine::InputContext::actions
private

A map of all actions registered with the context.

◆ mActive

bool CeresEngine::InputContext::mActive = true
private

The context active or inactive state.

◆ manager

InputManager& CeresEngine::InputContext::manager
private

The input manager.

◆ ranges

Map<String, UPtr<InputRange> > CeresEngine::InputContext::ranges
private

A map of all ranges registered with the context.


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