Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions include/keyple/core/service/ObservableLocalReaderAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,43 @@ class KEYPLESERVICE_API ObservableLocalReaderAdapter
cardSelectionResponses);
};

/**
* Operator << for InternalEvent enum to enable readable logging.
*
* @param os The output stream.
* @param event The internal event.
* @return The output stream.
*/
inline std::ostream&
operator<<(std::ostream& os,
const ObservableLocalReaderAdapter::InternalEvent event)
{
switch (event) {
case ObservableLocalReaderAdapter::InternalEvent::CARD_INSERTED:
os << "CARD_INSERTED";
break;
case ObservableLocalReaderAdapter::InternalEvent::CARD_REMOVED:
os << "CARD_REMOVED";
break;
case ObservableLocalReaderAdapter::InternalEvent::CARD_PROCESSED:
os << "CARD_PROCESSED";
break;
case ObservableLocalReaderAdapter::InternalEvent::START_DETECT:
os << "START_DETECT";
break;
case ObservableLocalReaderAdapter::InternalEvent::STOP_DETECT:
os << "STOP_DETECT";
break;
case ObservableLocalReaderAdapter::InternalEvent::TIME_OUT:
os << "TIME_OUT";
break;
default:
os << "UNKNOWN_EVENT(" << static_cast<int>(event) << ")";
break;
}
return os;
}

} /* namespace service */
} /* namespace core */
} /* namespace keyple */
13 changes: 10 additions & 3 deletions include/keyple/core/service/PluginEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,27 @@ class KEYPLESERVICE_API PluginEvent {
virtual Type getType() const = 0;

/**
* Operator << for PluginEvent::Type enum to enable readable logging.
*
* @param os The output stream.
* @param t The event type.
* @return The output stream.
*/
friend std::ostream&
operator<<(std::ostream& os, const Type t)
{
switch (t) {
case Type::READER_CONNECTED:
os << "TYPE = READER_CONNECTED";
os << "READER_CONNECTED";
break;
case Type::READER_DISCONNECTED:
os << "TYPE = READER_DISCONNECTED";
os << "READER_DISCONNECTED";
break;
case Type::UNAVAILABLE:
os << "TYPE = UNAVAILABLE";
os << "UNAVAILABLE";
break;
default:
os << "UNKNOWN_TYPE(" << static_cast<int>(t) << ")";
break;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/MonitoringState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ operator<<(std::ostream& os, const MonitoringState ms)
{
switch (ms) {
case MonitoringState::WAIT_FOR_START_DETECTION:
os << "MONITORING_STATE = WAIT_FOR_START_DETECTION";
os << "WAIT_FOR_START_DETECTION";
break;
case MonitoringState::WAIT_FOR_CARD_PROCESSING:
os << "MONITORING_STATE = WAIT_FOR_CARD_PROCESSING";
os << "WAIT_FOR_CARD_PROCESSING";
break;
case MonitoringState::WAIT_FOR_CARD_REMOVAL:
os << "MONITORING_STATE = WAIT_FOR_CARD_REMOVAL";
os << "WAIT_FOR_CARD_REMOVAL";
break;
case MonitoringState::WAIT_FOR_CARD_INSERTION:
os << "MONITORING_STATE = WAIT_FOR_CARD_INSERTION";
os << "WAIT_FOR_CARD_INSERTION";
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/WaitForCardInsertionStateAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ WaitForCardInsertionStateAdapter::onEvent(const InternalEvent event)
{
mLogger->trace(
"Internal event [%] received for reader [%] in current state [%]\n",
getReader()->getName(),
event,
getReader()->getName(),
getMonitoringState());

/* Process InternalEvent */
Expand Down
2 changes: 1 addition & 1 deletion src/main/WaitForCardProcessingStateAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ WaitForCardProcessingStateAdapter::onEvent(const InternalEvent event)
{
mLogger->trace(
"Internal event [%] received for reader [%] in current state [%]\n",
getReader()->getName(),
event,
getReader()->getName(),
getMonitoringState());

/* Process InternalEvent */
Expand Down
2 changes: 1 addition & 1 deletion src/main/WaitForCardRemovalStateAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ WaitForCardRemovalStateAdapter::onEvent(const InternalEvent event)
{
mLogger->trace(
"Internal event [%] received for reader [%] in current state [%]\n",
getReader()->getName(),
event,
getReader()->getName(),
getMonitoringState());

/* Process InternalEvent */
Expand Down
2 changes: 1 addition & 1 deletion src/main/WaitForStartDetectStateAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ WaitForStartDetectStateAdapter::onEvent(const InternalEvent event)
{
mLogger->trace(
"Internal event [%] received for reader [%] in current state [%]\n",
getReader()->getName(),
event,
getReader()->getName(),
getMonitoringState());

/* Process InternalEvent */
Expand Down
5 changes: 4 additions & 1 deletion src/main/cpp/ExecutorService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ ExecutorService::run()
if (mPool.size()) {
/* Start first service and wait until completion */
std::shared_ptr<Job> job = mPool[0];
job->run();

if(!job->isCancelled()) {
job->run();
}

/* Remove from vector */
mPool.erase(mPool.begin());
Expand Down
4 changes: 2 additions & 2 deletions src/main/cpp/Job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Job::cancel(const bool mayInterruptIfRunning)
"Unsupported value for mayInterruptIfRunning (true)");
}

mCancelled = true;

if (!isAlive()) {
return false;
}

mCancelled = true;

return true;
}

Expand Down
Loading