AccessEngine :: AEDevice :: AEInput :: Gesture :: Gesture :: Class Gesture
[hide private]
[frames] | no frames]

Class Gesture

source code

object --+
         |
        Gesture

Represents one or more device specific input actions. Maintains a list of action codes specific to a AEInput device as well as a reference to the device itself. Maintains a separate list of the action codes sorted according to the order specified by the AEInput device owning this Gesture in order to speed comparisons of two Gestures. Maintains a hash value computed by XORing the sorted action codes in order to support the deterministic hashing of Gestures with the same action codes to the same bin in a dictionary. Both the cached sorted list and the hash code are reset on each successful call to Gesture.addActionCode.

Instance Methods [hide private]
 
__init__(self, device, action_codes=None, gesture=None)
Stores a reference to the input device.
source code
string
__str__(self)
Gets a human readable representation of the Gesture as a string from asString.
source code
boolean
__eq__(self, other)
Compares this Gesture to the one provided.
source code
iterator
__iter__(self)
Gets an iterator over the action codes in this Gesture.
source code
boolean
__contains__(self, action_code)
Gets if this Gesture contains the given action code.
source code
integer
__hash__(self)
Builds a hash code for this Gesture based on its action code contents by XORing them together.
source code
integer
__len__(self)
Gets the number of codes in the current gesture.
source code
AEInput.AEInput
getDevice(self)
Gets the device on which this Gesture is performed.
source code
 
addActionCode(self, code)
Adds the given action code to this Gesture.
source code
 
removeActionCode(self, code)
Deletes an action code from this Gesture.
source code
 
clearActionCodes(self)
Deletes all action codes from this Gesture.
source code
list of integer
getActionCodes(self)
Gets a copy of all the action codes in this Gesture.
source code
 
peekActionCodes(self)
Gets a reference to the list of action codes in this Gesture.
source code
list of integer
getSortedActionCodes(self)
Gets a copy of all the action codes in this Gesture in a sort order determined by the AEInput device on which the actions are performed.
source code
integer
getNumActions(self)
Gets the number of action codes stored in this Gesture.
source code
string
asString(self)
Gets a human readable representation of the action codes in this Gesture determined by the AEInput device on which the actions were performed.
source code

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Instance Variables [hide private]
list of integer action_codes
Codes for the actions performed on the device forming this Gesture
AEInput.AEInput device
Input device on which the Gesture is performed
integer hash
Cached copy of the hash value of the Gesture
list of integer sorted_codes
Cached action codes sorted by the device owning this Gesture
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, device, action_codes=None, gesture=None)
(Constructor)

source code 
Stores a reference to the input device. Stores a copy of the the provided action codes or gets a copy of the action codes from the provided Gesture. If neither is specified, creates an empty action code list.
Parameters:
  • device (AEInput.AEInput) - Input device on which this Gesture is pressed
  • action_codes (list of integer) - Action codes used to initialize the action code list
  • gesture (Gesture) - Gesture object that this Gesture should copy
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 
Gets a human readable representation of the Gesture as a string from asString.
Returns: string
Text describing the gesture
Overrides: object.__str__

__eq__(self, other)
(Equality operator)

source code 
Compares this Gesture to the one provided. The comparison is performed independent of the order of the actions forming the gesture by using Gesture.getSortedActionCodes.
Parameters:
Returns: boolean
Is this Gesture equal to the one provided?

__iter__(self)

source code 
Gets an iterator over the action codes in this Gesture.
Returns: iterator
Iterator over all action codes in this Gesture

__contains__(self, action_code)
(In operator)

source code 
Gets if this Gesture contains the given action code.
Returns: boolean
Is the action code in this Gesture?

__hash__(self)
(Hashing function)

source code 
Builds a hash code for this Gesture based on its action code contents by XORing them together. The hash code is used by a GestureList in building its hash code. The action codes are sorted in device dependent order using Gesture.getSortedActionCodes before XORing to ensure two Gestures with the same actions hash to the same value.
Returns: integer
Hash code for this Gesture
Overrides: object.__hash__

__len__(self)
(Length operator)

source code 
Gets the number of codes in the current gesture.
Returns: integer
Number of codes

getDevice(self)

source code 
Gets the device on which this Gesture is performed.
Returns: AEInput.AEInput
Device on which this Gesture is performed

addActionCode(self, code)

source code 
Adds the given action code to this Gesture. If the Gesture is full (i.e. it has the maximum number of action as determined by its device), a ValueError is raised. If the Gesture is not full, the new action code is added to the end of action_codes. If the action code was already in the Gesture, the action code is moved to the end of action_codes.
Parameters:
  • code (integer) - Action code to add to this Gesture
Raises:

removeActionCode(self, code)

source code 
Deletes an action code from this Gesture.
Parameters:
  • code (integer) - Action code to remove from this Gesture
Raises:
  • ValueError - When the action code does not exist in the Gesture

getActionCodes(self)

source code 
Gets a copy of all the action codes in this Gesture. Makes a fast copy by taking a slice using the start and end slice defaults.
Returns: list of integer
Copy of all the action codes in this Gesture

peekActionCodes(self)

source code 
Gets a reference to the list of action codes in this Gesture. The reference to the list should be used for read-only access even though protections against modification are not used. This method exists solely to offset the time cost incurred by making a copy of actions using getActionCodes.

getSortedActionCodes(self)

source code 
Gets a copy of all the action codes in this Gesture in a sort order determined by the AEInput device on which the actions are performed.
Returns: list of integer
Copy of all the action codes in device dependent sort order

getNumActions(self)

source code 
Gets the number of action codes stored in this Gesture.
Returns: integer
Number of action codes bounded by AEInput.Base.AEInput.getMaxActions

asString(self)

source code 
Gets a human readable representation of the action codes in this Gesture determined by the AEInput device on which the actions were performed.
Returns: string
Text representation of the actions in this Gesture