CardTerminals
public protocol CardTerminals : AnyObject
The set of terminals supported by a TerminalFactory. This class allows applications to enumerate the available CardTerminals, obtain a specific CardTerminal, or wait for the insertion or removal of cards.
This class is multi-threading safe and can be used by multiple threads
concurrently. However, this object keeps track of the card presence state of
each of its terminals. Multiple objects should be used if independent calls
to waitForChange() are required.
Applications can obtain instances of this class by calling
TerminalFactory.terminals().
See also
See also
Version
1.0
Date
6 Nov 2017
-
list()Default implementationReturns an unmodifiable list of all available terminals.
Throws
CardError.operationFailedif the card operation failedDefault Implementation
Declaration
Swift
func list() throws -> [CardTerminal]Return Value
an unmodifiable list of all available terminals
-
Returns an unmodifiable list of all terminals matching the specified state.
If state is
CardState.all, this method returns all CardTerminals encapsulated by this object. If state isCardState.cardPresentorCardState.cardAbsent, it returns all CardTerminals where a card is currently present or absent, respectively.If state is
CardState.cardInsertionorCardState.cardRemoval, it returns all CardTerminals for which an insertion (or removal, respectively) was detected during the last call towaitForChange(). IfwaitForChange()has not been called on this object,cardInsertionis equivalent tocardPresentandcardRemovalis equivalent tocardAbsent. For an example of the use ofcardInsertion, seewaitForChange().Throws
CardError.operationFailedif the card operation failedDeclaration
Swift
func list(state: CardState) throws -> [CardTerminal]Parameters
statethe state
Return Value
an unmodifiable list of all terminals matching the specified attribute
-
terminal(name:Default implementation) Returns the terminal with the specified name or
nilif no such terminal exists.Default Implementation
Declaration
Swift
func terminal(name: String) -> CardTerminal?Parameters
namethe terminal name
Return Value
the terminal with the specified name or
nilif no such terminal exists -
waitForChange()Default implementationWaits for card insertion or removal in any of the terminals of this object.
This call is equivalent to calling
waitForChange(0).Throws
CardError.illegalStateif thisCardTerminalsobject does not contain any terminals;CardError.operationFailedif the card operation failedDefault Implementation
Declaration
Swift
func waitForChange() throws -
Waits for card insertion or removal in any of the terminals of this object or until the timeout expires.
This method examines each CardTerminal of this object. If a card was inserted into or removed from a CardTerminal since the previous call to
waitForChange(), it returns immediately. Otherwise, or if this is the first call towaitForChange()on this object, it blocks until a card is inserted into or removed from a CardTerminal.If
timeoutis greater than 0, the method returns aftertimeoutmilliseconds even if there is no change in state. In that case, this method returnsfalse; otherwise it returnstrue.This method is often used in a loop in combination with
list(CardState.cardInsertion), for example:TerminalFactory factory = ... CardTerminals terminals = factory.terminals() while true { for terminal in terminals.list(CardState.cardInsertion) { // examine Card in terminal, return if it matches } terminals.waitForChange() }Throws
CardError.illegalStateif thisCardTerminalsobject does not contain any terminals;CardError.illegalArgumentif timeout is negative;CardError.operationFailedif the card operation failedDeclaration
Swift
func waitForChange(timeout: Int) throws -> BoolParameters
timeoutif positive, block for up to
timeoutmilliseconds; if zero, block indefinitely; must not be negativeReturn Value
falseif the method returns due to an expired timeout,trueotherwise.