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

#include <AbstractObservableState.h>

Inherited by keyple::core::seproxy::plugin::WaitForSeInsertion, keyple::core::seproxy::plugin::WaitForSeProcessing, keyple::core::seproxy::plugin::WaitForSeRemoval, and keyple::core::seproxy::plugin::WaitForStartDetect.

Public Member Functions

const MonitoringStategetMonitoringState () const
 
virtual void onEvent (const InternalEvent event)=0
 
void onActivate ()
 
void onDeactivate ()
 

Public Attributes

std::shared_ptr< AbstractMonitoringJobmMonitoringJob
 

Protected Member Functions

 AbstractObservableState (MonitoringState state, AbstractObservableLocalReader *reader, std::shared_ptr< AbstractMonitoringJob > monitoringJob, std::shared_ptr< ExecutorService > executorService)
 
 AbstractObservableState (MonitoringState state, AbstractObservableLocalReader *reader)
 
virtual ~AbstractObservableState ()=default
 
void switchState (MonitoringState stateId)
 

Protected Attributes

MonitoringState mState
 
AbstractObservableLocalReadermReader
 
std::future< void > * mMonitoringEvent
 
std::shared_ptr< ExecutorServicemExecutorService
 
std::atomic< bool > mCancellationFlag
 

Detailed Description

Defines a state behaviour for a keyple::core::seproxy::plugin::AbstractObservableLocalReader. Handles keyple::core::seproxy::plugin::InternalEvent that might results on a switch of state.

Constructor & Destructor Documentation

◆ AbstractObservableState() [1/2]

keyple::core::seproxy::plugin::AbstractObservableState::AbstractObservableState ( MonitoringState  state,
AbstractObservableLocalReader reader,
std::shared_ptr< AbstractMonitoringJob monitoringJob,
std::shared_ptr< ExecutorService executorService 
)
protected

Create a new state with a state identifier and a monitor job

Parameters
statethe state identifier
readerthe current reader
monitoringJobthe job to be executed in background (may be null if no background job is required)
executorServicethe executor service

◆ AbstractObservableState() [2/2]

keyple::core::seproxy::plugin::AbstractObservableState::AbstractObservableState ( MonitoringState  state,
AbstractObservableLocalReader reader 
)
protected

Create a new state with a state identifier

Parameters
reader: observable reader this currentState is attached to
state: name of the currentState

◆ ~AbstractObservableState()

virtual keyple::core::seproxy::plugin::AbstractObservableState::~AbstractObservableState ( )
protectedvirtualdefault

Member Function Documentation

◆ getMonitoringState()

const MonitoringState & keyple::core::seproxy::plugin::AbstractObservableState::getMonitoringState ( ) const

Get the current state identifier of the state machine

Returns
the current state identifier

◆ onActivate()

void keyple::core::seproxy::plugin::AbstractObservableState::onActivate ( )

Invoked when activated, a custom behaviour can be added here

◆ onDeactivate()

void keyple::core::seproxy::plugin::AbstractObservableState::onDeactivate ( )

Invoked when deactivated

◆ onEvent()

virtual void keyple::core::seproxy::plugin::AbstractObservableState::onEvent ( const InternalEvent  event)
pure virtual

Handle Internal Event Usually state is switched using method reader::switchState

Parameters
eventinternal event received by reader

Implemented in keyple::core::seproxy::plugin::WaitForStartDetect, keyple::core::seproxy::plugin::WaitForSeRemoval, keyple::core::seproxy::plugin::WaitForSeProcessing, and keyple::core::seproxy::plugin::WaitForSeInsertion.

◆ switchState()

void keyple::core::seproxy::plugin::AbstractObservableState::switchState ( MonitoringState  stateId)
protected

Switch state in the parent reader

Parameters
stateIdthe new state

Member Data Documentation

◆ mCancellationFlag

std::atomic<bool> keyple::core::seproxy::plugin::AbstractObservableState::mCancellationFlag
protected

◆ mExecutorService

std::shared_ptr<ExecutorService> keyple::core::seproxy::plugin::AbstractObservableState::mExecutorService
protected

Executor service used to execute AbstractMonitoringJob

◆ mMonitoringEvent

std::future<void>* keyple::core::seproxy::plugin::AbstractObservableState::mMonitoringEvent
protected

Result of the background job if any

◆ mMonitoringJob

std::shared_ptr<AbstractMonitoringJob> keyple::core::seproxy::plugin::AbstractObservableState::mMonitoringJob

C++ vs. Java: protected in Java, public in C++ to try and workaround threading issues

Background job definition if any

◆ mReader

AbstractObservableLocalReader* keyple::core::seproxy::plugin::AbstractObservableState::mReader
protected

Reference to Reader

◆ mState

MonitoringState keyple::core::seproxy::plugin::AbstractObservableState::mState
protected

Identifier of the currentState


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