Class CommandMapping

Inheritance Relationships

Derived Types

Class Documentation

class CommandMapping

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.

Subclassed by tap::control::HoldCommandMapping, tap::control::HoldRepeatCommandMapping, tap::control::PressCommandMapping, tap::control::ToggleCommandMapping

Public Functions

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:
  • cmds[in] A list of Commands that are associated with the mapping.

  • rms[in] The map state that will be compared to the actual remote state to determine whether or not to add cmds.

virtual ~CommandMapping() = default

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

virtual void executeCommandMapping(const RemoteMapState &currState) = 0

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:

currState[in] The current state of the remote.

virtual bool mappingSubset(const RemoteMapState &mapState)
Returns:

true if this’s mapState is a subset of the passed in mapState. Returns false otherwise.

inline const RemoteMapState &getAssociatedRemoteMapState() const
inline const std::vector<Command*> &getAssociatedCommands() const

Public Static Functions

static inline bool negKeysSubset(const RemoteMapState &state1, const RemoteMapState &state2)
Returns:

true if state1’s neg keys are a subset of state2’s keys pressed, false otherwise.

Protected Functions

void addCommands()

Adds all the Commands to the main CommandScheduler.

void removeCommands()

Removes all the Commands from the main CommandScheduler.

bool noCommandsScheduled() const
Returns:

True if none of the associated commands are scheduled.

Protected Attributes

const RemoteMapState mapState

The RemoteMapState specified when constructing the CommandMapping.

std::vector<Command*> mappedCommands

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

Drivers *drivers

Friends

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

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

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

Checks for equality between the mapStates of cm1 and cm2.