diff --git a/.github/scripts/prepare_doxygen.sh b/.github/scripts/prepare_doxygen.sh
deleted file mode 100644
index f87b122..0000000
--- a/.github/scripts/prepare_doxygen.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-project_version=$1
-
-project_name="$(head -n 1 README.md | sed 's/#//')"
-
-repository_name=$(git rev-parse --show-toplevel | xargs basename)
-
-echo "Clone $repository_name..."
-git clone --branch doc https://github.com/eclipse/"$repository_name".git
-
-cd "$repository_name" || exit
-
-echo "Delete existing SNAPSHOT directory..."
-rm -rf ./*-SNAPSHOT
-
-echo "Create target directory $project_version..."
-mkdir "$project_version"
-
-echo "Copy Doxygen doc..."
-cp -rf ../.github/doxygen/out/html/* "$project_version"/
-
-echo "Update versions list..."
-echo "| Version | Documents |" >list_versions.md
-echo "|:---:|---|" >>list_versions.md
-for directory in $(ls -rvd [0-9]*/ | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr | cut -f1 -d'/'); do
- echo "| $directory | [API documentation]($directory) |" >>list_versions.md
-done
-
-echo "Computed all versions:"
-cat list_versions.md
-
-echo "Update project name to $project_name"
-sed -i "2s/.*/title: $project_name/" _config.yml
-
-cd ..
-
-echo "Local docs update finished."
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 248a504..8778107 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -1,4 +1,4 @@
-name: Build and test code
+name: Build and Test code
on:
push:
@@ -6,45 +6,9 @@ on:
- main
pull_request:
-jobs:
- build:
-
- strategy:
- matrix:
- env:
- - toolchain: "toolchain/gcc-linux.cmake"
- runner: ubuntu-latest
- generator: ""
- - toolchain: "toolchain/clang-macos.cmake"
- runner: macos-latest
- generator: ""
- - toolchain: "\"toolchain/clang-windows.cmake\""
- runner: windows-latest
- generator: "-G \"Visual Studio 17 2022\""
-
- runs-on: ${{ matrix.env.runner }}
-
- steps:
- - name: Check out repository
- uses: actions/checkout@v4
- - name: Install Linux reqs
- if: ${{ matrix.env.runner == 'ubuntu-latest' }}
- run: |
- sudo apt-get update
- sudo apt-get install -y clang cmake cppcheck clang-format clang-tidy gcc pre-commit
-
- - name: Install macOS reqs
- if: ${{ matrix.env.runner == 'macos-latest' }}
- run: |
- brew install llvm cppcheck clang-format gcc pre-commit
-
- - name: Build
- run: |
- cmake ${{ matrix.env.generator }} -B build -S . -DCMAKE_TOOLCHAIN_FILE=${{ matrix.env.toolchain }}
- cmake --build build -j8
-
- - name: Run Linux/macOS tests
- if: ${{ matrix.env.runner == 'ubuntu-latest' || matrix.env.runner == 'macos-latest' }}
- run: |
- ./build/bin/keypleservicecpplib_ut
+jobs:
+ call-reusable-workflow:
+ uses: eclipse-keyple/keyple-actions/.github/workflows/reusable-cpp-build-and-test.yml@main # NOSONAR - Same organization, trusted source
+ with:
+ test_executable_name: 'build/bin/keypleservicecpplib_ut'
diff --git a/.github/workflows/publish-doc-release.yml b/.github/workflows/publish-doc-release.yml
index 8e558fe..d26dd8d 100644
--- a/.github/workflows/publish-doc-release.yml
+++ b/.github/workflows/publish-doc-release.yml
@@ -1,47 +1,14 @@
-name: Publish API documentation
-
+name: Publish API documentation (release)
on:
release:
types: [published]
+permissions:
+ checks: write
+
jobs:
publish-doc-release:
- runs-on: ubuntu-latest
- steps:
- - name: Check out repository code from ${{ github.repository }}/${{ github.ref }}
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: Make scripts executable
- run: chmod +x ./.github/scripts/*.sh
-
- - name: Check version
- working-directory: .
- run: ./.github/scripts/check_version.sh $(echo "${{ github.ref }}" | sed -e "s,^refs/tags/,,")
-
- - name: Patch Doxyfile
- working-directory: .
- run: ./.github/scripts/patch_doxyfile.sh ${{ env.PROJECT_VERSION }}
-
- - name: Generate project documentation with Doxygen
- uses: eclipse-keyple/keyple-actions/doxygen@0c8593c4ed6b393642a1732af1fdef84d5e59540
- with:
- working-directory: .github/doxygen/
- doxyfile-path: ./Doxyfile
-
- - name: Prepare Doxygen doc page locally
- working-directory: .
- run: ./.github/scripts/prepare_doxygen.sh ${{ env.PROJECT_VERSION }}
-
- - name: Deploy to doc branch
- run: |
- git config --global user.name "Eclipse Keypop Bot"
- git config --global user.email "${{ github.repository }}-bot@eclipse.org"
- cd ${{ github.event.repository.name }}
- git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
- git add .
- git commit -m "docs: update ${{ github.event.inputs.version || github.ref_name }} documentation"
- git push origin doc --force
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ uses: eclipse-keyple/keyple-actions/.github/workflows/reusable-publish-doxygen.yml@main # NOSONAR - Same organization, trusted source
+ with:
+ version: ${{ github.event.inputs.version || github.ref_name }}
+ secrets: inherit # NOSONAR - Same organization, trusted source
diff --git a/.github/workflows/publish-doc-snapshot.yml b/.github/workflows/publish-doc-snapshot.yml
index 7094036..d5d29a6 100644
--- a/.github/workflows/publish-doc-snapshot.yml
+++ b/.github/workflows/publish-doc-snapshot.yml
@@ -1,50 +1,14 @@
name: Publish API documentation (snapshot)
-
on:
push:
branches:
- main
- - master
- - doxygen
+ workflow_dispatch:
+
+permissions:
+ checks: write
jobs:
publish-doc-snapshot:
- runs-on: ubuntu-latest
- steps:
- - name: Check out repository code from ${{ github.repository }}/${{ github.ref }}
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: Make scripts executable
- run: chmod +x ./.github/scripts/*.sh
-
- - name: Check version
- working-directory: .
- run: ./.github/scripts/check_version.sh
-
- - name: Patch Doxyfile
- working-directory: .
- run: ./.github/scripts/patch_doxyfile.sh ${{ env.PROJECT_VERSION }}
-
- - name: Generate project documentation with Doxygen
- uses: eclipse-keyple/keyple-actions/doxygen@0c8593c4ed6b393642a1732af1fdef84d5e59540
- with:
- working-directory: .github/doxygen/
- doxyfile-path: ./Doxyfile
-
- - name: Prepare Doxygen doc page locally
- working-directory: .
- run: ./.github/scripts/prepare_doxygen.sh ${{ env.PROJECT_VERSION }}
-
- - name: Deploy to doc branch
- run: |
- git config --global user.name "Eclipse Keypop Bot"
- git config --global user.email "${{ github.repository }}-bot@eclipse.org"
- cd ${{ github.event.repository.name }}
- git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
- git add .
- git diff --quiet && git diff --staged --quiet || git commit -m "docs: update snapshot documentation"
- git push origin doc --force
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ uses: eclipse-keyple/keyple-actions/.github/workflows/reusable-publish-doxygen.yml@main # NOSONAR - Same organization, trusted source
+ secrets: inherit # NOSONAR - Same organization, trusted source
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a99e38c..4cbc283 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,12 +13,12 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(KeypleServiceCppLib
- VERSION 3.2.3
+ VERSION 3.3.5
LANGUAGES C CXX)
SET(CMAKE_PROJECT_VERSION_MAJOR "3")
-SET(CMAKE_PROJECT_VERSION_MINOR "2")
-SET(CMAKE_PROJECT_VERSION_PATCH "3")
+SET(CMAKE_PROJECT_VERSION_MINOR "3")
+SET(CMAKE_PROJECT_VERSION_PATCH "5")
SET(CMAKE_PROJECT_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}.
${CMAKE_PROJECT_VERSION_MINOR}.
diff --git a/include/keyple/core/service/AbstractReaderAdapter.hpp b/include/keyple/core/service/AbstractReaderAdapter.hpp
index 08dd728..ac62b26 100644
--- a/include/keyple/core/service/AbstractReaderAdapter.hpp
+++ b/include/keyple/core/service/AbstractReaderAdapter.hpp
@@ -81,6 +81,22 @@ class KEYPLESERVICE_API AbstractReaderAdapter : virtual public CardReader,
*/
const std::string& getPluginName() const;
+ /**
+ * Returns the {@link KeypleReaderExtension} that is reader-specific.
+ *
+ *
Note: the provided argument is used at compile time to check the type
+ * consistency.
+ *
+ * @param readerExtensionClass The specific class of the reader.
+ * @param The type of the reader extension.
+ * @return A {@link KeypleReaderExtension}.
+ * @throw IllegalStateException If reader is no longer registered.
+ * @since 2.0.0
+ */
+ std::shared_ptr
+ getExtension(const std::type_info& readerExtensionClass) const;
+ // FIXME? should be final?
+
/**
* Performs a selection scenario following a card detection.
*
@@ -194,14 +210,6 @@ class KEYPLESERVICE_API AbstractReaderAdapter : virtual public CardReader,
*/
const std::string& getName() const final;
- /**
- * {@inheritDoc}
- *
- * @since 2.0.0
- */
- std::shared_ptr
- getExtension(const std::type_info& readerExtensionClass) const;
-
/**
* {@inheritDoc}
*
diff --git a/include/keyple/core/service/ApduResponseAdapter.hpp b/include/keyple/core/service/ApduResponseAdapter.hpp
index 75cd7c9..b727a2a 100644
--- a/include/keyple/core/service/ApduResponseAdapter.hpp
+++ b/include/keyple/core/service/ApduResponseAdapter.hpp
@@ -60,7 +60,14 @@ class KEYPLESERVICE_API ApduResponseAdapter final : public ApduResponseApi {
*
* @since 2.0.0
*/
- const std::vector getDataOut() const override;
+ void setApdu(const std::vector& apdu) override;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @since 2.0.0
+ */
+ std::vector getDataOut() const override;
/**
* {@inheritDoc}
@@ -85,7 +92,7 @@ class KEYPLESERVICE_API ApduResponseAdapter final : public ApduResponseApi {
/**
*
*/
- const std::vector mApdu;
+ std::vector mApdu;
/**
*
diff --git a/include/keyple/core/service/InternalDto.hpp b/include/keyple/core/service/InternalDto.hpp
index cab0f78..6e04383 100644
--- a/include/keyple/core/service/InternalDto.hpp
+++ b/include/keyple/core/service/InternalDto.hpp
@@ -74,9 +74,9 @@ class KEYPLESERVICE_API InternalDto {
/**
*
*/
- const std::shared_ptr
- parse(const std::shared_ptr
- cardSelectionResponseApi) const override;
+ const std::shared_ptr parse(
+ const std::shared_ptr
+ cardSelectionResponseApi) const override;
private:
/**
diff --git a/include/keyple/core/service/InternalLegacyDto.hpp b/include/keyple/core/service/InternalLegacyDto.hpp
index 51b761c..6087916 100644
--- a/include/keyple/core/service/InternalLegacyDto.hpp
+++ b/include/keyple/core/service/InternalLegacyDto.hpp
@@ -80,6 +80,22 @@ class KEYPLESERVICE_API InternalLegacyDto final {
std::vector mSuccessfulSelectionStatusWords;
};
+ /**
+ * @since 3.3.1
+ */
+ class LegacyCardRequestV0 final {
+ public:
+ /**
+ *
+ */
+ std::vector> mApduRequests;
+
+ /**
+ *
+ */
+ bool mIsStatusCodesVerificationEnabled;
+ };
+
/**
* @since 2.1.1
*/
@@ -104,7 +120,7 @@ class KEYPLESERVICE_API InternalLegacyDto final {
/**
* @since 2.1.1
*/
- class LegacyCardRequest final {
+ class LegacyCardRequestV1 final {
public:
/**
*
@@ -117,10 +133,26 @@ class KEYPLESERVICE_API InternalLegacyDto final {
bool mStopOnUnsuccessfulStatusWord;
};
+ /**
+ * @since 3.3.1
+ */
+ class LegacyCardSelectionRequestV0 final {
+ public:
+ /**
+ *
+ */
+ std::shared_ptr mCardSelector;
+
+ /**
+ *
+ */
+ std::shared_ptr mCardRequest;
+ };
+
/**
* @since 2.1.1
*/
- class LegacyCardSelectionRequest final {
+ class LegacyCardSelectionRequestV1 final {
public:
/**
*
@@ -130,14 +162,23 @@ class KEYPLESERVICE_API InternalLegacyDto final {
/**
*
*/
- std::shared_ptr mCardRequest;
+ std::shared_ptr mCardRequest;
};
/**
*
*/
- static const std::vector>
- mapToLegacyCardSelectionRequests(
+ static const std::vector>
+ mapToLegacyCardSelectionRequestsV0(
+ const std::vector>& cardSelectors,
+ const std::vector>&
+ cardSelectionRequests);
+
+ /**
+ *
+ */
+ static const std::vector>
+ mapToLegacyCardSelectionRequestsV1(
const std::vector>& cardSelectors,
const std::vector>&
cardSelectionRequests);
@@ -145,8 +186,16 @@ class KEYPLESERVICE_API InternalLegacyDto final {
/**
*
*/
- static std::shared_ptr
- mapToLegacyCardSelectionRequest(
+ static std::shared_ptr
+ mapToLegacyCardSelectionRequestV0(
+ std::shared_ptr cardSelector,
+ std::shared_ptr cardSelectionRequestSpi);
+
+ /**
+ *
+ */
+ static std::shared_ptr
+ mapToLegacyCardSelectionRequestV1(
std::shared_ptr cardSelector,
std::shared_ptr cardSelectionRequestSpi);
@@ -161,7 +210,13 @@ class KEYPLESERVICE_API InternalLegacyDto final {
*
*/
static std::shared_ptr
- mapToLegacyCardRequest(const std::shared_ptr cardRequest);
+ mapToLegacyCardRequestV0(const std::shared_ptr cardRequest);
+
+ /**
+ *
+ */
+ static std::shared_ptr
+ mapToLegacyCardRequestV1(const std::shared_ptr cardRequest);
/**
*
diff --git a/include/keyple/core/service/KeyplePluginException.hpp b/include/keyple/core/service/KeyplePluginException.hpp
index 5fb29a8..ab20821 100644
--- a/include/keyple/core/service/KeyplePluginException.hpp
+++ b/include/keyple/core/service/KeyplePluginException.hpp
@@ -15,6 +15,7 @@
#include
#include
+#include
#include "keyple/core/service/KeypleServiceExport.hpp"
#include "keyple/core/util/cpp/exception/RuntimeException.hpp"
@@ -47,8 +48,8 @@ class KEYPLESERVICE_API KeyplePluginException : public RuntimeException {
* @since 2.0.0
*/
KeyplePluginException(
- const std::string& message, const std::shared_ptr cause)
- : RuntimeException(message, cause)
+ const std::string& message, std::unique_ptr cause)
+ : RuntimeException(message, std::move(cause))
{
}
};
diff --git a/include/keyple/core/service/LocalReaderAdapter.hpp b/include/keyple/core/service/LocalReaderAdapter.hpp
index c33104d..63dec5f 100644
--- a/include/keyple/core/service/LocalReaderAdapter.hpp
+++ b/include/keyple/core/service/LocalReaderAdapter.hpp
@@ -172,7 +172,6 @@ class KEYPLESERVICE_API LocalReaderAdapter : public AbstractReaderAdapter {
void releaseChannel() final;
/**
- * (private)
* Local implementation of ApduRequestSpi.
*/
class ApduRequest : public ApduRequestSpi {
@@ -187,7 +186,12 @@ class KEYPLESERVICE_API LocalReaderAdapter : public AbstractReaderAdapter {
/**
*
*/
- std::vector getApdu() const override;
+ const std::vector& getApdu() const override;
+
+ /**
+ * C++
+ */
+ void setApdu(const std::vector& apdu) override;
/**
*
@@ -442,8 +446,10 @@ class KEYPLESERVICE_API LocalReaderAdapter : public AbstractReaderAdapter {
* @param cardSelector A not null CardSelector.
* @param cardSelectionRequest A not null CardSelectionRequestSpi.
* @return A not null {@link SelectionStatus}.
- * @throw ReaderIOException if the communication with the reader has failed.
- * @throw CardIOException if the communication with the card has failed.
+ * @throw ReaderBrokenCommunicationException If the communication with the
+ * reader has failed.
+ * @throw CardBrokenCommunicationException If the communication with the
+ * card has failed.
*/
std::shared_ptr processSelection(
std::shared_ptr cardSelector,
@@ -453,6 +459,7 @@ class KEYPLESERVICE_API LocalReaderAdapter : public AbstractReaderAdapter {
* Attempts to select the card and executes the optional requests if any.
*
* @param cardSelectionRequest The CardSelectionRequestSpi to be processed.
+ * @param channelControl The channelControl.
* @return A not null reference.
* @throw ReaderBrokenCommunicationException If the communication with the
* reader has failed.
@@ -463,7 +470,8 @@ class KEYPLESERVICE_API LocalReaderAdapter : public AbstractReaderAdapter {
*/
std::shared_ptr processCardSelectionRequest(
std::shared_ptr cardSelector,
- std::shared_ptr cardSelectionRequest);
+ std::shared_ptr cardSelectionRequest,
+ const ChannelControl channelControl);
/**
* Transmits an ApduRequestSpi and receives the ApduResponseAdapter.
@@ -479,21 +487,6 @@ class KEYPLESERVICE_API LocalReaderAdapter : public AbstractReaderAdapter {
std::shared_ptr
processApduRequest(const std::shared_ptr apduRequest);
- /**
- * Transmits a CardRequestSpi and returns a CardResponseAdapter.
- *
- * @param cardRequest The card request to transmit.
- * @return A not null reference.
- * @throw ReaderBrokenCommunicationException If the communication with the
- * reader has failed.
- * @throw CardBrokenCommunicationException If the communication with the
- * card has failed.
- * @throw UnexpectedStatusWordException If status word verification is
- * enabled in the card request and the card returned an unexpected code.
- */
- std::shared_ptr
- processCardRequest(const std::shared_ptr cardRequest);
-
/**
*
*/
diff --git a/include/keyple/core/service/ObservableLocalPluginAdapter.hpp b/include/keyple/core/service/ObservableLocalPluginAdapter.hpp
index 41a9134..b885ed6 100644
--- a/include/keyple/core/service/ObservableLocalPluginAdapter.hpp
+++ b/include/keyple/core/service/ObservableLocalPluginAdapter.hpp
@@ -98,7 +98,7 @@ class KEYPLESERVICE_API ObservableLocalPluginAdapter final
*
*/
void uncaughtException(
- std::shared_ptr t, std::shared_ptr e);
+ std::shared_ptr t, std::unique_ptr e);
private:
/**
diff --git a/include/keyple/core/service/ObservableLocalReaderAdapter.hpp b/include/keyple/core/service/ObservableLocalReaderAdapter.hpp
index 883e6dd..defbe6b 100644
--- a/include/keyple/core/service/ObservableLocalReaderAdapter.hpp
+++ b/include/keyple/core/service/ObservableLocalReaderAdapter.hpp
@@ -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(event) << ")";
+ break;
+ }
+ return os;
+}
+
} /* namespace service */
} /* namespace core */
} /* namespace keyple */
diff --git a/include/keyple/core/service/PluginEvent.hpp b/include/keyple/core/service/PluginEvent.hpp
index 6a2bcee..ae09794 100644
--- a/include/keyple/core/service/PluginEvent.hpp
+++ b/include/keyple/core/service/PluginEvent.hpp
@@ -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(t) << ")";
break;
}
diff --git a/include/keyple/core/service/SmartCardService.hpp b/include/keyple/core/service/SmartCardService.hpp
index bddfc79..f4afb9b 100644
--- a/include/keyple/core/service/SmartCardService.hpp
+++ b/include/keyple/core/service/SmartCardService.hpp
@@ -20,6 +20,7 @@
#include "keyple/core/common/KeypleCardExtension.hpp"
#include "keyple/core/common/KeyplePluginExtensionFactory.hpp"
#include "keyple/core/service/KeypleServiceExport.hpp"
+#include "keyple/core/service/Plugin.hpp"
#include "keypop/reader/ReaderApiFactory.hpp"
namespace keyple {
@@ -28,6 +29,7 @@ namespace service {
using keyple::core::common::KeypleCardExtension;
using keyple::core::common::KeyplePluginExtensionFactory;
+using keyple::core::service::Plugin;
using keypop::reader::ReaderApiFactory;
/**
@@ -134,7 +136,8 @@ class KEYPLESERVICE_API SmartCardService {
* @since 2.0.0
*/
virtual void checkCardExtension(
- const std::shared_ptr cardExtension) const = 0;
+ const std::shared_ptr cardExtension) const
+ = 0;
/**
* Registers a new distributed local service to the service.
diff --git a/include/keyple/core/service/cpp/ExecutorService.hpp b/include/keyple/core/service/cpp/ExecutorService.hpp
index eae19b1..6a4c068 100644
--- a/include/keyple/core/service/cpp/ExecutorService.hpp
+++ b/include/keyple/core/service/cpp/ExecutorService.hpp
@@ -13,7 +13,9 @@
#pragma once
+#include
#include
+#include
#include
#include
#include
@@ -74,25 +76,35 @@ class KEYPLESERVICE_API ExecutorService final {
/**
*
*/
- void run();
+ std::mutex mMutex;
+
+ /**
+ *
+ */
+ std::condition_variable mCondition;
/**
*
*/
- std::atomic mRunning;
+ bool mRunning;
/**
*
*/
- std::atomic mTerminated;
+ bool mTerminated;
/**
*
*/
- std::thread* mThread;
+ std::unique_ptr mThread;
+
+ /**
+ *
+ */
+ void run();
};
} /* namespace cpp */
} /* namespace service */
} /* namespace core */
-} /* namespace keyple */
+} /* namespace keyple */
\ No newline at end of file
diff --git a/include/keyple/core/service/spi/PluginObservationExceptionHandlerSpi.hpp b/include/keyple/core/service/spi/PluginObservationExceptionHandlerSpi.hpp
index 04c9299..2909049 100644
--- a/include/keyple/core/service/spi/PluginObservationExceptionHandlerSpi.hpp
+++ b/include/keyple/core/service/spi/PluginObservationExceptionHandlerSpi.hpp
@@ -44,8 +44,7 @@ class PluginObservationExceptionHandlerSpi {
* @since 2.0.0
*/
virtual void onPluginObservationError(
- const std::string& pluginName, const std::shared_ptr e)
- = 0;
+ const std::string& pluginName, std::unique_ptr e) = 0;
};
} /* namespace spi */
diff --git a/src/main/AbstractObservableLocalPluginAdapter.cpp b/src/main/AbstractObservableLocalPluginAdapter.cpp
index d333f32..0703fb9 100644
--- a/src/main/AbstractObservableLocalPluginAdapter.cpp
+++ b/src/main/AbstractObservableLocalPluginAdapter.cpp
@@ -15,6 +15,7 @@
#include
#include
+#include
#include
#include "keyple/core/service/PluginEventAdapter.hpp"
@@ -53,9 +54,10 @@ AbstractObservableLocalPluginAdapter::ObservableLocalPluginAdapterJob::execute()
AbstractObservableLocalPluginAdapter::AbstractObservableLocalPluginAdapter(
std::shared_ptr pluginSpi)
: LocalPluginAdapter(pluginSpi)
-, mObservationManager(std::make_shared>("", ""))
+, mObservationManager(
+ std::make_shared>("", ""))
{
}
@@ -89,15 +91,16 @@ AbstractObservableLocalPluginAdapter::notifyObserver(
{
try {
observer->onPluginEvent(event);
+
} catch (const Exception& e) {
+ auto _e(std::unique_ptr(new Exception(e)));
try {
mObservationManager->getObservationExceptionHandler()
- ->onPluginObservationError(
- getName(), std::make_shared(e));
+ ->onPluginObservationError(getName(), std::move(_e));
+
} catch (const Exception& e2) {
- mLogger->error(
- "Event notification error: % %\n", e2.getMessage(), e2);
- mLogger->error("Original cause: % %\n", e.getMessage(), e);
+ mLogger->error("Event notification error: %\n", e2.getMessage());
+ mLogger->error("Original cause: %\n", e.getMessage());
}
}
}
@@ -107,8 +110,11 @@ AbstractObservableLocalPluginAdapter::doUnregister()
{
const std::vector& unregisteredReaderNames = getReaderNames();
- notifyObservers(std::make_shared(
- getName(), unregisteredReaderNames, PluginEvent::Type::UNAVAILABLE));
+ notifyObservers(
+ std::make_shared(
+ getName(),
+ unregisteredReaderNames,
+ PluginEvent::Type::UNAVAILABLE));
clearObservers();
LocalPluginAdapter::doUnregister();
diff --git a/src/main/AbstractPluginAdapter.cpp b/src/main/AbstractPluginAdapter.cpp
index 9721f6a..7ececd4 100644
--- a/src/main/AbstractPluginAdapter.cpp
+++ b/src/main/AbstractPluginAdapter.cpp
@@ -16,6 +16,7 @@
#include