14#include "keyple/core/service/AbstractObservableStateAdapter.hpp"
19#include "keyple/core/service/AbstractMonitoringJobAdapter.hpp"
25AbstractObservableStateAdapter::AbstractObservableStateAdapter(
26 const MonitoringState monitoringState,
27 ObservableLocalReaderAdapter* reader,
28 std::shared_ptr<AbstractMonitoringJobAdapter> monitoringJob,
29 std::shared_ptr<ExecutorService> executorService)
30: mMonitoringState(monitoringState)
32, mMonitoringJob(monitoringJob)
33, mExecutorService(executorService)
38AbstractObservableStateAdapter::getMonitoringState()
const
40 return mMonitoringState;
43ObservableLocalReaderAdapter*
44AbstractObservableStateAdapter::getReader()
const
50AbstractObservableStateAdapter::switchState(
const MonitoringState stateId)
52 mReader->switchState(stateId);
56AbstractObservableStateAdapter::onActivate()
59 if (mMonitoringJob !=
nullptr) {
60 if (mExecutorService ==
nullptr) {
61 throw IllegalStateException(
"ExecutorService must be set");
64 mMonitoringEvent = mExecutorService->submit(
65 mMonitoringJob->getMonitoringJob(shared_from_this()));
70AbstractObservableStateAdapter::onDeactivate()
73 if (mMonitoringEvent !=
nullptr && !mMonitoringEvent->isDone()) {
74 mMonitoringJob->stop();
75 mMonitoringEvent->cancel(
false);
80 mMonitoringEvent =
nullptr;