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

#include <SamResourceManagerPool.h>

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

Public Member Functions

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

Protected Attributes

ReaderPoolPluginmSamReaderPlugin
 

Additional Inherited Members

- Public Types inherited from keyple::calypso::transaction::SamResourceManager
enum  AllocationMode { AllocationMode::BLOCKING, AllocationMode::NON_BLOCKING }
 
- Protected Member Functions inherited from keyple::calypso::transaction::SamResourceManager
virtual std::shared_ptr< ManagedSamResourcecreateSamResource (std::shared_ptr< SeReader > samReader)
 

Detailed Description

Implementation of Sam Resource Manager working a keyple::core::seproxy::ReaderPoolPlugin

Constructor & Destructor Documentation

◆ SamResourceManagerPool()

keyple::calypso::transaction::SamResourceManagerPool::SamResourceManagerPool ( ReaderPoolPlugin samReaderPoolPlugin,
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
samReaderPoolPluginthe reader pool plugin
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

Member Function Documentation

◆ allocateSamResource()

std::shared_ptr< SeResource< CalypsoSam > > keyple::calypso::transaction::SamResourceManagerPool::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::SamResourceManagerPool::freeSamResource ( const SeResource< CalypsoSam > &  samResource)
overridevirtual

Free a previously allocated SAM resource.

Parameters
samResourcethe SAM resource reference to free

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

Member Data Documentation

◆ mSamReaderPlugin

ReaderPoolPlugin& keyple::calypso::transaction::SamResourceManagerPool::mSamReaderPlugin
protected

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