Keyple C++  0.9.0
Keyple, an Open Source SDK for Ticketing
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin Class Referenceabstract

#include <AbstractThreadedObservablePlugin.h>

Inherits keyple::core::seproxy::plugin::AbstractObservablePlugin.

Inherited by keyple::plugin::pcsc::PcscPluginImpl [virtual], and keyple::plugin::stub::StubPluginImpl.

Public Member Functions

void addObserver (const std::shared_ptr< ObservablePlugin::PluginObserver > observer) final
 
void removeObserver (const std::shared_ptr< ObservablePlugin::PluginObserver > observer) final
 
void clearObservers () final
 
virtual ~AbstractThreadedObservablePlugin ()
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractObservablePlugin
virtual int countObservers () const final
 
virtual void notifyObservers (const std::shared_ptr< PluginEvent > event) final
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractPlugin
virtual ConcurrentMap< const std::string, std::shared_ptr< SeReader > > & getReaders () override
 
virtual const std::set< std::string > getReaderNames () const override
 
const std::shared_ptr< SeReadergetReader (const std::string &name) final
 
const std::string & getName () const
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractSeProxyComponent
 AbstractSeProxyComponent (const std::string &name)
 
virtual ~AbstractSeProxyComponent ()=default
 
const std::string & getName () const
 
void setParameters (const std::map< const std::string, const std::string > &parameters)
 
virtual void setParameter (const std::string &key, const std::string &value)=0
 
- Public Member Functions inherited from keyple::core::seproxy::ReaderPlugin
virtual ~ReaderPlugin ()=default
 
- Public Member Functions inherited from keyple::core::seproxy::ProxyElement
virtual ~ProxyElement ()=default
 
virtual const std::string & getName () const =0
 
virtual const std::map< const std::string, const std::string > & getParameters () const =0
 
virtual void setParameter (const std::string &key, const std::string &value)=0
 
virtual void setParameters (const std::map< const std::string, const std::string > &parameters)
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::ObservablePluginNotifier
virtual ~ObservablePluginNotifier ()=default
 
- Public Member Functions inherited from keyple::core::seproxy::event::ObservablePlugin
virtual ~ObservablePlugin ()=default
 
virtual void addObserver (const std::shared_ptr< PluginObserver > observer)=0
 
virtual void removeObserver (const std::shared_ptr< PluginObserver > observer)=0
 

Protected Member Functions

 AbstractThreadedObservablePlugin (const std::string &name)
 
virtual const std::set< std::string > & fetchNativeReadersNames ()=0
 
virtual std::shared_ptr< SeReaderfetchNativeReader (const std::string &name)=0
 
bool isMonitoring ()
 
- Protected Member Functions inherited from keyple::core::seproxy::plugin::AbstractObservablePlugin
 AbstractObservablePlugin (const std::string &name)
 
virtual ~AbstractObservablePlugin ()=default
 
- Protected Member Functions inherited from keyple::core::seproxy::plugin::AbstractPlugin
 AbstractPlugin (const std::string &name)
 
virtual ~AbstractPlugin ()=default
 
virtual ConcurrentMap< const std::string, std::shared_ptr< SeReader > > & initNativeReaders ()=0
 

Protected Attributes

long long mThreadWaitTimeout = SETTING_THREAD_TIMEOUT_DEFAULT
 
- Protected Attributes inherited from keyple::core::seproxy::plugin::AbstractPlugin
ConcurrentMap< const std::string, std::shared_ptr< SeReader > > mNativeReaders
 

Detailed Description

The AbstractThreadedObservablePlugin class provides the means to observe a plugin (insertion/removal of readers) using a monitoring thread.

Constructor & Destructor Documentation

◆ ~AbstractThreadedObservablePlugin()

keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::~AbstractThreadedObservablePlugin ( )
virtual

◆ AbstractThreadedObservablePlugin()

keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::AbstractThreadedObservablePlugin ( const std::string &  name)
explicitprotected

Instantiates an threaded observable plugin

Parameters
namename of the plugin
Exceptions
KeypleReaderNotFoundExceptionif the reader was not found by its name
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Member Function Documentation

◆ addObserver()

void keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::addObserver ( const std::shared_ptr< ObservablePlugin::PluginObserver observer)
finalvirtual

Add a plugin observer.

Overrides the method defined in AbstractObservablePlugin, a thread is created if it does not already exist (when the first observer is added).

Parameters
observerthe observer object

Reimplemented from keyple::core::seproxy::plugin::AbstractObservablePlugin.

◆ clearObservers()

void keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::clearObservers ( )
finalvirtual

Remove all observers at once

Overrides the method defined in AbstractObservablePlugin, the thread is ended.

Reimplemented from keyple::core::seproxy::plugin::AbstractObservablePlugin.

◆ fetchNativeReader()

virtual std::shared_ptr<SeReader> keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::fetchNativeReader ( const std::string &  name)
protectedpure virtual

Fetch connected native reader (from third party library) by its name Returns the current keyple::core::seproxy::plugin::AbstractReader if it is already listed. Creates and returns a new keyple::core::seproxy::plugin::AbstractReader if not.

Parameters
namethe reader name
Returns
the list of AbstractReader objects.
Exceptions
KeypleReaderNotFoundExceptionif the reader was not found by its name
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implemented in keyple::plugin::stub::StubPluginImpl, and keyple::plugin::pcsc::PcscPluginImpl.

◆ fetchNativeReadersNames()

virtual const std::set<std::string>& keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::fetchNativeReadersNames ( )
protectedpure virtual

Fetch the list of connected native reader (usually from third party library) and returns their names (or id)

Returns
connected readers' name list
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implemented in keyple::plugin::stub::StubPluginImpl, and keyple::plugin::pcsc::PcscPluginImpl.

◆ isMonitoring()

bool keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::isMonitoring ( )
protected

Check weither the background job is monitoring for new readers

Returns
true, if the background job is monitoring, false in all other cases.

◆ removeObserver()

void keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::removeObserver ( const std::shared_ptr< ObservablePlugin::PluginObserver observer)
finalvirtual

Remove a plugin observer.

Overrides the method defined in AbstractObservablePlugin, the monitoring thread is ended when the last observer is removed.

Parameters
observerthe observer object

Reimplemented from keyple::core::seproxy::plugin::AbstractObservablePlugin.

Member Data Documentation

◆ mThreadWaitTimeout

long long keyple::core::seproxy::plugin::AbstractThreadedObservablePlugin::mThreadWaitTimeout = SETTING_THREAD_TIMEOUT_DEFAULT
protected

Thread wait timeout in ms

This timeout value will determined the latency to detect changes


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