Keypop Reader C++ API - 2.1.0
Component of the Keypop C++ API
keypop::reader::ObservableCardReader Class Referenceabstract

Card reader able to observe the insertion/removal of cards. More...

#include <keypop/reader/ObservableCardReader.hpp>

Inheritance diagram for keypop::reader::ObservableCardReader:
Collaboration diagram for keypop::reader::ObservableCardReader:

Public Types

enum  DetectionMode { REPEATING , SINGLESHOT }
 Card detection management options to be applied after processing a card. More...
 
enum  NotificationMode { ALWAYS , MATCHED_ONLY }
 The options that apply when a card is detected. More...
 

Public Member Functions

virtual void setReaderObservationExceptionHandler (std::shared_ptr< CardReaderObservationExceptionHandlerSpi > exceptionHandler)=0
 Sets the exception handler. More...
 
virtual void addObserver (std::shared_ptr< CardReaderObserverSpi > observer)=0
 Registers a new observer to be notified when a reader event occurs. More...
 
virtual void removeObserver (const std::shared_ptr< CardReaderObserverSpi > observer)=0
 Unregisters a reader observer. More...
 
virtual void clearObservers ()=0
 Unregisters all observers at once. More...
 
virtual int countObservers () const =0
 Provides the current number of registered observers. More...
 
virtual void startCardDetection (const DetectionMode detectionMode)=0
 Starts the card detection. More...
 
virtual void stopCardDetection ()=0
 Stops the card detection. More...
 
virtual void finalizeCardProcessing ()=0
 Notifies the observation process that the processing of the card has been completed in order to ensure that the card monitoring cycle runs properly. More...
 
- Public Member Functions inherited from keypop::reader::CardReader
virtual ~CardReader ()=default
 
virtual const std::string & getName () const =0
 Returns the name of the reader. More...
 
virtual bool isContactless ()=0
 Checks if the card communication mode is contactless. More...
 
virtual bool isCardPresent ()=0
 Checks if the card is present. More...
 

Detailed Description

Card reader able to observe the insertion/removal of cards.

Since
1.0.0

Definition at line 33 of file ObservableCardReader.hpp.

Member Enumeration Documentation

◆ DetectionMode

Card detection management options to be applied after processing a card.

Since
1.0.0
Enumerator
REPEATING 

Continue waiting for the insertion of a next card.

Since
1.0.0
SINGLESHOT 

Stop and wait for a restart signal.

Since
1.0.0

Definition at line 40 of file ObservableCardReader.hpp.

◆ NotificationMode

The options that apply when a card is detected.

Since
1.0.0
Enumerator
ALWAYS 

All cards presented to the readers are notified to the observers, regardless of the result of the selection.

Since
1.0.0
MATCHED_ONLY 

Only the cards that have been successfully selected will be notified to the observers.

The others will be ignored and the application will not be aware of their presence.

Since
1.0.0

Definition at line 61 of file ObservableCardReader.hpp.

Member Function Documentation

◆ addObserver()

virtual void keypop::reader::ObservableCardReader::addObserver ( std::shared_ptr< CardReaderObserverSpi >  observer)
pure virtual

Registers a new observer to be notified when a reader event occurs.

The provided observer must implement the CardReaderObserverSpi interface to be able to receive the events produced by this reader (card insertion, removal, etc.)

Parameters
observerAn observer object implementing the required interface (should be not null).
Exceptions
IllegalArgumentExceptionIf the provided observer is null.
Since
1.0.0

◆ clearObservers()

virtual void keypop::reader::ObservableCardReader::clearObservers ( )
pure virtual

Unregisters all observers at once.

Since
1.0.0

◆ countObservers()

virtual int keypop::reader::ObservableCardReader::countObservers ( ) const
pure virtual

Provides the current number of registered observers.

Returns
An int.
Since
1.0.0

◆ finalizeCardProcessing()

virtual void keypop::reader::ObservableCardReader::finalizeCardProcessing ( )
pure virtual

Notifies the observation process that the processing of the card has been completed in order to ensure that the card monitoring cycle runs properly.

This method has no effect if the physical communication channel has already been closed.

It is mandatory to invoke this method when the physical communication channel with the card could not be closed properly.
The channel closing is nominally managed during the last transmission with the card. However, there are cases where exchanges with the card are interrupted (e.g. by an exception), in which case it is necessary to explicitly close the channel using this method.

In practice, it is recommended to invoke this method in all cases (e.g. in a "finally" statement) at the end of a card processing whatever the result.

Since
1.0.0

◆ removeObserver()

virtual void keypop::reader::ObservableCardReader::removeObserver ( const std::shared_ptr< CardReaderObserverSpi >  observer)
pure virtual

Unregisters a reader observer.

The observer will no longer receive any of the events produced by this reader.

Parameters
observerThe observer object to be removed (should be not null).
Exceptions
IllegalArgumentExceptionIf the provided observer is null.
Since
1.0.0

◆ setReaderObservationExceptionHandler()

virtual void keypop::reader::ObservableCardReader::setReaderObservationExceptionHandler ( std::shared_ptr< CardReaderObservationExceptionHandlerSpi >  exceptionHandler)
pure virtual

Sets the exception handler.

The invocation of this method is mandatory when the reader has to be observed.

In case of a fatal error during the observation, the handler will receive a notification.

Parameters
exceptionHandlerThe exception handler implemented by the application.
Exceptions
IllegalArgumentExceptionIf the provided handler is null.
Since
1.0.0

◆ startCardDetection()

virtual void keypop::reader::ObservableCardReader::startCardDetection ( const DetectionMode  detectionMode)
pure virtual

Starts the card detection.

Once activated, the application can be notified of the arrival of a card.

The DetectionMode indicates the action to be followed after processing the card.

Parameters
detectionModeThe card detection mode.
Exceptions
IllegalArgumentExceptionIf the provided detection mode is null.
Since
1.0.0

◆ stopCardDetection()

virtual void keypop::reader::ObservableCardReader::stopCardDetection ( )
pure virtual

Stops the card detection.

Since
1.0.0

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