Keyple C++  0.9.0
Keyple, an Open Source SDK for Ticketing
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
keyple::calypso::transaction::SamResourceManager Class Referenceabstract

#include <SamResourceManager.h>

Inherited by keyple::calypso::transaction::SamResourceManagerDefault, and keyple::calypso::transaction::SamResourceManagerPool.

Classes

class  ManagedSamResource
 

Public Types

enum  AllocationMode { AllocationMode::BLOCKING, AllocationMode::NON_BLOCKING }
 

Public Member Functions

virtual ~SamResourceManager ()=default
 
virtual std::shared_ptr< SeResource< CalypsoSam > > allocateSamResource (const AllocationMode allocationMode, const std::shared_ptr< SamIdentifier > samIdentifier)=0
 
virtual void freeSamResource (const SeResource< CalypsoSam > &samResource)=0
 

Protected Member Functions

virtual std::shared_ptr< ManagedSamResourcecreateSamResource (std::shared_ptr< SeReader > samReader)
 

Detailed Description

Management of SAM resources:

Provides methods fot the allocation/deallocation of SAM resources

Member Enumeration Documentation

◆ AllocationMode

Enumerator
BLOCKING 
NON_BLOCKING 

Constructor & Destructor Documentation

◆ ~SamResourceManager()

virtual keyple::calypso::transaction::SamResourceManager::~SamResourceManager ( )
virtualdefault

Member Function Documentation

◆ allocateSamResource()

virtual std::shared_ptr<SeResource<CalypsoSam> > keyple::calypso::transaction::SamResourceManager::allocateSamResource ( const AllocationMode  allocationMode,
const std::shared_ptr< SamIdentifier samIdentifier 
)
pure virtual

Allocate a SAM resource from the specified SAM group.

In the case where the allocation mode is BLOCKING, this method will wait until a SAM resource becomes free and then return the reference to the allocated resource. However, the BLOCKING mode will wait a maximum time defined in milliseconds by MAX_BLOCKING_TIME.

In the case where the allocation mode is NON_BLOCKING and no SAM resource is available, this method will return an exception.

If the samGroup argument is null, the first available SAM resource will be selected and returned regardless of its group.

Parameters
allocationModethe blocking/non-blocking mode
samIdentifierthe targeted SAM identifier
Returns
a SAM resource
Exceptions
CalypsoNoSamResourceAvailableExceptionif no resource is available
KeypleReaderExceptionif a reader error occurs
KeypleAllocationReaderExceptionif reader allocation fails

Implemented in keyple::calypso::transaction::SamResourceManagerPool, and keyple::calypso::transaction::SamResourceManagerDefault.

◆ createSamResource()

std::shared_ptr< ManagedSamResource > keyple::calypso::transaction::SamResourceManager::createSamResource ( std::shared_ptr< SeReader samReader)
protectedvirtual

Create a SAM resource from the provided SAM reader.

Proceed with the SAM selection and combine the SAM reader and the Calypso SAM resulting from the selection.

Parameters
samReaderthe SAM reader with which the APDU exchanges will be done.
Returns
a keyple::core::selection::SeResource<T>
Exceptions
CalypsoNoSamResourceAvailableExceptionif an error occurs while doing the selection

◆ freeSamResource()

virtual void keyple::calypso::transaction::SamResourceManager::freeSamResource ( const SeResource< CalypsoSam > &  samResource)
pure virtual

Free a previously allocated SAM resource.

Parameters
samResourcethe SAM resource reference to free

Implemented in keyple::calypso::transaction::SamResourceManagerPool, and keyple::calypso::transaction::SamResourceManagerDefault.


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