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

#include <SamResourceManagerDefault.h>

Inherits keyple::calypso::transaction::SamResourceManager.

Classes

class  PluginObserver
 
class  ReaderObserver
 

Public Member Functions

virtual ~SamResourceManagerDefault ()=default
 
std::shared_ptr< SeResource< CalypsoSam > > allocateSamResource (const AllocationMode allocationMode, const std::shared_ptr< SamIdentifier > samIdentifier) override
 
void freeSamResource (const SeResource< CalypsoSam > &samResource) override
 
 SamResourceManagerDefault (std::shared_ptr< ReaderPlugin > readerPlugin, const std::string &samReaderFilter, const int maxBlockingTime, const int sleepTime)
 
- Public Member Functions inherited from keyple::calypso::transaction::SamResourceManager
virtual ~SamResourceManager ()=default
 

Public Attributes

std::shared_ptr< SamResourceManagerDefault::ReaderObservermReaderObserver
 

Protected Member Functions

void removeResource (const std::shared_ptr< SeReader > samReader)
 
- Protected Member Functions inherited from keyple::calypso::transaction::SamResourceManager
virtual std::shared_ptr< ManagedSamResourcecreateSamResource (std::shared_ptr< SeReader > samReader)
 

Protected Attributes

std::shared_ptr< ReaderPluginmSamReaderPlugin
 

Additional Inherited Members

- Public Types inherited from keyple::calypso::transaction::SamResourceManager
enum  AllocationMode { AllocationMode::BLOCKING, AllocationMode::NON_BLOCKING }
 

Detailed Description

Implementation of Sam Resource Manager working a keyple::core::seproxy::ReaderPlugin (either Stub or Pcsc) It is meant to work with a Keyple Pcsc Plugin or a Keyple Stub Plugin.

Constructor & Destructor Documentation

◆ ~SamResourceManagerDefault()

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

◆ SamResourceManagerDefault()

keyple::calypso::transaction::SamResourceManagerDefault::SamResourceManagerDefault ( std::shared_ptr< ReaderPlugin readerPlugin,
const std::string &  samReaderFilter,
const int  maxBlockingTime,
const int  sleepTime 
)

Protected constructor, use the SamResourceManagerFactory

C++ vs. Java: Should be private but would forbid usage of make_shared from SamResourceManagerFactory class. Setting it public for now. Could use an intermediate derived class otherwise if need be.

Parameters
readerPluginthe plugin through which SAM readers are accessible
samReaderFilterthe regular expression defining how to identify SAM readers among others.
maxBlockingTimethe maximum duration for which the allocateSamResource method will attempt to allocate a new reader by retrying (in milliseconds)
sleepTimethe duration to wait between two retries
Exceptions
KeypleReaderExceptionthrown if an error occurs while getting the readers list.

Member Function Documentation

◆ allocateSamResource()

std::shared_ptr< SeResource< CalypsoSam > > keyple::calypso::transaction::SamResourceManagerDefault::allocateSamResource ( const AllocationMode  allocationMode,
const std::shared_ptr< SamIdentifier samIdentifier 
)
overridevirtual

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

Implements keyple::calypso::transaction::SamResourceManager.

◆ freeSamResource()

void keyple::calypso::transaction::SamResourceManagerDefault::freeSamResource ( const SeResource< CalypsoSam > &  samResource)
overridevirtual

◆ removeResource()

void keyple::calypso::transaction::SamResourceManagerDefault::removeResource ( const std::shared_ptr< SeReader samReader)
protected

Remove a keyple::core::selection::SeResource<T> from the current keyple::core::selection::SeResource<T> list

Parameters
samReaderthe SAM reader of the resource to remove from the list.

Member Data Documentation

◆ mReaderObserver

std::shared_ptr<SamResourceManagerDefault::ReaderObserver> keyple::calypso::transaction::SamResourceManagerDefault::mReaderObserver

Only used with observable readers

◆ mSamReaderPlugin

std::shared_ptr<ReaderPlugin> keyple::calypso::transaction::SamResourceManagerDefault::mSamReaderPlugin
protected

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