Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::control::CommandMapping Class Referenceabstract

#include <command_mapping.hpp>

Inheritance diagram for tap::control::CommandMapping:
Collaboration diagram for tap::control::CommandMapping:

Public Member Functions

 CommandMapping (Drivers *drivers, const std::vector< Command * > cmds, const RemoteMapState &rms)
 
virtual ~CommandMapping ()=default
 
virtual void executeCommandMapping (const RemoteMapState &currState)=0
 
virtual bool mappingSubset (const RemoteMapState &mapState)
 
const RemoteMapStategetAssociatedRemoteMapState () const
 
const std::vector< Command * > & getAssociatedCommands () const
 

Static Public Member Functions

static bool negKeysSubset (const RemoteMapState &state1, const RemoteMapState &state2)
 

Protected Member Functions

void addCommands ()
 
void removeCommands ()
 
bool noCommandsScheduled () const
 

Protected Attributes

const RemoteMapState mapState
 
std::vector< Command * > mappedCommands
 
Driversdrivers
 

Friends

bool operator== (const CommandMapping &cm1, const CommandMapping &cm2)
 
bool mapStateEqual (const CommandMapping &cm1, const CommandMapping &cm2)
 

Detailed Description

A class that combines a vector of Commands and a RemoteMapState whose behavior is defined by derived classes. Used in conjunction with the CommandMapper to add and remove Commands from the scheduler when the derived CommandMapping sees fit, depending on the current state of the remote data.

See also
HoldCommandMapping
HoldRepeatCommandMapping
PressCommandMapping
ToggleCommandMapping

Constructor & Destructor Documentation

◆ CommandMapping()

tap::control::CommandMapping::CommandMapping ( Drivers drivers,
const std::vector< Command * >  cmds,
const RemoteMapState rms 
)

Initializes the CommandMapping with the set of passed in Commands mapped to a particular RemoteMapState.

Note
All nullptr Commands in cmds will be removed.
Parameters
[in]cmdsA list of Commands that are associated with the mapping.
[in]rmsThe map state that will be compared to the actual remote state to determine whether or not to add cmds.

◆ ~CommandMapping()

virtual tap::control::CommandMapping::~CommandMapping ( )
virtualdefault

Nothing dynamically allocated that isn't taken care of automatically.

Member Function Documentation

◆ addCommands()

void tap::control::CommandMapping::addCommands ( )
protected

Adds all the Commands to the main CommandScheduler.

◆ executeCommandMapping()

virtual void tap::control::CommandMapping::executeCommandMapping ( const RemoteMapState currState)
pure virtual

Using currState, determines whether or not to add or remove Commands from the main scheduler. Up the the implementer to determine what the criteria for adding and removing Commands should be.

Parameters
[in]currStateThe current state of the remote.

Implemented in tap::control::HoldCommandMapping, tap::control::HoldRepeatCommandMapping, tap::control::PressCommandMapping, and tap::control::ToggleCommandMapping.

◆ getAssociatedCommands()

const std::vector< Command * > & tap::control::CommandMapping::getAssociatedCommands ( ) const
inline

◆ getAssociatedRemoteMapState()

const RemoteMapState & tap::control::CommandMapping::getAssociatedRemoteMapState ( ) const
inline

◆ mappingSubset()

bool tap::control::CommandMapping::mappingSubset ( const RemoteMapState mapState)
virtual
Returns
true if this's mapState is a subset of the passed in mapState. Returns false otherwise.

◆ negKeysSubset()

static bool tap::control::CommandMapping::negKeysSubset ( const RemoteMapState state1,
const RemoteMapState state2 
)
inlinestatic
Returns
true if state1's neg keys are a subset of state2's keys pressed, false otherwise.

◆ noCommandsScheduled()

bool tap::control::CommandMapping::noCommandsScheduled ( ) const
protected
Returns
True if none of the associated commands are scheduled.

◆ removeCommands()

void tap::control::CommandMapping::removeCommands ( )
protected

Removes all the Commands from the main CommandScheduler.

Friends And Related Symbol Documentation

◆ mapStateEqual

bool mapStateEqual ( const CommandMapping cm1,
const CommandMapping cm2 
)
friend

Checks for equality between the mapStates of cm1 and cm2.

◆ operator==

bool operator== ( const CommandMapping cm1,
const CommandMapping cm2 
)
friend

Straight equality of the mapState and mappedCommands between cm1 and cm2.

Member Data Documentation

◆ drivers

Drivers* tap::control::CommandMapping::drivers
protected

◆ mappedCommands

std::vector<Command *> tap::control::CommandMapping::mappedCommands
protected

A map of commands to add to and remove from the scheduler.

◆ mapState

const RemoteMapState tap::control::CommandMapping::mapState
protected

The RemoteMapState specified when constructing the CommandMapping.


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