From ff0774f93a64bfd51de1278796abe1f15ba5dd67 Mon Sep 17 00:00:00 2001 From: Alexandre MUNSCH Date: Sun, 6 Apr 2025 09:28:16 -0500 Subject: [PATCH] feat: updated to 2.2.1 --- .clang-format | 300 ++++++++++++++++++ .clang-tidy | 14 + .cppcheck.suppress | 6 + .github/scripts/check_version.sh | 2 +- .github/scripts/patch_doxyfile.sh | 2 +- .github/scripts/prepare_doxygen.sh | 3 - .github/workflows/build-and-test.yml | 14 + .github/workflows/publish-doc-release.yml | 43 +-- .github/workflows/publish-doc-snapshot.yml | 42 +-- .gitignore | 42 +++ .pre-commit-config.yaml | 48 +++ CMakeLists.txt | 38 +-- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 18 +- CPPLINT.cfg | 3 + NOTICE.md | 1 - PUBLISHERS.yml | 2 +- README.md | 1 - SECURITY.md | 2 +- .../plugin/stub/KeyplePluginStubExport.hpp | 21 ++ include/keyple/plugin/stub/StubPlugin.hpp | 64 ++++ .../keyple/plugin/stub/StubPluginAdapter.hpp | 70 ++-- .../keyple/plugin/stub/StubPluginFactory.hpp | 39 +++ .../plugin/stub/StubPluginFactoryAdapter.hpp | 64 ++-- .../plugin/stub/StubPluginFactoryBuilder.hpp | 67 ++-- include/keyple/plugin/stub/StubPoolPlugin.hpp | 68 ++++ .../plugin/stub/StubPoolPluginAdapter.hpp | 82 ++--- .../plugin/stub/StubPoolPluginFactory.hpp | 32 ++ .../stub/StubPoolPluginFactoryAdapter.hpp | 75 ++--- .../stub/StubPoolPluginFactoryBuilder.hpp | 62 ++-- include/keyple/plugin/stub/StubReader.hpp | 64 ++++ .../keyple/plugin/stub/StubReaderAdapter.hpp | 110 ++++--- .../keyple/plugin/stub/StubSmartCard.hpp | 132 +++++--- .../stub/spi/ApduResponseProviderSpi.hpp | 49 +++ src/CMakeLists.txt | 2 +- src/main/CMakeLists.txt | 47 +-- src/main/CMakeLists.txt.keyple-common | 40 +++ src/main/CMakeLists.txt.keyple-plugin | 40 +++ src/main/CMakeLists.txt.keyple-util | 47 +++ src/main/CMakeLists.txt.keypop-reader | 40 +++ src/main/KeyplePluginStubExport.h | 23 -- src/main/StubPlugin.h | 64 ---- src/main/StubPluginAdapter.cpp | 77 +++-- src/main/StubPluginFactory.h | 34 -- src/main/StubPluginFactoryAdapter.cpp | 106 ++++--- src/main/StubPluginFactoryBuilder.cpp | 64 ++-- src/main/StubPoolPlugin.h | 63 ---- src/main/StubPoolPluginAdapter.cpp | 150 +++++---- src/main/StubPoolPluginFactory.h | 34 -- src/main/StubPoolPluginFactoryAdapter.cpp | 102 +++--- src/main/StubPoolPluginFactoryBuilder.cpp | 79 +++-- src/main/StubReader.h | 67 ---- src/main/StubReaderAdapter.cpp | 175 +++++----- src/main/StubSmartCard.cpp | 136 ++++---- src/main/spi/ApduResponseProviderSpi.h | 48 --- src/test/CMakeLists.txt | 73 ++--- src/test/CMakeLists.txt.googletest | 64 ++-- src/test/CMakeLists.txt.in | 28 -- src/test/MainTest.cpp | 35 +- src/test/StubPluginAdapterTest.cpp | 70 ++-- src/test/StubPluginFactoryAdapterTest.cpp | 94 +++--- src/test/StubPoolPluginAdapterTest.cpp | 121 ++++--- src/test/StubPoolPluginFactoryAdapterTest.cpp | 90 +++--- src/test/StubReaderAdapterTest.cpp | 83 ++--- src/test/StubSmartCardTest.cpp | 102 +++--- toolchain/arm-unknown-gnueabi-linux.cmake | 5 +- toolchain/clang-8-linux.cmake | 1 - toolchain/clang-9-linux.cmake | 1 - toolchain/clang-linux.cmake | 1 - toolchain/clang-macos.cmake | 1 - toolchain/clang-windows.cmake | 5 +- toolchain/gcc-10-linux.cmake | 1 - toolchain/gcc-4.8.3-linux.cmake | 1 - toolchain/gcc-8-linux.cmake | 1 - toolchain/gcc-9-linux.cmake | 1 - toolchain/gcc-linux.cmake | 1 - toolchain/ios-macos.cmake | 1 - 77 files changed, 2258 insertions(+), 1542 deletions(-) create mode 100644 .clang-format create mode 100644 .clang-tidy create mode 100644 .cppcheck.suppress create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 CPPLINT.cfg create mode 100644 include/keyple/plugin/stub/KeyplePluginStubExport.hpp create mode 100644 include/keyple/plugin/stub/StubPlugin.hpp rename src/main/StubPluginAdapter.h => include/keyple/plugin/stub/StubPluginAdapter.hpp (57%) create mode 100644 include/keyple/plugin/stub/StubPluginFactory.hpp rename src/main/StubPluginFactoryAdapter.h => include/keyple/plugin/stub/StubPluginFactoryAdapter.hpp (67%) rename src/main/StubPluginFactoryBuilder.h => include/keyple/plugin/stub/StubPluginFactoryBuilder.hpp (59%) create mode 100644 include/keyple/plugin/stub/StubPoolPlugin.hpp rename src/main/StubPoolPluginAdapter.h => include/keyple/plugin/stub/StubPoolPluginAdapter.hpp (57%) create mode 100644 include/keyple/plugin/stub/StubPoolPluginFactory.hpp rename src/main/StubPoolPluginFactoryAdapter.h => include/keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp (56%) rename src/main/StubPoolPluginFactoryBuilder.h => include/keyple/plugin/stub/StubPoolPluginFactoryBuilder.hpp (63%) create mode 100644 include/keyple/plugin/stub/StubReader.hpp rename src/main/StubReaderAdapter.h => include/keyple/plugin/stub/StubReaderAdapter.hpp (57%) rename src/main/StubSmartCard.h => include/keyple/plugin/stub/StubSmartCard.hpp (70%) create mode 100644 include/keyple/plugin/stub/spi/ApduResponseProviderSpi.hpp mode change 100644 => 100755 src/CMakeLists.txt create mode 100644 src/main/CMakeLists.txt.keyple-common create mode 100644 src/main/CMakeLists.txt.keyple-plugin create mode 100644 src/main/CMakeLists.txt.keyple-util create mode 100644 src/main/CMakeLists.txt.keypop-reader delete mode 100644 src/main/KeyplePluginStubExport.h delete mode 100644 src/main/StubPlugin.h delete mode 100644 src/main/StubPluginFactory.h delete mode 100644 src/main/StubPoolPlugin.h delete mode 100644 src/main/StubPoolPluginFactory.h delete mode 100644 src/main/StubReader.h delete mode 100644 src/main/spi/ApduResponseProviderSpi.h delete mode 100644 src/test/CMakeLists.txt.in diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..2fd4acc --- /dev/null +++ b/.clang-format @@ -0,0 +1,300 @@ +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +#http://clang.llvm.org/docs/ClangFormatStyleOptions.html + +# The style used for all options not specifically set in the configuration. +# This option is supported only in the clang-format configuration (both within +# -style='{...}' and the .clang-format file). +# LLVM A style complying with the LLVM coding standards +# Google A style complying with Google’s C++ style guide +# Chromium A style complying with Chromium’s style guide +# Mozilla A style complying with Mozilla’s style guide +# WebKit A style complying with WebKit’s style guide +BasedOnStyle: Webkit + +# The extra indent or outdent of access modifiers, e.g. public:. +AccessModifierOffset: -4 + +# If true, horizontally aligns arguments after an open bracket. +# This applies to round brackets (parentheses), angle brackets and square +# brackets. This will result in formattings like code +# someLongFunction(argument1, argument2); endcode +AlignAfterOpenBracket: AlwaysBreak + +# If true, aligns escaped newlines as far left as possible. Otherwise puts them +# into the right-most column. +#AlignEscapedNewlinesLeft + +# If true, horizontally align operands of binary and ternary expressions. +AlignOperands: true + +# If true, aligns trailing comments. +AlignTrailingComments: true + +# Allow putting all parameters of a function declaration onto the next line even +# if BinPackParameters is false. +AllowAllParametersOfDeclarationOnNextLine: true + +# Allows contracting simple braced statements to a single line. +# E.g., this allows if (a) { return; } to be put on a single line. +AllowShortBlocksOnASingleLine: false + +# If true, short case labels will be contracted to a single line. +AllowShortCaseLabelsOnASingleLine: false + +# Dependent on the value, int f() { return 0; } can be put on a single line. +# SFS_None (in configuration: None) Never merge functions into a single line. +# SFS_Inline (in configuration: Inline) Only merge functions defined inside a +# class. +# SFS_Empty (in configuration: Empty) Only merge empty functions. +# SFS_All (in configuration: All) Merge all functions fitting on a single line. +AllowShortFunctionsOnASingleLine: None + +# If true, if (a) return; can be put on a single line. +#AllowShortIfStatementsOnASingleLine: false + +# If true, while (true) continue; can be put on a single line. +AllowShortLoopsOnASingleLine: true + +# If true, always break after function definition return types. +# More truthfully called ‘break before the identifier following the type in a +# function definition’. +# PenaltyReturnTypeOnItsOwnLine becomes irrelevant. +AlwaysBreakAfterDefinitionReturnType: All + +# If true, always break before multiline string literals. +AlwaysBreakBeforeMultilineStrings: false + +# If true, always break after the template<...> of a template declaration. +AlwaysBreakTemplateDeclarations: true + +# If false, a function call’s arguments will either be all on the same line or +# will have one line each. +BinPackArguments: false + +# If false, a function call’s arguments will either be all +# on the same line or will have one line each. +BinPackParameters: false + +# The way to wrap binary operators. +# BOS_None (in configuration: None) Break after operators. +# BOS_NonAssignment (in configuration: NonAssignment) Break before operators +# that aren’t assignments. +# BOS_All (in configuration: All) Break before operators. +#BreakBeforeBinaryOperators: None + +# The brace breaking style to use. +# BS_Attach (in configuration: Attach) Always attach braces to surrounding +# context. +# BS_Linux (in configuration: Linux) Like Attach, but break before braces on +# function, namespace and class definitions. +# BS_Stroustrup (in configuration: Stroustrup) Like Attach, but break before +# function definitions, and ‘else’. +# BS_Allman (in configuration: Allman) Always break before braces. +# BS_GNU (in configuration: GNU) Always break before braces and add an extra +# level of indentation to braces of control statements, not to those of class, +# function or other definitions. +BreakBeforeBraces: WebKit + +# If true, ternary operators will be placed after line breaks. +BreakBeforeTernaryOperators: true + +# Always break constructor initializers before commas and align the commas with +# the colon. +BreakConstructorInitializersBeforeComma: true + +# The column limit. +# A column limit of 0 means that there is no column limit. In this case, +# clang-format will respect the input’s line breaking decisions within +# statements unless they contradict other rules. +ColumnLimit: 80 + +# A regular expression that describes comments with special meaning, which +# should not be split into lines or otherwise changed. +CommentPragmas: "\/*(.*)*\/" + +# If the constructor initializers don’t fit on a line, put each initializer on +# its own line. +#ConstructorInitializerAllOnOneLineOrOnePerLine: false + +# The number of characters to use for indentation of constructor initializer +# lists. +ConstructorInitializerIndentWidth: 0 + +# Indent width for line continuations. +#ContinuationIndentWidth: 4 + +# If true, format braced lists as best suited for C++11 braced lists. +# Important differences: - No spaces inside the braced list. - No line break +# before the closing brace. - Indentation with the continuation indent, not with +# the block indent. +# Fundamentally, C++11 braced lists are formatted exactly like function calls +# would be formatted in their place. If the braced list follows a name (e.g. a +# type or variable name), clang-format formats as if the {} were the parentheses +# of a function call with that name. If there is no name, a zero-length name is +# assumed. +Cpp11BracedListStyle: true + +# If true, analyze the formatted file for the most common alignment of & and *. +# Point +#DerivePointerAlignment: false + +# Disables formatting at all. +#DisableFormat: false + +# If true, clang-format detects whether function calls and definitions are +# formatted with one parameter per line. +# Each call can be bin-packed, one-per-line or inconclusive. If it is +# inconclusive, e.g. completely on one line, but a decision needs to be made, +# clang-format analyzes whether there are other bin-packed cases in the input +# file and act accordingly. +# NOTE: This is an experimental flag, that might go away or be renamed. Do not +# use this in config files, etc. Use at your own risk. +ExperimentalAutoDetectBinPacking: false + +# A vector of macros that should be interpreted as foreach loops instead of as +# function calls. +# These are expected to be macros of the form: code +# FOREACH(, ...) endcode +# For example: BOOST_FOREACH. +#ForEachMacros (std::vector) + +# Indent case labels one level from the switch statement. +# When false, use the same indentation level as for the switch statement. Switch +# statement body is always indented one level more than case labels. +IndentCaseLabels: false + +# The number of columns to use for indentation. +IndentWidth: 4 + +# Indent if a function definition or declaration is wrapped after the type. +#IndentWrappedFunctionNames: false + +# If true, empty lines at the start of blocks are kept. +KeepEmptyLinesAtTheStartOfBlocks: false + +# Language, this format style is targeted at. +# LK_None (in configuration: None) Do not use. +# LK_Cpp (in configuration: Cpp) Should be used for C, C++, ObjectiveC, +# ObjectiveC++. +# LK_Java (in configuration: Java) Should be used for Java. +# LK_JavaScript (in configuration: JavaScript) Should be used for JavaScript. +# LK_Proto (in configuration: Proto) Should be used for Protocol Buffers +# (https://developers.google.com/protocol-buffers/). +Language: Cpp + +# The maximum number of consecutive empty lines to keep. +#MaxEmptyLinesToKeep: 0 + +# The indentation used for namespaces. +# NI_None (in configuration: None) Don’t indent in namespaces. +# NI_Inner (in configuration: Inner) Indent only in inner namespaces (nested in +# other namespaces). +# NI_All (in configuration: All) Indent in all namespaces. +NamespaceIndentation: None + +# The number of characters to use for indentation of ObjC blocks. +#ObjCBlockIndentWidth: 4 + +# Add a space after @property in Objective-C, i.e. use \@property (readonly) +# instead of \@property(readonly). +#ObjCSpaceAfterProperty: false + +# Add a space in front of an Objective-C protocol list, i.e. use Foo +# instead of Foo. +#ObjCSpaceBeforeProtocolList: false + +# The penalty for breaking a function call after “call(”. +#PenaltyBreakBeforeFirstCallParameter (unsigned) + +# The penalty for each line break introduced inside a comment. +#PenaltyBreakComment (unsigned) + +# The penalty for breaking before the first <<. +#PenaltyBreakFirstLessLess (unsigned) + +# The penalty for each line break introduced inside a string literal. +#PenaltyBreakString (unsigned) + +# The penalty for each character outside of the column limit. +#PenaltyExcessCharacter (unsigned) + +# Penalty for putting the return type of a function onto its own line. +#PenaltyReturnTypeOnItsOwnLine (unsigned) + +# If true, analyze the formatted file for the most common alignment of & and *. +# PointerAlignment is then used only as fallback. +PointerAlignment: Left + +# If true, a space may be inserted after C style casts. +SpaceAfterCStyleCast: false + +# If false, spaces will be removed before assignment operators. +SpaceBeforeAssignmentOperators: true + +# Defines in which cases to put a space before opening parentheses. +# SBPO_Never (in configuration: Never) Never put a space before opening +# parentheses. +# SBPO_ControlStatements (in configuration: ControlStatements) Put a space +# before opening parentheses only after control statement keywords +# (for/if/while...). +# SBPO_Always (in configuration: Always) Always put a space before opening +# parentheses, except when it’s prohibited by the syntax rules (in function-like +# macro definitions) or when determined by other style rules (after unary +# operators, opening parentheses, etc.) +SpaceBeforeParens: ControlStatements + +# If true, spaces may be inserted into ‘()’. +SpaceInEmptyParentheses: false + +# The number of spaces before trailing line comments (// - comments). +# This does not affect trailing block comments (/**/ - comments) as those +# commonly have different usage patterns and a number of special cases. +SpacesBeforeTrailingComments: 2 + +# If true, spaces will be inserted after ‘<’ and before ‘>’ in template argument +# lists +SpacesInAngles: false + +# If true, spaces may be inserted into C style casts. +SpacesInCStyleCastParentheses: false + +# If true, spaces are inserted inside container literals (e.g. ObjC and +# Javascript array and dict literals). +SpacesInContainerLiterals: false + +# If true, spaces will be inserted after ‘(‘ and before ‘)’. +SpacesInParentheses: false + +# If true, spaces will be inserted after ‘[‘ and before ‘]’. +SpacesInSquareBrackets: false + +# Format compatible with this standard, e.g. use A > instead of A> +# for LS_Cpp03. +# LS_Cpp03 (in configuration: Cpp03) Use C++03-compatible syntax. +# LS_Cpp11 (in configuration: Cpp11) Use features of C++11 (e.g. A> +# instead of A >). +# LS_Auto (in configuration: Auto) Automatic detection based on the input. +Standard: Cpp11 + +# The number of columns used for tab stops. +TabWidth: 4 + +# The way to use tab characters in the resulting file. +# UT_Never (in configuration: Never) Never use tab. +# UT_ForIndentation (in configuration: ForIndentation) Use tabs only for +# indentation. +# UT_Always (in configuration: Always) Use tabs whenever we need to fill +# whitespace that spans at least from one tab stop to the next one. +UseTab: Never + +# Indent code enclosed in an extern block +IndentExternBlock: NoIndent diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..7adfeed --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,14 @@ +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +Checks: '-checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*' +WarningsAsErrors: true +HeaderFilterRegex: '.*' +FormatStyle: webkit diff --git a/.cppcheck.suppress b/.cppcheck.suppress new file mode 100644 index 0000000..640316f --- /dev/null +++ b/.cppcheck.suppress @@ -0,0 +1,6 @@ +cstyleCast +missingIncludeSystem +missingInclude +unusedStructMember +accessMoved +normalCheckLevelMaxBranches diff --git a/.github/scripts/check_version.sh b/.github/scripts/check_version.sh index e776a4e..ea0c841 100644 --- a/.github/scripts/check_version.sh +++ b/.github/scripts/check_version.sh @@ -32,4 +32,4 @@ fi echo "PROJECT_VERSION=$version" >> $GITHUB_ENV -echo "Retained PROJECT_VERSION=$version" \ No newline at end of file +echo "Retained PROJECT_VERSION=$version" diff --git a/.github/scripts/patch_doxyfile.sh b/.github/scripts/patch_doxyfile.sh index 65d38f3..a6d5e9f 100644 --- a/.github/scripts/patch_doxyfile.sh +++ b/.github/scripts/patch_doxyfile.sh @@ -6,4 +6,4 @@ sed -i "s/%PROJECT_VERSION%/$project_version/g" ./.github/doxygen/Doxyfile project_name="$(head -n 1 README.md | sed 's/#//')" -sed -i "s/%PROJECT_NAME%/$project_name/g" ./.github/doxygen/Doxyfile \ No newline at end of file +sed -i "s/%PROJECT_NAME%/$project_name/g" ./.github/doxygen/Doxyfile diff --git a/.github/scripts/prepare_doxygen.sh b/.github/scripts/prepare_doxygen.sh index 543d953..f87b122 100644 --- a/.github/scripts/prepare_doxygen.sh +++ b/.github/scripts/prepare_doxygen.sh @@ -36,6 +36,3 @@ 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 new file mode 100644 index 0000000..b72ee45 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,14 @@ +name: Build and Test code + +on: + push: + branches: + - main + pull_request: + + +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/keyplepluginstubcpplib_ut' diff --git a/.github/workflows/publish-doc-release.yml b/.github/workflows/publish-doc-release.yml index 5c65148..d26dd8d 100644 --- a/.github/workflows/publish-doc-release.yml +++ b/.github/workflows/publish-doc-release.yml @@ -1,41 +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: mattnotmitt/doxygen-action@v1.9.2 - 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 }} \ No newline at end of file + 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 55afb9a..d5d29a6 100644 --- a/.github/workflows/publish-doc-snapshot.yml +++ b/.github/workflows/publish-doc-snapshot.yml @@ -1,44 +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: mattnotmitt/doxygen-action@v1.9.2 - 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 }} \ No newline at end of file + 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/.gitignore b/.gitignore new file mode 100644 index 0000000..7dc582b --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Build directories +build +out + +# IDE files +CMakeSettings.json + +# OS +.DS_Store diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3beb443 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,48 @@ +#************************************************************************************************** +#* Copyright (c) 2024 Calypso Networks Association https://calypsonet.org/ * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the MIT License which is available at https://opensource.org/licenses/MIT. * +#* * +#* SPDX-License-Identifier: MIT * +#**************************************************************************************************/ + +fail_fast: false + +repos: + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + + - repo: https://github.com/pocc/pre-commit-hooks + rev: master + hooks: + - id: clang-tidy + name: clang-tidy + entry: clang-tidy -p=build + --system-headers + --fix-errors + + # Code formatting (see .clang-format for config used). + - id: clang-format + name: clang-format + args: [-i] + + # Static code analysis (for C++ files). + - id: cppcheck + name: cppcheck + args: [--enable=all, + --error-exitcode=1, + --language=c++, + --std=c++11, + --suppressions-list=./.cppcheck.suppress] + files: \.(cpp|hpp)$ + + # Coding style analysis. Based on Google C++ code style. + # cpplint configuration can be found in CPPLINT.cfg. + - id: cpplint diff --git a/CMakeLists.txt b/CMakeLists.txt index a575c7d..2a2b153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,21 @@ -# ************************************************************************************************* -# Copyright (c) 2023 Calypso Networks Association https://calypsonet.org/ * -# * -# See the NOTICE file(s) distributed with this work for additional information regarding * -# copyright ownership. * -# * -# This program and the accompanying materials are made available under the terms of the Eclipse * -# Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * -# * -# SPDX-License-Identifier: EPL-2.0 * -# *************************************************************************************************/ - -PROJECT(KeyplePluginStubCppLib C CXX) -CMAKE_MINIMUM_REQUIRED(VERSION 3.0) +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) +PROJECT(KeyplePluginStubCppLib + VERSION 2.2.1 + LANGUAGES C CXX) SET(CMAKE_PROJECT_VERSION_MAJOR "2") -SET(CMAKE_PROJECT_VERSION_MINOR "1") -SET(CMAKE_PROJECT_VERSION_PATCH "2") +SET(CMAKE_PROJECT_VERSION_MINOR "2") +SET(CMAKE_PROJECT_VERSION_PATCH "1") SET(CMAKE_PROJECT_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}. ${CMAKE_PROJECT_VERSION_MINOR}. @@ -42,9 +42,3 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # Add projects ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src) - -# Dependencies (for later use): -# -# keyple-common-cpp-api:2.0.0 -# keyple-plugin-cpp-api:2.0.0 -# keyple-util-cpp-lib:2.1.0 \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c347b27..33bd8b6 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -90,4 +90,4 @@ The Eclipse Foundation Board of Directors may amend this Code from time to time This Code was inspired by the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4, available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct/). -[^1]: Capitalized terms used herein without definition shall have the meanings assigned to them in the Bylaws. \ No newline at end of file +[^1]: Capitalized terms used herein without definition shall have the meanings assigned to them in the Bylaws. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e99c61c..5052fad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,38 +2,38 @@ **Welcome to the Eclipse Keyple Community!** -We are thrilled to have you onboard and look forward to your contributions. Whether you're a coder, designer, -documenter, or enthusiast, your involvement is invaluable to us. Here's how you can start contributing to Eclipse +We are thrilled to have you onboard and look forward to your contributions. Whether you're a coder, designer, +documenter, or enthusiast, your involvement is invaluable to us. Here's how you can start contributing to Eclipse Keyple: ## Quick Start 1. **Read the Contribution Guidelines**: Before starting, please visit our detailed contributing guide at the -[Eclipse Keyple Contribution Guide](https://keyple.org/community/contributing/). +[Eclipse Keyple Contribution Guide](https://keyple.org/community/contributing/). This guide covers all the necessary information about contributing to the project. -2. **Join the mailing list**: Connect with other contributors on our -[mailing list](https://accounts.eclipse.org/mailing-list/keyple-dev/). +2. **Join the mailing list**: Connect with other contributors on our +[mailing list](https://accounts.eclipse.org/mailing-list/keyple-dev/). It's a great place to ask questions, share ideas, and collaborate. 3. **Explore Open Issues**: Check out the issues tab in our GitHub repository. ## How to Contribute -- **Code**: Submit pull requests with bug fixes, new features, and improvements. Make sure to follow the code style and +- **Code**: Submit pull requests with bug fixes, new features, and improvements. Make sure to follow the code style and testing guidelines. - **Documentation**: Help us improve our documentation by fixing errors, adding examples, or writing tutorials. -- **Feedback**: Share your experience using Eclipse Keyple. Feedback on usability, features, and your overall experience +- **Feedback**: Share your experience using Eclipse Keyple. Feedback on usability, features, and your overall experience is incredibly valuable. -- **Community Support**: Answer questions on the community forums, help with user support, and participate in +- **Community Support**: Answer questions on the community forums, help with user support, and participate in discussions. ## Need Help? -If you have any questions or need assistance, please reach out on the +If you have any questions or need assistance, please reach out on the [mailing list](https://accounts.eclipse.org/mailing-list/keyple-dev/). --- diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 0000000..0c881ca --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,3 @@ +set noparent +filter=-whitespace/indent,-build/c++11,-runtime/references,-whitespace/braces,-whitespace/blank_line,-runtime/string +linelength=80 diff --git a/NOTICE.md b/NOTICE.md index 0719a26..ebadca3 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -33,4 +33,3 @@ SPDX-License-Identifier: EPL-2.0 ## Third-party Content No third party - diff --git a/PUBLISHERS.yml b/PUBLISHERS.yml index a1980da..eccabf6 100644 --- a/PUBLISHERS.yml +++ b/PUBLISHERS.yml @@ -15,4 +15,4 @@ scm: url: https://github.com/eclipse/keyple-plugin-stub-cpp-lib ciManagement: system: GitHub Actions - url: https://github.com/eclipse/keyple-plugin-stub-cpp-lib/actions \ No newline at end of file + url: https://github.com/eclipse/keyple-plugin-stub-cpp-lib/actions diff --git a/README.md b/README.md index 106069d..d8bd14f 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,3 @@ Examples of implementation are available in the following repository: [github.co ## About the source code The code is built with **CLang / GCC / MSVC** in order to address a wide range of applications. - diff --git a/SECURITY.md b/SECURITY.md index bfb9250..0b90d27 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,4 +6,4 @@ This project implements the Eclipse Foundation Security Policy ## Reporting a Vulnerability -Please report vulnerabilities to the Eclipse Foundation Security Team at security@eclipse.org \ No newline at end of file +Please report vulnerabilities to the Eclipse Foundation Security Team at security@eclipse.org diff --git a/include/keyple/plugin/stub/KeyplePluginStubExport.hpp b/include/keyple/plugin/stub/KeyplePluginStubExport.hpp new file mode 100644 index 0000000..47ae01c --- /dev/null +++ b/include/keyple/plugin/stub/KeyplePluginStubExport.hpp @@ -0,0 +1,21 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#if defined(WIN32) +#if defined(KEYPLEPLUGINSTUB_EXPORT) +#define KEYPLEPLUGINSTUB_API __declspec(dllexport) +#else +#define KEYPLEPLUGINSTUB_API __declspec(dllimport) +#endif +#else +#define KEYPLEPLUGINSTUB_API +#endif diff --git a/include/keyple/plugin/stub/StubPlugin.hpp b/include/keyple/plugin/stub/StubPlugin.hpp new file mode 100644 index 0000000..930a019 --- /dev/null +++ b/include/keyple/plugin/stub/StubPlugin.hpp @@ -0,0 +1,64 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include +#include + +#include "keyple/core/common/KeyplePluginExtension.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" + +namespace keyple { +namespace plugin { +namespace stub { + +using keyple::core::common::KeyplePluginExtension; + +/** + * Specific methods of the Stub Plugin. Implemented as a {@link + * KeyplePluginExtension}. To invoke those methods use + * Plugin#getExtension(StubPlugin.class) from the Plugin class. + * + * @since 2.0.0 + */ +class StubPlugin : public KeyplePluginExtension { +public: + /** + * Plug a new {@link StubReader}. This operation is asynchronous and will + * raise a READER_CONNECTED event. A new {@link StubReader} is created and + * make available in the plugin + * + * @param name name for the reader (not nullable and unique) + * @param isContactless true if the created reader should be contactless, + * false if not. + * @param card created reader can contain a card (nullable) + * @since 2.0.0 + */ + virtual void plugReader( + const std::string& name, + const bool isContactless, + std::shared_ptr card) + = 0; + + /** + * Unplug a {@link StubReader}. This operation is asynchronous and will + * raise a READER_DISCONNECTED event. The reader is removed from the * + * available list of reader. It does nothing if no reader matches the name. + * + * @param name the name of the reader to unplug (not nullable) + * @since 2.0.0 + */ + virtual void unplugReader(const std::string& name) = 0; +}; + +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPluginAdapter.h b/include/keyple/plugin/stub/StubPluginAdapter.hpp similarity index 57% rename from src/main/StubPluginAdapter.h rename to include/keyple/plugin/stub/StubPluginAdapter.hpp index 37d7bb8..49afc7b 100644 --- a/src/main/StubPluginAdapter.h +++ b/include/keyple/plugin/stub/StubPluginAdapter.hpp @@ -1,14 +1,12 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #pragma once @@ -17,22 +15,22 @@ #include #include -/* Keyple Core Plugin */ -#include "ObservablePluginSpi.h" - -/* Keyple Plugin Stub */ -#include "KeyplePluginStubExport.h" -#include "StubPlugin.h" -#include "StubPluginFactoryAdapter.h" -#include "StubReaderAdapter.h" +#include "keyple/core/plugin/spi/ObservablePluginSpi.hpp" +#include "keyple/core/plugin/spi/reader/ReaderSpi.hpp" +#include "keyple/plugin/stub/KeyplePluginStubExport.hpp" +#include "keyple/plugin/stub/StubPlugin.hpp" +#include "keyple/plugin/stub/StubPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubReaderAdapter.hpp" namespace keyple { namespace plugin { namespace stub { -using StubReaderConfiguration = StubPluginFactoryAdapter::StubReaderConfiguration; +using StubReaderConfiguration + = StubPluginFactoryAdapter::StubReaderConfiguration; -using namespace keyple::core::plugin::spi; +using keyple::core::plugin::spi::ObservablePluginSpi; +using keyple::core::plugin::spi::reader::ReaderSpi; /** * (package-private)
@@ -40,19 +38,22 @@ using namespace keyple::core::plugin::spi; * * @since 2.0.0 */ -class KEYPLEPLUGINSTUB_API StubPluginAdapter : public StubPlugin, public ObservablePluginSpi { +class KEYPLEPLUGINSTUB_API StubPluginAdapter : public StubPlugin, + public ObservablePluginSpi { public: /** * (package-private )constructor * * @param name name of the plugin - * @param readerConfigurations configurations of the reader to plug initially + * @param readerConfigurations configurations of the reader to plug + * initially * @param monitoringCycleDuration duration between two monitoring cycles * @since 2.0.0 */ StubPluginAdapter( const std::string& name, - const std::vector>& readerConfigurations, + const std::vector>& + readerConfigurations, const int monitoringCycleDuration); /** @@ -71,10 +72,11 @@ class KEYPLEPLUGINSTUB_API StubPluginAdapter : public StubPlugin, public Observa /** * {@inheritDoc} - * + *@ * @since 2.0.0 */ - std::shared_ptr searchReader(const std::string& readerName) override; + std::shared_ptr + searchReader(const std::string& readerName) override; /** * {@inheritDoc} @@ -88,7 +90,8 @@ class KEYPLEPLUGINSTUB_API StubPluginAdapter : public StubPlugin, public Observa * * @since 2.0.0 */ - const std::vector> searchAvailableReaders() override; + const std::vector> + searchAvailableReaders() override; /** * {@inheritDoc} @@ -102,9 +105,10 @@ class KEYPLEPLUGINSTUB_API StubPluginAdapter : public StubPlugin, public Observa * * @since 2.0.0 */ - void plugReader(const std::string& name, - const bool isContactless, - std::shared_ptr card) override; + void plugReader( + const std::string& name, + const bool isContactless, + std::shared_ptr card) override; /** * {@inheritDoc} @@ -130,6 +134,6 @@ class KEYPLEPLUGINSTUB_API StubPluginAdapter : public StubPlugin, public Observa std::map> mStubReaders; }; -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/include/keyple/plugin/stub/StubPluginFactory.hpp b/include/keyple/plugin/stub/StubPluginFactory.hpp new file mode 100644 index 0000000..02a6460 --- /dev/null +++ b/include/keyple/plugin/stub/StubPluginFactory.hpp @@ -0,0 +1,39 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +/* Keyple Core Common */ +#include "keyple/core/common/KeyplePluginExtensionFactory.hpp" + +namespace keyple { +namespace plugin { +namespace stub { + +using keyple::core::common::KeyplePluginExtensionFactory; + +/** + * Stub specific {@link KeyplePluginExtensionFactory} to be provided to the + * Keyple SmartCard service to register the Stub plugin, built by {@link + * StubPluginFactoryBuilder}. + * + * @since 2.0.0 + */ +class StubPluginFactory : public KeyplePluginExtensionFactory { +public: + /** + * Virtual destructor. + */ + virtual ~StubPluginFactory() = default; +}; + +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPluginFactoryAdapter.h b/include/keyple/plugin/stub/StubPluginFactoryAdapter.hpp similarity index 67% rename from src/main/StubPluginFactoryAdapter.h rename to include/keyple/plugin/stub/StubPluginFactoryAdapter.hpp index 74f43fc..3496e1f 100644 --- a/src/main/StubPluginFactoryAdapter.h +++ b/include/keyple/plugin/stub/StubPluginFactoryAdapter.hpp @@ -1,30 +1,31 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #pragma once -/* Keyple Core Plugin */ -#include "PluginFactorySpi.h" +#include +#include +#include -/* Keyple Plugin Stub */ -#include "KeyplePluginStubExport.h" -#include "StubPluginFactory.h" -#include "StubSmartCard.h" +#include "keyple/core/plugin/spi/PluginFactorySpi.hpp" +#include "keyple/core/plugin/spi/PluginSpi.hpp" +#include "keyple/plugin/stub/KeyplePluginStubExport.hpp" +#include "keyple/plugin/stub/StubPluginFactory.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::plugin::spi; +using keyple::core::plugin::spi::PluginFactorySpi; +using keyple::core::plugin::spi::PluginSpi; /** * (package-private)
@@ -32,7 +33,9 @@ using namespace keyple::core::plugin::spi; * * @since 2.0.0 */ -class KEYPLEPLUGINSTUB_API StubPluginFactoryAdapter final : public StubPluginFactory, public PluginFactorySpi { +class KEYPLEPLUGINSTUB_API StubPluginFactoryAdapter final +: public StubPluginFactory, + public PluginFactorySpi { public: /** * (package-private) @@ -47,13 +50,15 @@ class KEYPLEPLUGINSTUB_API StubPluginFactoryAdapter final : public StubPluginFac * (package-private) constructor for a reader configuration * * @param name name of the reader (not nullable) - * @param isContactless true if the reader should be contactless (not nullable) + * @param isContactless true if the reader should be contactless (not + * nullable) * @param card inserted card (nullable) * @since 2.0.0 */ - StubReaderConfiguration(const std::string& name, - const bool isContactless, - std::shared_ptr card); + StubReaderConfiguration( + const std::string& name, + const bool isContactless, + std::shared_ptr card); /** * (package-private)
@@ -110,7 +115,8 @@ class KEYPLEPLUGINSTUB_API StubPluginFactoryAdapter final : public StubPluginFac */ StubPluginFactoryAdapter( const std::string& pluginName, - const std::vector> readerConfigurations, + const std::vector>& + readerConfigurations, const int monitoringCycleDuration); /** @@ -118,14 +124,14 @@ class KEYPLEPLUGINSTUB_API StubPluginFactoryAdapter final : public StubPluginFac * * @since 2.0.0 */ - const std::string& getPluginApiVersion() const override; + const std::string getPluginApiVersion() const override; /** * {@inheritDoc} * * @since 2.0.0 */ - const std::string& getCommonApiVersion() const override; + const std::string getCommonApiVersion() const override; /** * {@inheritDoc} @@ -158,6 +164,6 @@ class KEYPLEPLUGINSTUB_API StubPluginFactoryAdapter final : public StubPluginFac const std::string mPluginName; }; -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPluginFactoryBuilder.h b/include/keyple/plugin/stub/StubPluginFactoryBuilder.hpp similarity index 59% rename from src/main/StubPluginFactoryBuilder.h rename to include/keyple/plugin/stub/StubPluginFactoryBuilder.hpp index 39f235d..3f9a5d5 100644 --- a/src/main/StubPluginFactoryBuilder.h +++ b/include/keyple/plugin/stub/StubPluginFactoryBuilder.hpp @@ -1,28 +1,28 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #pragma once +#include #include +#include -/* Keyple Plugin Stub */ -#include "KeyplePluginStubExport.h" -#include "StubPluginFactoryAdapter.h" +#include "keyple/plugin/stub/KeyplePluginStubExport.hpp" +#include "keyple/plugin/stub/StubPluginFactoryAdapter.hpp" namespace keyple { namespace plugin { namespace stub { -using StubReaderConfiguration = StubPluginFactoryAdapter::StubReaderConfiguration; +using StubReaderConfiguration + = StubPluginFactoryAdapter::StubReaderConfiguration; /** * Builds instances of {@link StubPluginFactory}. @@ -51,21 +51,26 @@ class KEYPLEPLUGINSTUB_API StubPluginFactoryBuilder final { friend class StubPluginFactoryBuilder; /** - * Initialize the plugin with a stub reader. Multiple readers can be added. The reader can - * contain a smart card. Readers name should be unique. + * Initialize the plugin with a stub reader. Multiple readers can be + * added. The reader can contain a smart card. Readers name should be + * unique. * - * @param name name for the initially inserted reader (not nullable and unique) - * @param isContactLess true if the created reader should be contactless, false if not. + * @param name name for the initially inserted reader (not nullable and + * unique) + * @param isContactLess true if the created reader should be + * contactless, false if not. * @param card (optional) inserted smart card * @return instance of the builder * @since 2.0.0 */ - Builder& withStubReader(const std::string& name, - const bool isContactLess, - std::shared_ptr card); + Builder& withStubReader( + const std::string& name, + const bool isContactLess, + std::shared_ptr card); /** - * Configure the sleep time between two cycles for card and reader monitoring + * Configure the sleep time between two cycles for card and reader + * monitoring * * @param duration in milliseconds, default value : 0 * @return instance of the builder @@ -74,7 +79,8 @@ class KEYPLEPLUGINSTUB_API StubPluginFactoryBuilder final { Builder& withMonitoringCycleDuration(const int duration); /** - * Returns an instance of StubPluginFactory created from the fields set on this builder. + * Returns an instance of StubPluginFactory created from the fields set + * on this builder. * * @return A {@link StubPluginFactory} * @since 2.0.0 @@ -85,7 +91,8 @@ class KEYPLEPLUGINSTUB_API StubPluginFactoryBuilder final { /** * */ - std::vector> mReaderConfigurations; + std::vector> + mReaderConfigurations; /** * @@ -110,9 +117,11 @@ class KEYPLEPLUGINSTUB_API StubPluginFactoryBuilder final { /** * */ - StubPluginFactoryBuilder() {} + StubPluginFactoryBuilder() + { + } }; -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/include/keyple/plugin/stub/StubPoolPlugin.hpp b/include/keyple/plugin/stub/StubPoolPlugin.hpp new file mode 100644 index 0000000..89d4ee0 --- /dev/null +++ b/include/keyple/plugin/stub/StubPoolPlugin.hpp @@ -0,0 +1,68 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include +#include + +#include "keyple/core/common/KeyplePluginExtension.hpp" + +namespace keyple { +namespace plugin { +namespace stub { + +using keyple::core::common::KeyplePluginExtension; + +/** + * Simulates a keyple::core::plugin::spi::PoolPluginSpi with StubReader and + * StubSmartCard. Manages allocation readers by group reference. + */ +class StubPoolPlugin : public KeyplePluginExtension { +public: + /** + * Plug synchronously a new StubReader in the StubPoolPlugin associated to + * groupReference and a stub card. A READER_CONNECTED event will be raised. + * + * @param groupReference group reference of the new stub reader (mandatory) + * @param readerName name of the new stub reader (mandatory). Each reader + * should have a unique name, no matter to what groupReference they are + * associated to + * @param card insert a card at creation (can be null) + */ + virtual void plugPoolReader( + const std::string& groupReference, + const std::string& readerName, + std::shared_ptr card) + = 0; + + /** + * Unplug synchronously all readers associated to a groupReference. A + * READER_DISCONNECTED event will be raised. + * + * @param groupReference groupReference of the reader(s) to be unplugged + * (mandatory) + * @since 2.0.0 + */ + virtual void unplugPoolReaders(const std::string& groupReference) = 0; + + /** + * Unplug synchronously a pool reader. A READER_DISCONNECTED event will be + * raised. + * + * @param readerName name of the reader to be unplugged (mandatory) + * @since 2.0.0 + */ + virtual void unplugPoolReader(const std::string& readerName) = 0; +}; + +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPoolPluginAdapter.h b/include/keyple/plugin/stub/StubPoolPluginAdapter.hpp similarity index 57% rename from src/main/StubPoolPluginAdapter.h rename to include/keyple/plugin/stub/StubPoolPluginAdapter.hpp index d6b9d47..090cfd4 100644 --- a/src/main/StubPoolPluginAdapter.h +++ b/include/keyple/plugin/stub/StubPoolPluginAdapter.hpp @@ -1,14 +1,12 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #pragma once @@ -17,24 +15,24 @@ #include #include -/* Keyple Plugin Stub */ -#include "KeyplePluginStubExport.h" -#include "StubPluginAdapter.h" -#include "StubPoolPlugin.h" -#include "StubPoolPluginFactoryAdapter.h" -#include "StubSmartCard.h" - -/* Keyple Core Plugin */ -#include "ObservablePluginSpi.h" -#include "PoolPluginSpi.h" +#include "keyple/core/plugin/spi/ObservablePluginSpi.hpp" +#include "keyple/core/plugin/spi/PoolPluginSpi.hpp" +#include "keyple/core/plugin/spi/reader/PoolReaderSpi.hpp" +#include "keyple/plugin/stub/KeyplePluginStubExport.hpp" +#include "keyple/plugin/stub/StubPluginAdapter.hpp" +#include "keyple/plugin/stub/StubPoolPlugin.hpp" +#include "keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::plugin::spi; +using keyple::core::plugin::spi::PoolPluginSpi; +using keyple::core::plugin::spi::reader::PoolReaderSpi; -using StubPoolReaderConfiguration = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; +using StubPoolReaderConfiguration + = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; /** * (package-private)
@@ -42,20 +40,23 @@ using StubPoolReaderConfiguration = StubPoolPluginFactoryAdapter::StubPoolReader * * @since 2.0.0 */ -class KEYPLEPLUGINSTUB_API StubPoolPluginAdapter -: public StubPoolPlugin, public PoolPluginSpi, public ObservablePluginSpi { +class KEYPLEPLUGINSTUB_API StubPoolPluginAdapter : public StubPoolPlugin, + public PoolPluginSpi, + public ObservablePluginSpi { public: /** * (package-private )constructor * * @param name name of the plugin - * @param readerConfigurations configurations of the reader to plug initially + * @param readerConfigurations configurations of the reader to plug + * initially * @param monitoringCycleDuration duration between two monitoring cycle * @since 2.0.0 */ StubPoolPluginAdapter( const std::string& name, - const std::vector>& readerConfigurations, + const std::vector>& + readerConfigurations, const int monitoringCycleDuration); /** @@ -70,7 +71,8 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginAdapter * * @since 2.0.0 */ - const std::vector> searchAvailableReaders() override; + const std::vector> + searchAvailableReaders() override; /** * {@inheritDoc} @@ -84,7 +86,8 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginAdapter * * @since 2.0.0 */ - std::shared_ptr allocateReader(const std::string& readerGroupReference) override; + std::shared_ptr + allocateReader(const std::string& readerGroupReference) override; /** * {@inheritDoc} @@ -105,9 +108,10 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginAdapter * * @since 2.0.0 */ - void plugPoolReader(const std::string& groupReference, - const std::string& readerName, - std::shared_ptr card) override; + void plugPoolReader( + const std::string& groupReference, + const std::string& readerName, + std::shared_ptr card) override; /** * {@inheritDoc} @@ -128,7 +132,7 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginAdapter * * @since 2.0.0 */ - int getMonitoringCycleDuration() const override; + int getMonitoringCycleDuration() const override; /** * {@inheritDoc} @@ -142,7 +146,8 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginAdapter * * @since 2.0.0 */ - std::shared_ptr searchReader(const std::string& readerName) override; + std::shared_ptr + searchReader(const std::string& readerName) override; private: /** @@ -166,9 +171,10 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginAdapter * @param aGroupReference not nullable reference to a group reference * @return collection of reader names */ - const std::vector listReadersByGroup(const std::string& aGroupReference); + const std::vector + listReadersByGroup(const std::string& aGroupReference); }; -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/include/keyple/plugin/stub/StubPoolPluginFactory.hpp b/include/keyple/plugin/stub/StubPoolPluginFactory.hpp new file mode 100644 index 0000000..25eb00b --- /dev/null +++ b/include/keyple/plugin/stub/StubPoolPluginFactory.hpp @@ -0,0 +1,32 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include "keyple/core/common/KeyplePluginExtensionFactory.hpp" + +namespace keyple { +namespace plugin { +namespace stub { + +using keyple::core::common::KeyplePluginExtensionFactory; + +/** + * Stub specific KeyplePluginExtensionFactory to be provided to the Keyple + * SmartCard service to register the Stub Pool plugin, built by + * StubPoolPluginFactoryBuilder. + * + * @since 2.0.0 + */ +class StubPoolPluginFactory : public KeyplePluginExtensionFactory { }; + +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPoolPluginFactoryAdapter.h b/include/keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp similarity index 56% rename from src/main/StubPoolPluginFactoryAdapter.h rename to include/keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp index 95956ac..d26966e 100644 --- a/src/main/StubPoolPluginFactoryAdapter.h +++ b/include/keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp @@ -1,36 +1,36 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #pragma once +#include #include +#include -/* Keyple Plugin Stub */ -#include "KeyplePluginStubExport.h" -#include "StubPluginFactoryAdapter.h" -#include "StubPoolPluginFactory.h" -#include "StubPoolPluginFactoryAdapter.h" -#include "StubSmartCard.h" - -/* Keyple Core Plugin */ -#include "PoolPluginFactorySpi.h" +#include "keyple/core/plugin/spi/PoolPluginFactorySpi.hpp" +#include "keyple/core/plugin/spi/PoolPluginSpi.hpp" +#include "keyple/plugin/stub/KeyplePluginStubExport.hpp" +#include "keyple/plugin/stub/StubPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubPoolPluginFactory.hpp" +#include "keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::plugin::spi; +using keyple::core::plugin::spi::PoolPluginFactorySpi; +using keyple::core::plugin::spi::PoolPluginSpi; -using StubReaderConfiguration = StubPluginFactoryAdapter::StubReaderConfiguration; +using StubReaderConfiguration + = StubPluginFactoryAdapter::StubReaderConfiguration; /** * (package-private)
* Factory of {@link StubPoolPlugin}. @@ -38,12 +38,14 @@ using StubReaderConfiguration = StubPluginFactoryAdapter::StubReaderConfiguratio * @since 2.0.0 */ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryAdapter final -: public StubPoolPluginFactory, public PoolPluginFactorySpi { +: public StubPoolPluginFactory, + public PoolPluginFactorySpi { public: /** * */ - class KEYPLEPLUGINSTUB_API StubPoolReaderConfiguration : public StubReaderConfiguration { + class KEYPLEPLUGINSTUB_API StubPoolReaderConfiguration + : public StubReaderConfiguration { public: /** * (package-private) constructor for a reader configuration @@ -53,9 +55,10 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryAdapter final * @param card inserted card (nullable) * @since 2.0.0 */ - StubPoolReaderConfiguration(const std::string& groupReference, - const std::string& name, - std::shared_ptr card); + StubPoolReaderConfiguration( + const std::string& groupReference, + const std::string& name, + std::shared_ptr card); /** * @@ -67,7 +70,6 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryAdapter final * */ const std::string mGroupReference; - }; /** @@ -81,7 +83,8 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryAdapter final */ StubPoolPluginFactoryAdapter( const std::string& pluginName, - const std::vector>& readerConfigurations, + const std::vector>& + readerConfigurations, const int monitoringCycleDuration); /** @@ -89,14 +92,14 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryAdapter final * * @since 2.0.0 */ - const std::string& getPluginApiVersion() const override; + const std::string getPluginApiVersion() const override; /** * {@inheritDoc} * * @since 2.0.0 */ - const std::string& getCommonApiVersion() const override; + const std::string getCommonApiVersion() const override; /** * {@inheritDoc} @@ -116,7 +119,8 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryAdapter final /** * */ - const std::vector> mReaderConfigurations; + const std::vector> + mReaderConfigurations; /** * @@ -127,9 +131,8 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryAdapter final * */ const std::string mPluginName; - }; -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPoolPluginFactoryBuilder.h b/include/keyple/plugin/stub/StubPoolPluginFactoryBuilder.hpp similarity index 63% rename from src/main/StubPoolPluginFactoryBuilder.h rename to include/keyple/plugin/stub/StubPoolPluginFactoryBuilder.hpp index 9bc37df..e9a05ec 100644 --- a/src/main/StubPoolPluginFactoryBuilder.h +++ b/include/keyple/plugin/stub/StubPoolPluginFactoryBuilder.hpp @@ -1,14 +1,12 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #pragma once @@ -17,16 +15,17 @@ #include /* Keyple Plugin Stub */ -#include "KeyplePluginStubExport.h" -#include "StubPoolPluginFactory.h" -#include "StubPoolPluginFactoryAdapter.h" -#include "StubSmartCard.h" +#include "keyple/plugin/stub/KeyplePluginStubExport.hpp" +#include "keyple/plugin/stub/StubPoolPluginFactory.hpp" +#include "keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" namespace keyple { namespace plugin { namespace stub { -using StubPoolReaderConfiguration = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; +using StubPoolReaderConfiguration + = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; /** * Builds instances of StubPoolPluginFactory. @@ -48,21 +47,25 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryBuilder final { friend class StubPoolPluginFactoryBuilder; /** - * Initialize the plugin with a stub reader. Multiple readers can be added. The reader can - * contain a smart card. Readers name should be unique. + * Initialize the plugin with a stub reader. Multiple readers can be + * added. The reader can contain a smart card. Readers name should be + * unique. * * @param groupReference Reader group reference. - * @param name name for the initially inserted reader (not nullable and unique) + * @param name name for the initially inserted reader (not nullable and + * unique) * @param card (optional) inserted smart card * @return instance of the builder * @since 2.0.0 */ - Builder& withStubReader(const std::string& groupReference, - const std::string& name, - std::shared_ptr card); + Builder& withStubReader( + const std::string& groupReference, + const std::string& name, + std::shared_ptr card); /** - * Configure the sleep time between two cycles for card and reader monitoring + * Configure the sleep time between two cycles for card and reader + * monitoring * * @param duration in milliseconds, default value : 0 * @return instance of the builder @@ -71,7 +74,8 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryBuilder final { Builder& withMonitoringCycleDuration(const int duration); /** - * Returns an instance of StubPoolPluginFactory created from the fields set on this builder. + * Returns an instance of StubPoolPluginFactory created from the fields + * set on this builder. * * @return A {@link StubPoolPluginFactory} * @since 2.0.0 @@ -82,7 +86,8 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryBuilder final { /** * */ - std::vector> mReaderConfigurations; + std::vector> + mReaderConfigurations; /** * @@ -107,7 +112,6 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryBuilder final { */ static const std::string PLUGIN_NAME; - /** * Creates builder to build a {@link StubPoolPluginFactory}. * @@ -123,6 +127,6 @@ class KEYPLEPLUGINSTUB_API StubPoolPluginFactoryBuilder final { StubPoolPluginFactoryBuilder(); }; -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/include/keyple/plugin/stub/StubReader.hpp b/include/keyple/plugin/stub/StubReader.hpp new file mode 100644 index 0000000..5e19602 --- /dev/null +++ b/include/keyple/plugin/stub/StubReader.hpp @@ -0,0 +1,64 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include +#include + +#include "keyple/core/common/KeypleReaderExtension.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" + +namespace keyple { +namespace plugin { +namespace stub { + +using keyple::core::common::KeypleReaderExtension; + +/** + * The Stub Reader supports programmatically the insertion and removal of {@link + * StubSmartCard}
To invoke those methods use + * Reader#getExtension(StubReader.class) from the Reader class. + * + * @since 2.0.0 + */ +class StubReader : public KeypleReaderExtension { +public: + /** + * Insert a stub card into the reader. The card is taken into account by the + * reader only if its protocol has been activated previously by the method + * keyple::core::plugin::spi::reader::ConfigurableReaderSpi::activateProtocol(). + * In such case it raises a CARD_INSERTED event. + * + * @param smartCard stub card to be inserted in the reader (not nullable) + * @since 2.0.0 + */ + virtual void insertCard(std::shared_ptr smartCard) = 0; + + /** + * Remove card from reader if any + * + * @since 2.0.0 + */ + virtual void removeCard() = 0; + + /** + * Get inserted card + * + * @return instance of a {@link StubSmartCard}, can be null if no card + * inserted + * @since 2.0.0 + */ + virtual std::shared_ptr getSmartcard() = 0; +}; + +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubReaderAdapter.h b/include/keyple/plugin/stub/StubReaderAdapter.hpp similarity index 57% rename from src/main/StubReaderAdapter.h rename to include/keyple/plugin/stub/StubReaderAdapter.hpp index b6c335a..e8e432f 100644 --- a/src/main/StubReaderAdapter.h +++ b/include/keyple/plugin/stub/StubReaderAdapter.hpp @@ -1,14 +1,12 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #pragma once @@ -17,31 +15,31 @@ #include #include -/* Keyple Core Util */ -#include "LoggerFactory.h" - -/* Keyple Core Plugin */ -#include "ConfigurableReaderSpi.h" -#include "ObservableReaderSpi.h" -#include "WaitForCardInsertionNonBlockingSpi.h" -#include "WaitForCardRemovalDuringProcessingBlockingSpi.h" -#include "WaitForCardRemovalNonBlockingSpi.h" - -/* Keyple Plugin Stub */ -#include "KeyplePluginStubExport.h" -#include "StubReader.h" -#include "StubSmartCard.h" +#include "keyple/core/plugin/spi/reader/ConfigurableReaderSpi.hpp" +#include "keyple/core/plugin/spi/reader/PoolReaderSpi.hpp" +#include "keyple/core/plugin/spi/reader/observable/ObservableReaderSpi.hpp" +#include "keyple/core/plugin/spi/reader/observable/state/insertion/CardInsertionWaiterNonBlockingSpi.hpp" +#include "keyple/core/plugin/spi/reader/observable/state/removal/CardRemovalWaiterNonBlockingSpi.hpp" +#include "keyple/core/util/cpp/Any.hpp" +#include "keyple/core/util/cpp/LoggerFactory.hpp" +#include "keyple/plugin/stub/KeyplePluginStubExport.hpp" +#include "keyple/plugin/stub/StubReader.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::plugin::spi::reader; -using namespace keyple::core::plugin::spi::reader::observable; -using namespace keyple::core::plugin::spi::reader::observable::state::insertion; -using namespace keyple::core::plugin::spi::reader::observable::state::processing; -using namespace keyple::core::plugin::spi::reader::observable::state::removal; -using namespace keyple::core::util::cpp; +using keyple::core::plugin::spi::reader::ConfigurableReaderSpi; +using keyple::core::plugin::spi::reader::PoolReaderSpi; +using keyple::core::plugin::spi::reader::observable::ObservableReaderSpi; +using keyple::core::plugin::spi::reader::observable::state::insertion:: + CardInsertionWaiterNonBlockingSpi; +using keyple::core::plugin::spi::reader::observable::state::removal:: + CardRemovalWaiterNonBlockingSpi; +using keyple::core::util::cpp::any; +using keyple::core::util::cpp::Logger; +using keyple::core::util::cpp::LoggerFactory; /** * (package-private)
@@ -52,10 +50,10 @@ using namespace keyple::core::util::cpp; class KEYPLEPLUGINSTUB_API StubReaderAdapter final : public StubReader, public ConfigurableReaderSpi, + public PoolReaderSpi, public ObservableReaderSpi, - public WaitForCardInsertionNonBlockingSpi, - public WaitForCardRemovalDuringProcessingBlockingSpi, - public WaitForCardRemovalNonBlockingSpi { + public CardInsertionWaiterNonBlockingSpi, + public CardRemovalWaiterNonBlockingSpi { public: /** * (package-private)
@@ -66,13 +64,14 @@ class KEYPLEPLUGINSTUB_API StubReaderAdapter final * @param card (optional) inserted smart card at creation * @since 2.0.0 */ - StubReaderAdapter(const std::string& name, - const bool isContactLess, - std::shared_ptr card); + StubReaderAdapter( + const std::string& name, + const bool isContactLess, + std::shared_ptr card); /* - * ObservableReaderSpi - */ + * ObservableReaderSpi + */ /** * {@inheritDoc} @@ -163,7 +162,8 @@ class KEYPLEPLUGINSTUB_API StubReaderAdapter final * * @since 2.0.0 */ - const std::vector transmitApdu(const std::vector& apduIn) override; + const std::vector + transmitApdu(const std::vector& apduIn) override; /** * {@inheritDoc} @@ -180,8 +180,8 @@ class KEYPLEPLUGINSTUB_API StubReaderAdapter final void onUnregister() override; /* - * StubReader - */ + * StubReader + */ /** * {@inheritDoc} @@ -202,27 +202,35 @@ class KEYPLEPLUGINSTUB_API StubReaderAdapter final * * @since 2.0.0 */ - std::shared_ptr getSmartcard() override ; + std::shared_ptr getSmartcard() override; /** * {@inheritDoc} * - * @since 2.0.0 + * @since 2.2.0 */ - void waitForCardRemovalDuringProcessing() override; + std::shared_ptr getSelectedSmartCard() const override; /** * {@inheritDoc} * - * @since 2.0.0 + * @since 2.2.0 + */ + int getCardInsertionMonitoringSleepDuration() const override; + + /** + * {@inheritDoc} + * + * @since 2.2.0 */ - void stopWaitForCardRemovalDuringProcessing() override; + int getCardRemovalMonitoringSleepDuration() const override; private: /** * */ - const std::unique_ptr mLogger = LoggerFactory::getLogger(typeid(StubReaderAdapter)); + const std::unique_ptr mLogger + = LoggerFactory::getLogger(typeid(StubReaderAdapter)); /** * @@ -250,6 +258,6 @@ class KEYPLEPLUGINSTUB_API StubReaderAdapter final std::atomic mContinueWaitForCardRemovalTask; }; -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubSmartCard.h b/include/keyple/plugin/stub/StubSmartCard.hpp similarity index 70% rename from src/main/StubSmartCard.h rename to include/keyple/plugin/stub/StubSmartCard.hpp index 6596e09..872bd62 100644 --- a/src/main/StubSmartCard.h +++ b/include/keyple/plugin/stub/StubSmartCard.hpp @@ -1,14 +1,12 @@ -/************************************************************************************************** - * Copyright (c) 2022 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #pragma once @@ -18,37 +16,44 @@ #include #include -/* Keyple Plugin Stub */ -#include "ApduResponseProviderSpi.h" -#include "KeyplePluginStubExport.h" +#include "keyple/plugin/stub/KeyplePluginStubExport.hpp" +#include "keyple/plugin/stub/spi/ApduResponseProviderSpi.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::plugin::stub::spi; +using keyple::plugin::stub::spi::ApduResponseProviderSpi; /** - * Simulated smart card that can be inserted into a {@link StubReader}. Use the {@link Builder} to - * create this object + * Simulated smart card that can be inserted into a {@link StubReader}. Use the + * {@link Builder} to create this object * * @since 2.0.0 */ class KEYPLEPLUGINSTUB_API StubSmartCard { public: + /** + * Provides methods to add simulated commands and responses to a + * StubSmartCard builder. + * + * @since 2.1.0 + */ class SimulatedCommandStep { public: /** * Add simulated command/response to the StubSmartCard to build. Command and response * should be hexadecimal. * - * @param command hexadecimal command to respond to (can be a regexp to match multiple apdu) + * @param command hexadecimal command to respond to (can be a regexp to + * match multiple apdu) * @param response hexadecimal response * @return next step of builder * @since 2.1.0 */ - virtual SimulatedCommandStep& withSimulatedCommand(const std::string& command, - const std::string& response) = 0; + virtual SimulatedCommandStep& withSimulatedCommand( + const std::string& command, const std::string& response) + = 0; /** * Build the StubSmartCard @@ -58,6 +63,11 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { virtual std::shared_ptr build() = 0; }; + /** + * Build step for creating a {@link StubSmartCard} instance. + * + * @since 2.1.0 + */ class BuildStep { public: /** @@ -69,31 +79,40 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { virtual std::shared_ptr build() = 0; }; + /** + * CommandStep interface provides methods to build and configure a + * StubSmartCard object. + * + * @since 2.0.0 + */ class CommandStep { public: /** * Add simulated command/response to the StubSmartCard to build. Command and * response should be hexadecimal. * - * @param command hexadecimal command to respond to (can be a regexp to match multiple apdu) + * @param command hexadecimal command to respond to (can be a regexp to + * match multiple apdu) * @param response hexadecimal response * @return next step of builder * @since 2.0.0 */ - virtual SimulatedCommandStep& withSimulatedCommand(const std::string& command, - const std::string& response) = 0; + virtual SimulatedCommandStep& withSimulatedCommand( + const std::string& command, const std::string& response) + = 0; /** * Provide simulated command/response to the StubSmartCard using a custom provider * implementing of ApduResponseProviderSpi. * - * @param apduResponseProvider hexadecimal command to respond to (can be a regexp to match - * multiple apdu) + * @param apduResponseProvider hexadecimal command to respond to (can be + * a regexp to match multiple apdu) * @return next step of builder * @since 2.1.0 */ virtual BuildStep& withApduResponseProvider( - const std::shared_ptr apduResponseProvider) = 0; + const std::shared_ptr apduResponseProvider) + = 0; /** * Build the StubSmartCard @@ -103,6 +122,12 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { virtual std::shared_ptr build() = 0; }; + /** + * Provides a method to define the simulated protocol for the StubSmartCard + * to build. + * + * @since 2.0.0 + */ class ProtocolStep { public: /** @@ -115,6 +140,12 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { virtual CommandStep& withProtocol(const std::string& protocol) = 0; }; + /** + * Provides a method for defining simulated power-on data for the + * StubSmartCard to build. + * + * @since 2.0.0 + */ class PowerOnDataStep { public: /** @@ -129,7 +160,9 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { * @return next step of builder * @since 2.0.0 */ - virtual ProtocolStep& withPowerOnData(const std::vector& powerOnData) = 0; + virtual ProtocolStep& + withPowerOnData(const std::vector& powerOnData) + = 0; }; /** @@ -137,12 +170,11 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { * * @since 2.0.0 */ - class Builder - : public PowerOnDataStep, - public ProtocolStep, - public CommandStep, - public BuildStep, - public SimulatedCommandStep { + class Builder : public PowerOnDataStep, + public ProtocolStep, + public CommandStep, + public BuildStep, + public SimulatedCommandStep { public: /** * @@ -154,8 +186,8 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { * * @since 2.0.0 */ - SimulatedCommandStep& withSimulatedCommand(const std::string& command, - const std::string& response) override; + SimulatedCommandStep& withSimulatedCommand( + const std::string& command, const std::string& response) override; /** * {@inheritDoc} @@ -169,7 +201,8 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { * * @since 2.0.0 */ - ProtocolStep& withPowerOnData(const std::vector& powerOnData) override; + ProtocolStep& + withPowerOnData(const std::vector& powerOnData) override; /** * {@inheritDoc} @@ -184,7 +217,8 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { * @since 2.1.0 */ BuildStep& withApduResponseProvider( - const std::shared_ptr apduResponseProvider) override; + const std::shared_ptr apduResponseProvider) + override; private: /** @@ -276,7 +310,8 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { * * @since 2.0.0 */ - friend std::ostream& operator<<(std::ostream& os, const std::shared_ptr ssc); + friend std::ostream& + operator<<(std::ostream& os, const std::shared_ptr ssc); /** * Creates a builder for the {@link StubSmartCard} @@ -314,22 +349,25 @@ class KEYPLEPLUGINSTUB_API StubSmartCard { /** * (private)
- * Create a simulated smart card with mandatory parameters The response APDU can be provided + * Create a simulated smart card with mandatory parameters The response APDU + * can be provided * using apduResponseProvider if it is not null or hexCommands by * default. * * @param powerOnData (non nullable) power-on data of the card * @param cardProtocol (non nullable) card protocol * @param hexCommands (non nullable) set of simulated commands - * @param apduResponseProvider (nullable) an external provider of simulated commands + * @param apduResponseProvider (nullable) an external provider of simulated + * commands * @since 2.0.0 */ - StubSmartCard(const std::vector& powerOnData, - const std::string& cardProtocol, - const std::map& hexCommands, - const std::shared_ptr apduResponseProvider); + StubSmartCard( + const std::vector& powerOnData, + const std::string& cardProtocol, + const std::map& hexCommands, + const std::shared_ptr apduResponseProvider); }; -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/include/keyple/plugin/stub/spi/ApduResponseProviderSpi.hpp b/include/keyple/plugin/stub/spi/ApduResponseProviderSpi.hpp new file mode 100644 index 0000000..8478a07 --- /dev/null +++ b/include/keyple/plugin/stub/spi/ApduResponseProviderSpi.hpp @@ -0,0 +1,49 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include + +namespace keyple { +namespace plugin { +namespace stub { +namespace spi { + +/** + * This interface must be used to provide an APDU response according to an APDU + * request. It is used by StubSmartCard} to delegate it APDU response providing + * to another class. + * + * @since 2.1.0 + */ +class ApduResponseProviderSpi { +public: + /** + * + */ + virtual ~ApduResponseProviderSpi() = default; + + /** + * Provide APDU responses according to an APDU request. + * + * @param apduRequest hexadecimal string format (without spaces) + * @return the APDU response in hexadecimal string format (without spaces) + * @since 2.1.0 + */ + virtual const std::string + getResponseFromRequest(const std::string& apduRequest) + = 0; +}; + +} /* namespace spi */ +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt old mode 100644 new mode 100755 index 5a68cdf..8f95afb --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,4 +12,4 @@ # Add projects add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/main) -#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test) diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index f67440b..35f9a7e 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -1,20 +1,25 @@ -#/************************************************************************************************* -# * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * -# * * -# * See the NOTICE file(s) distributed with this work for additional information regarding * -# * copyright ownership. * -# * * -# * This program and the accompanying materials are made available under the terms of the Eclipse * -# * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * -# * * -# * SPDX-License-Identifier: EPL-2.0 * -# *************************************************************************************************/ +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ SET(LIBRARY_NAME keyplepluginstubcpplib) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKEYPLEPLUGINSTUB_EXPORT") +# Include deps +INCLUDE("CMakeLists.txt.keyple-common") +INCLUDE("CMakeLists.txt.keyple-plugin") +INCLUDE("CMakeLists.txt.keyple-util") +INCLUDE("CMakeLists.txt.keypop-reader") + ADD_LIBRARY( + ${LIBRARY_NAME} ${LIBRARY_TYPE} @@ -30,16 +35,14 @@ ADD_LIBRARY( ) TARGET_INCLUDE_DIRECTORIES( + ${LIBRARY_NAME} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - spi + $ ) -# Careful, link order matters here as there are includes with the same name, and we cannot -# discriminate based on path TARGET_LINK_LIBRARIES( ${LIBRARY_NAME} @@ -47,8 +50,16 @@ TARGET_LINK_LIBRARIES( PUBLIC Keyple::Util - Keyple::CommonApi - Keyple::PluginApi + Keyple::Common + Keyple::Plugin + Keypop::Reader ) -ADD_LIBRARY(Keyple::PluginStub ALIAS ${LIBRARY_NAME}) +ADD_LIBRARY( + + Keyple::Plugin::Stub + + ALIAS + + ${LIBRARY_NAME} +) diff --git a/src/main/CMakeLists.txt.keyple-common b/src/main/CMakeLists.txt.keyple-common new file mode 100644 index 0000000..f94a45b --- /dev/null +++ b/src/main/CMakeLists.txt.keyple-common @@ -0,0 +1,40 @@ +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/keyplecommoncppapi-src") + + MESSAGE("-- > Fetching keyple common from keyple plugin stub") + + # Checkout Keyple Plugin Cpp Api dependency + FetchContent_Declare( + + KeypleCommonCppApi + + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/eclipse-keyple/keyple-common-cpp-api + GIT_TAG develop-2.0.2 + ) + +ELSE() + + FetchContent_Declare( + + KeypleCommonCppApi + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/keyplecommoncppapi-src + ) + +ENDIF() + +FetchContent_MakeAvailable(KeypleCommonCppApi) diff --git a/src/main/CMakeLists.txt.keyple-plugin b/src/main/CMakeLists.txt.keyple-plugin new file mode 100644 index 0000000..8c029b3 --- /dev/null +++ b/src/main/CMakeLists.txt.keyple-plugin @@ -0,0 +1,40 @@ +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/keypleplugincppapi-src") + + MESSAGE("-- > Fetching keyple plugin from keyple plugin stub") + + # Checkout Keyple Plugin Cpp Api dependency + FetchContent_Declare( + + KeyplePluginCppApi + + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/eclipse-keyple/keyple-plugin-cpp-api + GIT_TAG develop-2.3.2 + ) + +ELSE() + + FetchContent_Declare( + + KeyplePluginCppApi + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/keypleplugincppapi-src + ) + +ENDIF() + +FetchContent_MakeAvailable(KeyplePluginCppApi) diff --git a/src/main/CMakeLists.txt.keyple-util b/src/main/CMakeLists.txt.keyple-util new file mode 100644 index 0000000..bf31cd4 --- /dev/null +++ b/src/main/CMakeLists.txt.keyple-util @@ -0,0 +1,47 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/keypleutilcpplib-src") + + MESSAGE("-- > Fetching keyple util from keyple service") + + # FetchContent added in CMake 3.11, downloads during the configure step + # FetchContent_MakeAvailable was added in CMake 3.14; simpler usage + INCLUDE(FetchContent) + + # Checkout Keyple Util Cpp Lib dependency + FetchContent_Declare( + + KeypleUtilCppLib + + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/eclipse-keyple/keyple-util-cpp-lib + GIT_TAG develop-2.4.0 + ) + +ELSE() + + FetchContent_Declare( + + KeypleUtilCppLib + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/keypleutilcpplib-src + ) + +ENDIF() + +FetchContent_MakeAvailable(KeypleUtilCppLib) diff --git a/src/main/CMakeLists.txt.keypop-reader b/src/main/CMakeLists.txt.keypop-reader new file mode 100644 index 0000000..16f4604 --- /dev/null +++ b/src/main/CMakeLists.txt.keypop-reader @@ -0,0 +1,40 @@ +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/keypopreadercppapi-src") + + MESSAGE("-- > Fetching keypop reader from keyple plugin stub") + + # Checkout Keypop Reader Cpp Api dependency + FetchContent_Declare( + + KeypopReaderCppApi + + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/eclipse-keypop/keypop-reader-cpp-api + GIT_TAG 2.1.0 + ) + +ELSE() + + FetchContent_Declare( + + KeypopReaderCppApi + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/keypopreadercppapi-src + ) + +ENDIF() + +FetchContent_MakeAvailable(KeypopReaderCppApi) diff --git a/src/main/KeyplePluginStubExport.h b/src/main/KeyplePluginStubExport.h deleted file mode 100644 index 1f2a900..0000000 --- a/src/main/KeyplePluginStubExport.h +++ /dev/null @@ -1,23 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#if defined(WIN32) -#if defined(KEYPLEPLUGINSTUB_EXPORT) -#define KEYPLEPLUGINSTUB_API __declspec(dllexport) -#else -#define KEYPLEPLUGINSTUB_API __declspec(dllimport) -#endif -#else -#define KEYPLEPLUGINSTUB_API -#endif \ No newline at end of file diff --git a/src/main/StubPlugin.h b/src/main/StubPlugin.h deleted file mode 100644 index 7a22a52..0000000 --- a/src/main/StubPlugin.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include -#include - -/* Keyple Core Common */ -#include "KeyplePluginExtension.h" - -/* Keyple Plugin Stub */ -#include "StubSmartCard.h" - -namespace keyple { -namespace plugin { -namespace stub { - -using namespace keyple::core::common; - -/** - * Specific methods of the Stub Plugin. Implemented as a {@link KeyplePluginExtension}. To invoke - * those methods use Plugin#getExtension(StubPlugin.class) from the Plugin class. - * - * @since 2.0.0 - */ -class StubPlugin : public KeyplePluginExtension { -public: - /** - * Plug a new {@link StubReader}. This operation is asynchronous and will raise a - * READER_CONNECTED event. A new {@link StubReader} is created and make available in the plugin - * - * @param name name for the reader (not nullable and unique) - * @param isContactless true if the created reader should be contactless, false if not. - * @param card created reader can contain a card (nullable) - * @since 2.0.0 - */ - virtual void plugReader(const std::string& name, - const bool isContactless, - std::shared_ptr card) = 0; - - /** - * Unplug a {@link StubReader}. This operation is asynchronous and will raise a - * READER_DISCONNECTED event. The reader is removed from the * available list of reader. It does - * nothing if no reader matches the name. - * - * @param name the name of the reader to unplug (not nullable) - * @since 2.0.0 - */ - virtual void unplugReader(const std::string& name) = 0; -}; - -} -} -} diff --git a/src/main/StubPluginAdapter.cpp b/src/main/StubPluginAdapter.cpp index 283f399..9b4b67d 100644 --- a/src/main/StubPluginAdapter.cpp +++ b/src/main/StubPluginAdapter.cpp @@ -1,40 +1,43 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ -#include "StubPluginAdapter.h" +#include "keyple/plugin/stub/StubPluginAdapter.hpp" namespace keyple { namespace plugin { namespace stub { StubPluginAdapter::StubPluginAdapter( - const std::string& name, - const std::vector>& readerConfigurations, - const int monitoringCycleDuration) -: mName(name), mMonitoringCycleDuration(monitoringCycleDuration) + const std::string& name, + const std::vector>& + readerConfigurations, + const int monitoringCycleDuration) +: mName(name) +, mMonitoringCycleDuration(monitoringCycleDuration) { for (const auto& configuration : readerConfigurations) { - plugReader(configuration->getName(), - configuration->getContactless(), - configuration->getCard()); + plugReader( + configuration->getName(), + configuration->getContactless(), + configuration->getCard()); } } -int StubPluginAdapter::getMonitoringCycleDuration() const +int +StubPluginAdapter::getMonitoringCycleDuration() const { return mMonitoringCycleDuration; } -const std::vector StubPluginAdapter::searchAvailableReaderNames() +const std::vector +StubPluginAdapter::searchAvailableReaderNames() { std::vector readers; for (const auto& reader : mStubReaders) { @@ -44,7 +47,8 @@ const std::vector StubPluginAdapter::searchAvailableReaderNames() return readers; } -std::shared_ptr StubPluginAdapter::searchReader(const std::string& readerName) +std::shared_ptr +StubPluginAdapter::searchReader(const std::string& readerName) { const auto it = mStubReaders.find(readerName); if (it != mStubReaders.end()) { @@ -54,12 +58,14 @@ std::shared_ptr StubPluginAdapter::searchReader(const std::string& re return nullptr; } -const std::string& StubPluginAdapter::getName() const +const std::string& +StubPluginAdapter::getName() const { return mName; } -const std::vector> StubPluginAdapter::searchAvailableReaders() +const std::vector> +StubPluginAdapter::searchAvailableReaders() { std::vector> readers; for (const auto& reader : mStubReaders) { @@ -69,23 +75,28 @@ const std::vector> StubPluginAdapter::searchAvailable return readers; } -void StubPluginAdapter::onUnregister() +void +StubPluginAdapter::onUnregister() { /* NO-OP */ } -void StubPluginAdapter::plugReader(const std::string& name, - const bool isContactless, - std::shared_ptr card) +void +StubPluginAdapter::plugReader( + const std::string& name, + const bool isContactless, + std::shared_ptr card) { - mStubReaders.insert({name, std::make_shared(name, isContactless, card)}); + mStubReaders.insert( + {name, std::make_shared(name, isContactless, card)}); } -void StubPluginAdapter::unplugReader(const std::string& name) +void +StubPluginAdapter::unplugReader(const std::string& name) { mStubReaders.erase(name); } -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPluginFactory.h b/src/main/StubPluginFactory.h deleted file mode 100644 index a4b71ba..0000000 --- a/src/main/StubPluginFactory.h +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -/* Keyple Core Common */ -#include "KeyplePluginExtensionFactory.h" - -namespace keyple { -namespace plugin { -namespace stub { - -using namespace keyple::core::common; - -/** - * Stub specific {@link KeyplePluginExtensionFactory} to be provided to the Keyple SmartCard service - * to register the Stub plugin, built by {@link StubPluginFactoryBuilder}. - * - * @since 2.0.0 - */ -class StubPluginFactory : public KeyplePluginExtensionFactory {}; - -} -} -} diff --git a/src/main/StubPluginFactoryAdapter.cpp b/src/main/StubPluginFactoryAdapter.cpp index 66fe1e0..81cc31d 100644 --- a/src/main/StubPluginFactoryAdapter.cpp +++ b/src/main/StubPluginFactoryAdapter.cpp @@ -1,86 +1,96 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "StubPluginFactoryAdapter.h" - -/* Keyple Core Plugin */ -#include "PluginApiProperties.h" - -/* Keyple Core Common */ -#include "CommonApiProperties.h" - -/* Keyple Plugin Stub */ -#include "StubPluginAdapter.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include "keyple/plugin/stub/StubPluginFactoryAdapter.hpp" + +#include "keyple/core/common/CommonApiProperties.hpp" +#include "keyple/core/plugin/PluginApiProperties.hpp" +#include "keyple/plugin/stub/StubPluginAdapter.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::common; -using namespace keyple::core::plugin; +using keyple::core::common::CommonApiProperties_VERSION; +using keyple::core::plugin::PluginApiProperties_VERSION; -/* STUB READER CONFIGURATION -------------------------------------------------------------------- */ +/* STUB READER CONFIGURATION + * -------------------------------------------------------------------- */ StubPluginFactoryAdapter::StubReaderConfiguration::StubReaderConfiguration( - const std::string& name, const bool isContactless, std::shared_ptr card) -: mName(name), mIsContactless(isContactless), mCard(card) {} + const std::string& name, + const bool isContactless, + std::shared_ptr card) +: mName(name) +, mIsContactless(isContactless) +, mCard(card) +{ +} -const std::string& StubPluginFactoryAdapter::StubReaderConfiguration::getName() const +const std::string& +StubPluginFactoryAdapter::StubReaderConfiguration::getName() const { return mName; } -bool StubPluginFactoryAdapter::StubReaderConfiguration::getContactless() const +bool +StubPluginFactoryAdapter::StubReaderConfiguration::getContactless() const { return mIsContactless; } -std::shared_ptr StubPluginFactoryAdapter::StubReaderConfiguration::getCard() const +std::shared_ptr +StubPluginFactoryAdapter::StubReaderConfiguration::getCard() const { return mCard; } -/* STUB PLUGIN FACTORY ADAPTER ------------------------------------------------------------------ */ +/* STUB PLUGIN FACTORY ADAPTER + * ------------------------------------------------------------------ */ StubPluginFactoryAdapter::StubPluginFactoryAdapter( - const std::string& pluginName, - const std::vector> readerConfigurations, - const int monitoringCycleDuration) -: mReaderConfigurations(readerConfigurations), - mMonitoringCycleDuration(monitoringCycleDuration), - mPluginName(pluginName) {} - -const std::string& StubPluginFactoryAdapter::getPluginApiVersion() const + const std::string& pluginName, + const std::vector>& + readerConfigurations, + const int monitoringCycleDuration) +: mReaderConfigurations(readerConfigurations) +, mMonitoringCycleDuration(monitoringCycleDuration) +, mPluginName(pluginName) +{ +} + +const std::string +StubPluginFactoryAdapter::getPluginApiVersion() const { return PluginApiProperties_VERSION; } -const std::string& StubPluginFactoryAdapter::getCommonApiVersion() const +const std::string +StubPluginFactoryAdapter::getCommonApiVersion() const { return CommonApiProperties_VERSION; } -const std::string& StubPluginFactoryAdapter::getPluginName() const +const std::string& +StubPluginFactoryAdapter::getPluginName() const { return mPluginName; } -std::shared_ptr StubPluginFactoryAdapter::getPlugin() +std::shared_ptr +StubPluginFactoryAdapter::getPlugin() { - return std::make_shared(mPluginName, - mReaderConfigurations, - mMonitoringCycleDuration); + return std::make_shared( + mPluginName, mReaderConfigurations, mMonitoringCycleDuration); } -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPluginFactoryBuilder.cpp b/src/main/StubPluginFactoryBuilder.cpp index a78843d..4ba2e0b 100644 --- a/src/main/StubPluginFactoryBuilder.cpp +++ b/src/main/StubPluginFactoryBuilder.cpp @@ -1,16 +1,14 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "StubPluginFactoryBuilder.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include "keyple/plugin/stub/StubPluginFactoryBuilder.hpp" namespace keyple { namespace plugin { @@ -20,13 +18,20 @@ using Builder = StubPluginFactoryBuilder::Builder; const std::string StubPluginFactoryBuilder::PLUGIN_NAME = "StubPlugin"; -/* BUILDER -------------------------------------------------------------------------------------- */ +/* BUILDER + * -------------------------------------------------------------------------------------- + */ -Builder::Builder() : mMonitoringCycleDuration(0) {} +Builder::Builder() +: mMonitoringCycleDuration(0) +{ +} -Builder& Builder::withStubReader(const std::string& name, - const bool isContactLess, - std::shared_ptr card) +Builder& +Builder::withStubReader( + const std::string& name, + const bool isContactLess, + std::shared_ptr card) { mReaderConfigurations.push_back( std::make_shared(name, isContactLess, card)); @@ -34,27 +39,30 @@ Builder& Builder::withStubReader(const std::string& name, return *this; } -Builder& Builder::withMonitoringCycleDuration(const int duration) +Builder& +Builder::withMonitoringCycleDuration(const int duration) { mMonitoringCycleDuration = duration; return *this; } -std::shared_ptr Builder::build() const +std::shared_ptr +Builder::build() const { - return std::make_shared(PLUGIN_NAME, - mReaderConfigurations, - mMonitoringCycleDuration); + return std::make_shared( + PLUGIN_NAME, mReaderConfigurations, mMonitoringCycleDuration); } -/* STUB PLUGIN FACTORY BUILDER ------------------------------------------------------------------ */ +/* STUB PLUGIN FACTORY BUILDER + * ------------------------------------------------------------------ */ -std::unique_ptr StubPluginFactoryBuilder::builder() +std::unique_ptr +StubPluginFactoryBuilder::builder() { return std::unique_ptr(new Builder()); } -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPoolPlugin.h b/src/main/StubPoolPlugin.h deleted file mode 100644 index 6ad7050..0000000 --- a/src/main/StubPoolPlugin.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -/* Keyple Core Common */ -#include "KeyplePluginExtension.h" - -namespace keyple { -namespace plugin { -namespace stub { - -using namespace keyple::core::common; - -/** - * Simulates a keyple::core::plugin::spi::PoolPluginSpi with StubReader and StubSmartCard. Manages - * allocation readers by group reference. - */ -class StubPoolPlugin : public KeyplePluginExtension { -public: - /** - * Plug synchronously a new StubReader in the StubPoolPlugin associated to groupReference and a - * stub card. A READER_CONNECTED event will be raised. - * - * @param groupReference group reference of the new stub reader (mandatory) - * @param readerName name of the new stub reader (mandatory). Each reader should have a unique - * name, no matter to what groupReference they are associated to - * @param card insert a card at creation (can be null) - */ - virtual void plugPoolReader(const std::string& groupReference, - const std::string& readerName, - std::shared_ptr card) = 0; - - /** - * Unplug synchronously all readers associated to a groupReference. A READER_DISCONNECTED event - * will be raised. - * - * @param groupReference groupReference of the reader(s) to be unplugged (mandatory) - * @since 2.0.0 - */ - virtual void unplugPoolReaders(const std::string& groupReference) = 0; - - /** - * Unplug synchronously a pool reader. A READER_DISCONNECTED event will be raised. - * - * @param readerName name of the reader to be unplugged (mandatory) - * @since 2.0.0 - */ - virtual void unplugPoolReader(const std::string& readerName) = 0; -}; - -} -} -} diff --git a/src/main/StubPoolPluginAdapter.cpp b/src/main/StubPoolPluginAdapter.cpp index e0ab1e5..7bca28c 100644 --- a/src/main/StubPoolPluginAdapter.cpp +++ b/src/main/StubPoolPluginAdapter.cpp @@ -1,69 +1,70 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "StubPoolPluginAdapter.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include "keyple/plugin/stub/StubPoolPluginAdapter.hpp" #include -/* Keyple Core Plugin */ -#include "PluginIOException.h" - -/* Keyple Core Util */ -#include "IllegalArgumentException.h" -#include "KeypleAssert.h" +#include "keyple/core/plugin/PluginIOException.hpp" +#include "keyple/core/util/KeypleAssert.hpp" +#include "keyple/core/util/cpp/exception/IllegalArgumentException.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::plugin; -using namespace keyple::core::util; -using namespace keyple::core::util::cpp::exception; +using keyple::core::plugin::PluginIOException; +using keyple::core::plugin::spi::PoolReaderSpi; +using keyple::core::util::Assert; +using keyple::core::util::cpp::exception::IllegalArgumentException; StubPoolPluginAdapter::StubPoolPluginAdapter( - const std::string& name, - const std::vector>& readerConfigurations, - const int monitoringCycleDuration) + const std::string& name, + const std::vector>& + readerConfigurations, + const int monitoringCycleDuration) { /* - * C++: cannot directly use readerConfigurations to build mStubPluginAdapter, need to cast - * to a new sort of vector + * C++: cannot directly use readerConfigurations to build + * mStubPluginAdapter, need to cast to a new sort of vector */ std::vector> configurations; - for (const auto &config : readerConfigurations) { - configurations.push_back(std::dynamic_pointer_cast(config)); + for (const auto& config : readerConfigurations) { + configurations.push_back( + std::dynamic_pointer_cast(config)); } - mStubPluginAdapter = std::make_shared(name, - configurations, - monitoringCycleDuration); + mStubPluginAdapter = std::make_shared( + name, configurations, monitoringCycleDuration); for (const auto& readerConfiguration : readerConfigurations) { - mReaderToGroup.insert({readerConfiguration->getName(), - readerConfiguration->getGroupReference()}); + mReaderToGroup.insert( + {readerConfiguration->getName(), + readerConfiguration->getGroupReference()}); } } -const std::string& StubPoolPluginAdapter::getName() const +const std::string& +StubPoolPluginAdapter::getName() const { return mStubPluginAdapter->getName(); } -const std::vector> StubPoolPluginAdapter::searchAvailableReaders() +const std::vector> +StubPoolPluginAdapter::searchAvailableReaders() { return mStubPluginAdapter->searchAvailableReaders(); } -const std::vector StubPoolPluginAdapter::getReaderGroupReferences() const +const std::vector +StubPoolPluginAdapter::getReaderGroupReferences() const { std::vector references; for (const auto& ref : mReaderToGroup) { @@ -73,8 +74,8 @@ const std::vector StubPoolPluginAdapter::getReaderGroupReferences() return references; } -std::shared_ptr StubPoolPluginAdapter::allocateReader( - const std::string& readerGroupReference) +std::shared_ptr +StubPoolPluginAdapter::allocateReader(const std::string& readerGroupReference) { std::vector candidateReadersName; @@ -82,48 +83,58 @@ std::shared_ptr StubPoolPluginAdapter::allocateReader( /* Every reader is candidate for allocation */ candidateReadersName = mStubPluginAdapter->searchAvailableReaderNames(); } else { - /* Only readers from the readerGroupReference are candidates for allocation */ + /* Only readers from the readerGroupReference are candidates for + * allocation */ candidateReadersName = listReadersByGroup(readerGroupReference); } /* Find the first non allocated reader among candidates */ for (const auto& readerName : candidateReadersName) { /* Find if already existing */ - const auto it = std::find(mAllocatedReaders.begin(), mAllocatedReaders.end(), readerName); + const auto it = std::find( + mAllocatedReaders.begin(), mAllocatedReaders.end(), readerName); if (it == mAllocatedReaders.end()) { mAllocatedReaders.push_back(readerName); - return mStubPluginAdapter->searchReader(readerName); + return std::dynamic_pointer_cast( + mStubPluginAdapter->searchReader(readerName)); } } - throw PluginIOException("No reader is available in the groupReference : " + - readerGroupReference); + throw PluginIOException( + "No reader is available in the groupReference : " + + readerGroupReference); } -void StubPoolPluginAdapter::releaseReader(std::shared_ptr readerSpi) +void +StubPoolPluginAdapter::releaseReader(std::shared_ptr readerSpi) { Assert::getInstance().notNull(readerSpi, "reader SPI"); const auto stub = std::dynamic_pointer_cast(readerSpi); if (!stub) { - throw IllegalArgumentException("Can not release reader, Reader should be of type " \ - "StubReader"); + throw IllegalArgumentException( + "Can not release reader, Reader should be of type " + "StubReader"); } - const auto it = std::find(mAllocatedReaders.begin(), - mAllocatedReaders.end(), - readerSpi->getName()); + const auto it = std::find( + mAllocatedReaders.begin(), + mAllocatedReaders.end(), + readerSpi->getName()); mAllocatedReaders.erase(it); } -void StubPoolPluginAdapter::onUnregister() +void +StubPoolPluginAdapter::onUnregister() { /* NO-OP */ } -void StubPoolPluginAdapter::plugPoolReader(const std::string& groupReference, - const std::string& readerName, - std::shared_ptr card) +void +StubPoolPluginAdapter::plugPoolReader( + const std::string& groupReference, + const std::string& readerName, + std::shared_ptr card) { /* Create new reader */ mStubPluginAdapter->plugReader(readerName, false, card); @@ -132,22 +143,26 @@ void StubPoolPluginAdapter::plugPoolReader(const std::string& groupReference, mReaderToGroup.insert({readerName, groupReference}); } -void StubPoolPluginAdapter::unplugPoolReaders(const std::string& groupReference) +void +StubPoolPluginAdapter::unplugPoolReaders(const std::string& groupReference) { /* Find the reader in the readerPool */ - const std::vector readerNames = listReadersByGroup(groupReference); + const std::vector readerNames + = listReadersByGroup(groupReference); for (const auto& readerName : readerNames) { unplugPoolReader(readerName); } } -void StubPoolPluginAdapter::unplugPoolReader(const std::string& readerName) +void +StubPoolPluginAdapter::unplugPoolReader(const std::string& readerName) { /* Remove reader from pool */ mReaderToGroup.erase(mReaderToGroup.find(readerName)); /* Remove reader from allocate list */ - const auto it = std::find(mAllocatedReaders.begin(), mAllocatedReaders.end(), readerName); + const auto it = std::find( + mAllocatedReaders.begin(), mAllocatedReaders.end(), readerName); if (it != mAllocatedReaders.end()) { mAllocatedReaders.erase(it); } @@ -156,23 +171,26 @@ void StubPoolPluginAdapter::unplugPoolReader(const std::string& readerName) mStubPluginAdapter->unplugReader(readerName); } -int StubPoolPluginAdapter::getMonitoringCycleDuration() const +int +StubPoolPluginAdapter::getMonitoringCycleDuration() const { return mStubPluginAdapter->getMonitoringCycleDuration(); } -const std::vector StubPoolPluginAdapter::searchAvailableReaderNames() +const std::vector +StubPoolPluginAdapter::searchAvailableReaderNames() { return mStubPluginAdapter->searchAvailableReaderNames(); } -std::shared_ptr StubPoolPluginAdapter::searchReader(const std::string& readerName) +std::shared_ptr +StubPoolPluginAdapter::searchReader(const std::string& readerName) { return mStubPluginAdapter->searchReader(readerName); } -const std::vector StubPoolPluginAdapter::listReadersByGroup( - const std::string& aGroupReference) +const std::vector +StubPoolPluginAdapter::listReadersByGroup(const std::string& aGroupReference) { std::vector readers; @@ -188,6 +206,6 @@ const std::vector StubPoolPluginAdapter::listReadersByGroup( return readers; } -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPoolPluginFactory.h b/src/main/StubPoolPluginFactory.h deleted file mode 100644 index 559b004..0000000 --- a/src/main/StubPoolPluginFactory.h +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -/* Keyple Core Common */ -#include "KeyplePluginExtensionFactory.h" - -namespace keyple { -namespace plugin { -namespace stub { - -using namespace keyple::core::common; - -/** - * Stub specific KeyplePluginExtensionFactory to be provided to the Keyple SmartCard service - * to register the Stub Pool plugin, built by StubPoolPluginFactoryBuilder. - * - * @since 2.0.0 - */ -class StubPoolPluginFactory : public KeyplePluginExtensionFactory {}; - -} -} -} diff --git a/src/main/StubPoolPluginFactoryAdapter.cpp b/src/main/StubPoolPluginFactoryAdapter.cpp index 93c6d5a..4eb54aa 100644 --- a/src/main/StubPoolPluginFactoryAdapter.cpp +++ b/src/main/StubPoolPluginFactoryAdapter.cpp @@ -1,80 +1,86 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "StubPoolPluginFactoryAdapter.h" - -/* Keyple Core Plugin */ -#include "PluginApiProperties.h" - -/* Keyple Core Common */ -#include "CommonApiProperties.h" - -/* Keyple Plugin Stub */ -#include "StubPoolPluginAdapter.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include "keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp" + +#include "keyple/core/common/CommonApiProperties.hpp" +#include "keyple/core/plugin/PluginApiProperties.hpp" +#include "keyple/plugin/stub/StubPoolPluginAdapter.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::common; -using namespace keyple::core::plugin; +using keyple::core::common::CommonApiProperties_VERSION; +using keyple::core::plugin::PluginApiProperties_VERSION; -using StubPoolReaderConfiguration = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; +using StubPoolReaderConfiguration + = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; -/* STUB POOL READER CONFIGURATION --------------------------------------------------------------- */ +/* STUB POOL READER CONFIGURATION + * --------------------------------------------------------------- */ StubPoolReaderConfiguration::StubPoolReaderConfiguration( - const std::string& groupReference, - const std::string& name, - std::shared_ptr card) -: StubReaderConfiguration(name, false, card), mGroupReference(groupReference) {} + const std::string& groupReference, + const std::string& name, + std::shared_ptr card) +: StubReaderConfiguration(name, false, card) +, mGroupReference(groupReference) +{ +} -const std::string& StubPoolReaderConfiguration::getGroupReference() const +const std::string& +StubPoolReaderConfiguration::getGroupReference() const { return mGroupReference; } -/* STUB POOL PLUGIN FACTORY ADAPTER ------------------------------------------------------------- */ +/* STUB POOL PLUGIN FACTORY ADAPTER + * ------------------------------------------------------------- */ StubPoolPluginFactoryAdapter::StubPoolPluginFactoryAdapter( - const std::string& pluginName, - const std::vector>& readerConfigurations, - const int monitoringCycleDuration) -: mReaderConfigurations(readerConfigurations), - mMonitoringCycleDuration(monitoringCycleDuration), - mPluginName(pluginName) {} + const std::string& pluginName, + const std::vector>& + readerConfigurations, + const int monitoringCycleDuration) +: mReaderConfigurations(readerConfigurations) +, mMonitoringCycleDuration(monitoringCycleDuration) +, mPluginName(pluginName) +{ +} -const std::string& StubPoolPluginFactoryAdapter::getPluginApiVersion() const +const std::string +StubPoolPluginFactoryAdapter::getPluginApiVersion() const { return PluginApiProperties_VERSION; } -const std::string& StubPoolPluginFactoryAdapter::getCommonApiVersion() const +const std::string +StubPoolPluginFactoryAdapter::getCommonApiVersion() const { return CommonApiProperties_VERSION; } -const std::string& StubPoolPluginFactoryAdapter::getPoolPluginName() const +const std::string& +StubPoolPluginFactoryAdapter::getPoolPluginName() const { return mPluginName; } -std::shared_ptr StubPoolPluginFactoryAdapter::getPoolPlugin() +std::shared_ptr +StubPoolPluginFactoryAdapter::getPoolPlugin() { - return std::make_shared(mPluginName, - mReaderConfigurations, - mMonitoringCycleDuration); + return std::make_shared( + mPluginName, mReaderConfigurations, mMonitoringCycleDuration); } -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubPoolPluginFactoryBuilder.cpp b/src/main/StubPoolPluginFactoryBuilder.cpp index 5c18fad..b28a45e 100644 --- a/src/main/StubPoolPluginFactoryBuilder.cpp +++ b/src/main/StubPoolPluginFactoryBuilder.cpp @@ -1,67 +1,78 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "StubPoolPluginFactoryBuilder.h" - -/* Keyple Plugin Stub */ -#include "StubPoolPluginFactoryAdapter.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include "keyple/plugin/stub/StubPoolPluginFactoryBuilder.hpp" + +#include "keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp" namespace keyple { namespace plugin { namespace stub { using Builder = StubPoolPluginFactoryBuilder::Builder; -using StubPoolReaderConfiguration = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; +using StubPoolReaderConfiguration + = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; -/* BUILDER -------------------------------------------------------------------------------------- */ +/* BUILDER + * -------------------------------------------------------------------------------------- + */ -Builder::Builder() : mMonitoringCycleDuration(0) {} +Builder::Builder() +: mMonitoringCycleDuration(0) +{ +} -Builder& Builder::withStubReader(const std::string& groupReference, - const std::string& name, - std::shared_ptr card) +Builder& +Builder::withStubReader( + const std::string& groupReference, + const std::string& name, + std::shared_ptr card) { mReaderConfigurations.push_back( - std::make_shared(groupReference, name, card)); + std::make_shared( + groupReference, name, card)); return *this; } -Builder& Builder::withMonitoringCycleDuration(const int duration) +Builder& +Builder::withMonitoringCycleDuration(const int duration) { mMonitoringCycleDuration = duration; return *this; } -std::shared_ptr Builder::build() +std::shared_ptr +Builder::build() { return std::shared_ptr( - new StubPoolPluginFactoryAdapter(PLUGIN_NAME, - mReaderConfigurations, - mMonitoringCycleDuration)); + new StubPoolPluginFactoryAdapter( + PLUGIN_NAME, mReaderConfigurations, mMonitoringCycleDuration)); } -/* STUB POOL PLUGIN FACTORY BUILDER ------------------------------------------------------------- */ +/* STUB POOL PLUGIN FACTORY BUILDER + * ------------------------------------------------------------- */ const std::string StubPoolPluginFactoryBuilder::PLUGIN_NAME = "StubPoolPlugin"; -StubPoolPluginFactoryBuilder::StubPoolPluginFactoryBuilder() {} +StubPoolPluginFactoryBuilder::StubPoolPluginFactoryBuilder() +{ +} -std::unique_ptr StubPoolPluginFactoryBuilder::builder() +std::unique_ptr +StubPoolPluginFactoryBuilder::builder() { return std::unique_ptr(new Builder()); } -} -} -} +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubReader.h b/src/main/StubReader.h deleted file mode 100644 index febecdd..0000000 --- a/src/main/StubReader.h +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include -#include - -/* Keyple Core Common */ -#include "KeypleReaderExtension.h" - -/* Keyple Plugin Stub */ -#include "StubSmartCard.h" - -namespace keyple { -namespace plugin { -namespace stub { - -using namespace keyple::core::common; - -/** - * The Stub Reader supports programmatically the insertion and removal of {@link StubSmartCard}
- * To invoke those methods use Reader#getExtension(StubReader.class) from the Reader class. - * - * @since 2.0.0 - */ -class StubReader : public KeypleReaderExtension { -public: - /** - * Insert a stub card into the reader. The card is taken into account by the reader only if its - * protocol has been activated previously by the method - * keyple::core::plugin::spi::reader::ConfigurableReaderSpi::activateProtocol(). In - * such case it raises a CARD_INSERTED event. - * - * @param smartCard stub card to be inserted in the reader (not nullable) - * @since 2.0.0 - */ - virtual void insertCard(std::shared_ptr smartCard) = 0; - - /** - * Remove card from reader if any - * - * @since 2.0.0 - */ - virtual void removeCard() = 0; - - /** - * Get inserted card - * - * @return instance of a {@link StubSmartCard}, can be null if no card inserted - * @since 2.0.0 - */ - virtual std::shared_ptr getSmartcard() = 0; -}; - -} -} -} diff --git a/src/main/StubReaderAdapter.cpp b/src/main/StubReaderAdapter.cpp index 7476dda..f81ede1 100644 --- a/src/main/StubReaderAdapter.cpp +++ b/src/main/StubReaderAdapter.cpp @@ -1,60 +1,68 @@ -/************************************************************************************************** - * Copyright (c) 2022 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "StubReaderAdapter.h" - -/* Keyple Core Util */ -#include "Arrays.h" -#include "HexUtil.h" -#include "InterruptedException.h" -#include "KeypleAssert.h" -#include "Thread.h" - -/* Keyple Core Plugin */ -#include "CardIOException.h" -#include "TaskCanceledException.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include "keyple/plugin/stub/StubReaderAdapter.hpp" + +#include "keyple/core/plugin/CardIOException.hpp" +#include "keyple/core/plugin/TaskCanceledException.hpp" +#include "keyple/core/util/HexUtil.hpp" +#include "keyple/core/util/KeypleAssert.hpp" +#include "keyple/core/util/cpp/Any.hpp" +#include "keyple/core/util/cpp/Arrays.hpp" +#include "keyple/core/util/cpp/Thread.hpp" +#include "keyple/core/util/cpp/exception/InterruptedException.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::plugin; -using namespace keyple::core::util; -using namespace keyple::core::util::cpp; -using namespace keyple::core::util::cpp::exception; +using keyple::core::plugin::CardIOException; +using keyple::core::plugin::TaskCanceledException; +using keyple::core::util::Assert; +using keyple::core::util::HexUtil; +using keyple::core::util::cpp::any; +using keyple::core::util::cpp::Arrays; +using keyple::core::util::cpp::Thread; +using keyple::core::util::cpp::exception::InterruptedException; StubReaderAdapter::StubReaderAdapter( - const std::string& name, const bool isContactLess, std::shared_ptr card) -: mName(name), - mIsContactLess(isContactLess), - mSmartCard(card), - mContinueWaitForCardRemovalTask(false) {} + const std::string& name, + const bool isContactLess, + std::shared_ptr card) +: mName(name) +, mIsContactLess(isContactLess) +, mSmartCard(card) +, mContinueWaitForCardRemovalTask(false) +{ +} -void StubReaderAdapter::onStartDetection() +void +StubReaderAdapter::onStartDetection() { mLogger->trace("Detection has been started on reader %\n", getName()); } -void StubReaderAdapter::onStopDetection() +void +StubReaderAdapter::onStopDetection() { mLogger->trace("Detection has been stopped on reader %\n", getName()); } -const std::string& StubReaderAdapter::getName() const +const std::string& +StubReaderAdapter::getName() const { return mName; } -bool StubReaderAdapter::isProtocolSupported(const std::string& readerProtocol) const +bool +StubReaderAdapter::isProtocolSupported(const std::string& readerProtocol) const { (void)readerProtocol; @@ -62,22 +70,24 @@ bool StubReaderAdapter::isProtocolSupported(const std::string& readerProtocol) c return true; } -void StubReaderAdapter::activateProtocol(const std::string& readerProtocol) +void +StubReaderAdapter::activateProtocol(const std::string& readerProtocol) { mActivatedProtocols.push_back(readerProtocol); } -void StubReaderAdapter::deactivateProtocol(const std::string& readerProtocol) +void +StubReaderAdapter::deactivateProtocol(const std::string& readerProtocol) { - const auto it = std::find(mActivatedProtocols.begin(), - mActivatedProtocols.end(), - readerProtocol); + const auto it = std::find( + mActivatedProtocols.begin(), mActivatedProtocols.end(), readerProtocol); if (it != mActivatedProtocols.end()) { mActivatedProtocols.erase(it); } } -bool StubReaderAdapter::isCurrentProtocol(const std::string& readerProtocol) const +bool +StubReaderAdapter::isCurrentProtocol(const std::string& readerProtocol) const { if (mSmartCard != nullptr && mSmartCard->getCardProtocol() != "") { return mSmartCard->getCardProtocol() == readerProtocol; @@ -86,36 +96,42 @@ bool StubReaderAdapter::isCurrentProtocol(const std::string& readerProtocol) con } } -void StubReaderAdapter::openPhysicalChannel() +void +StubReaderAdapter::openPhysicalChannel() { if (mSmartCard != nullptr) { mSmartCard->openPhysicalChannel(); } } -void StubReaderAdapter::closePhysicalChannel() +void +StubReaderAdapter::closePhysicalChannel() { if (mSmartCard != nullptr) { mSmartCard->closePhysicalChannel(); } } -bool StubReaderAdapter::isPhysicalChannelOpen() const +bool +StubReaderAdapter::isPhysicalChannelOpen() const { return mSmartCard != nullptr && mSmartCard->isPhysicalChannelOpen(); } -bool StubReaderAdapter::checkCardPresence() +bool +StubReaderAdapter::checkCardPresence() { return mSmartCard != nullptr; } -const std::string StubReaderAdapter::getPowerOnData() const +const std::string +StubReaderAdapter::getPowerOnData() const { return HexUtil::toHex(mSmartCard->getPowerOnData()); } -const std::vector StubReaderAdapter::transmitApdu(const std::vector& apduIn) +const std::vector +StubReaderAdapter::transmitApdu(const std::vector& apduIn) { if (mSmartCard == nullptr) { throw CardIOException("No card available."); @@ -124,30 +140,36 @@ const std::vector StubReaderAdapter::transmitApdu(const std::vectorprocessApdu(apduIn); } -bool StubReaderAdapter::isContactless() +bool +StubReaderAdapter::isContactless() { return mIsContactLess; } -void StubReaderAdapter::onUnregister() +void +StubReaderAdapter::onUnregister() { /* NO-OP */ } -void StubReaderAdapter::insertCard(std::shared_ptr smartCard) +void +StubReaderAdapter::insertCard(std::shared_ptr smartCard) { Assert::getInstance().notNull(smartCard, "smart card"); if (checkCardPresence()) { - mLogger->warn("You must remove the inserted card before inserted another one\n"); + mLogger->warn( + "You must remove the inserted card before inserted another one\n"); return; } const std::string protocol = smartCard->getCardProtocol(); if (!Arrays::contains(mActivatedProtocols, protocol)) { - mLogger->trace("Inserted card protocol % does not match any activated protocol, please " \ - "use activateProtocol() method\n", - protocol); + mLogger->trace( + "Inserted card protocol % does not match any activated protocol, " + "please " + "use activateProtocol() method\n", + protocol); return; } @@ -157,7 +179,8 @@ void StubReaderAdapter::insertCard(std::shared_ptr smartCard) mSmartCard = smartCard; } -void StubReaderAdapter::removeCard() +void +StubReaderAdapter::removeCard() { if (mSmartCard != nullptr) { mLogger->trace("Remove card %\n", mSmartCard); @@ -166,36 +189,30 @@ void StubReaderAdapter::removeCard() } } -std::shared_ptr StubReaderAdapter::getSmartcard() +std::shared_ptr +StubReaderAdapter::getSmartcard() { return mSmartCard; } -void StubReaderAdapter::waitForCardRemovalDuringProcessing() +std::shared_ptr +StubReaderAdapter::getSelectedSmartCard() const { - mContinueWaitForCardRemovalTask = true; - - while (mSmartCard != nullptr && - mContinueWaitForCardRemovalTask == true /* && - !Thread.currentThread().isInterrupted() */) { - try { - Thread::sleep(100); - } catch (const InterruptedException& e) { - (void)e; - //Thread.currentThread().interrupt(); - } - } - - if (!mContinueWaitForCardRemovalTask) { - throw TaskCanceledException("Wait for card removal task cancelled"); - } + return nullptr; } -void StubReaderAdapter::stopWaitForCardRemovalDuringProcessing() +int +StubReaderAdapter::getCardInsertionMonitoringSleepDuration() const { - mContinueWaitForCardRemovalTask = false; + return 0; } +int +StubReaderAdapter::getCardRemovalMonitoringSleepDuration() const +{ + return 0; } -} -} + +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/StubSmartCard.cpp b/src/main/StubSmartCard.cpp index 5797540..62fc031 100644 --- a/src/main/StubSmartCard.cpp +++ b/src/main/StubSmartCard.cpp @@ -1,38 +1,36 @@ -/************************************************************************************************** - * Copyright (c) 2022 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "StubSmartCard.h" - -/* Keyple Core Util */ -#include "HexUtil.h" -#include "KeypleStd.h" -#include "Pattern.h" - -/* Keyple Core Plugin */ -#include "CardIOException.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include "keyple/plugin/stub/StubSmartCard.hpp" + +#include "keyple/core/plugin/CardIOException.hpp" +#include "keyple/core/util/HexUtil.hpp" +#include "keyple/core/util/cpp/KeypleStd.hpp" +#include "keyple/core/util/cpp/Pattern.hpp" namespace keyple { namespace plugin { namespace stub { -using namespace keyple::core::plugin; -using namespace keyple::core::util; -using namespace keyple::core::util::cpp; +using keyple::core::plugin::CardIOException; +using keyple::core::util::HexUtil; +using keyple::core::util::cpp::Pattern; -/* BUILDER -------------------------------------------------------------------------------------- */ +/* BUILDER ------------------------------------------------------------------ */ -StubSmartCard::Builder::Builder() {} +StubSmartCard::Builder::Builder() +{ +} -StubSmartCard::SimulatedCommandStep& StubSmartCard::Builder::withSimulatedCommand( +StubSmartCard::SimulatedCommandStep& +StubSmartCard::Builder::withSimulatedCommand( const std::string& command, const std::string& response) { /* Add commands without space */ @@ -44,28 +42,31 @@ StubSmartCard::SimulatedCommandStep& StubSmartCard::Builder::withSimulatedComman return *this; } -std::shared_ptr StubSmartCard::Builder::build() +std::shared_ptr +StubSmartCard::Builder::build() { - return std::shared_ptr( - new StubSmartCard(mPowerOnData, mCardProtocol, mHexCommands, mApduResponseProvider)); + return std::shared_ptr(new StubSmartCard( + mPowerOnData, mCardProtocol, mHexCommands, mApduResponseProvider)); } -StubSmartCard::ProtocolStep& StubSmartCard::Builder::withPowerOnData( - const std::vector& powerOnData) +StubSmartCard::ProtocolStep& +StubSmartCard::Builder::withPowerOnData(const std::vector& powerOnData) { mPowerOnData = powerOnData; return *this; } -StubSmartCard::CommandStep& StubSmartCard::Builder::withProtocol(const std::string& protocol) +StubSmartCard::CommandStep& +StubSmartCard::Builder::withProtocol(const std::string& protocol) { mCardProtocol = protocol; return *this; } -StubSmartCard::BuildStep& StubSmartCard::Builder::withApduResponseProvider( +StubSmartCard::BuildStep& +StubSmartCard::Builder::withApduResponseProvider( const std::shared_ptr apduResponseProvider) { mApduResponseProvider = apduResponseProvider; @@ -73,34 +74,40 @@ StubSmartCard::BuildStep& StubSmartCard::Builder::withApduResponseProvider( return *this; } -/* STUB SMARTCARD ------------------------------------------------------------------------------- */ +/* STUB SMARTCARD ----------------------------------------------------------- */ -const std::string& StubSmartCard::getCardProtocol() const +const std::string& +StubSmartCard::getCardProtocol() const { return mCardProtocol; } -const std::vector& StubSmartCard::getPowerOnData() const +const std::vector& +StubSmartCard::getPowerOnData() const { return mPowerOnData; } -bool StubSmartCard::isPhysicalChannelOpen() const +bool +StubSmartCard::isPhysicalChannelOpen() const { return mIsPhysicalChannelOpen; } -void StubSmartCard::openPhysicalChannel() +void +StubSmartCard::openPhysicalChannel() { mIsPhysicalChannelOpen = true; } -void StubSmartCard::closePhysicalChannel() +void +StubSmartCard::closePhysicalChannel() { mIsPhysicalChannelOpen = false; } -const std::vector StubSmartCard::processApdu(const std::vector& apduIn) +const std::vector +StubSmartCard::processApdu(const std::vector& apduIn) { if (apduIn.size() == 0) { return std::vector(); @@ -110,16 +117,17 @@ const std::vector StubSmartCard::processApdu(const std::vector const std::string hexApdu = HexUtil::toHex(apduIn); if (mApduResponseProvider != nullptr) { - const std::string responseFromRequest = - mApduResponseProvider->getResponseFromRequest(hexApdu); + const std::string responseFromRequest + = mApduResponseProvider->getResponseFromRequest(hexApdu); if (responseFromRequest != "") { return HexUtil::toByteArray(responseFromRequest); } } else if (!mHexCommands.empty()) { - /* Return matching hex response if the provided APDU matches the regex */ + /* Return matching hex response if the provided APDU matches the regex + */ for (const auto& hexCommand : mHexCommands) { - std::unique_ptr p = Pattern::compile(hexCommand.first); + std::shared_ptr p = Pattern::compile(hexCommand.first); if (p->matcher(hexApdu)->matches()) { return HexUtil::toByteArray(hexCommand.second); } @@ -130,33 +138,37 @@ const std::vector StubSmartCard::processApdu(const std::vector throw CardIOException("No response available for this request: " + hexApdu); } -std::ostream& operator<<(std::ostream& os, const std::shared_ptr ssc) +std::ostream& +operator<<(std::ostream& os, const std::shared_ptr ssc) { os << "STUB_SMART_CARD: {" << "POWER_ON_DATA = " << HexUtil::toHex(ssc->mPowerOnData) << ", " << "CARD_PROTOCOL = " << ssc->mCardProtocol << ", " << "IS_PHYSICAL_CHANNEL_OPEN = " << ssc->mIsPhysicalChannelOpen << ", " - << "HEX_COMMANDS(#) = " << ssc->mHexCommands.size() - << "}"; + << "HEX_COMMANDS(#) = " << ssc->mHexCommands.size() << "}"; - return os; + return os; } -std::unique_ptr StubSmartCard::builder() +std::unique_ptr +StubSmartCard::builder() { return std::unique_ptr(new Builder()); } -StubSmartCard::StubSmartCard(const std::vector& powerOnData, - const std::string& cardProtocol, - const std::map& hexCommands, - const std::shared_ptr apduResponseProvider) -: mPowerOnData(powerOnData), - mCardProtocol(cardProtocol), - mIsPhysicalChannelOpen(false), - mHexCommands(hexCommands), - mApduResponseProvider(apduResponseProvider) {} - -} -} +StubSmartCard::StubSmartCard( + const std::vector& powerOnData, + const std::string& cardProtocol, + const std::map& hexCommands, + const std::shared_ptr apduResponseProvider) +: mPowerOnData(powerOnData) +, mCardProtocol(cardProtocol) +, mIsPhysicalChannelOpen(false) +, mHexCommands(hexCommands) +, mApduResponseProvider(apduResponseProvider) +{ } + +} /* namespace stub */ +} /* namespace plugin */ +} /* namespace keyple */ diff --git a/src/main/spi/ApduResponseProviderSpi.h b/src/main/spi/ApduResponseProviderSpi.h deleted file mode 100644 index bafa674..0000000 --- a/src/main/spi/ApduResponseProviderSpi.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2022 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include - -namespace keyple { -namespace plugin { -namespace stub { -namespace spi { - -/** - * This interface must be used to provide an APDU response according to an APDU request. It is used - * by StubSmartCard} to delegate it APDU response providing to another class. - * - * @since 2.1.0 - */ -class ApduResponseProviderSpi { -public: - /** - * - */ - virtual ~ApduResponseProviderSpi() = default; - - /** - * Provide APDU responses according to an APDU request. - * - * @param apduRequest hexadecimal string format (without spaces) - * @return the APDU response in hexadecimal string format (without spaces) - * @since 2.1.0 - */ - virtual const std::string getResponseFromRequest(const std::string& apduRequest) = 0; -}; - -} -} -} -} diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 290ba38..d85df1e 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,60 +1,55 @@ -# ************************************************************************************************* -# Copyright (c) 2021 Calypso Networks Association * -# https://www.calypsonet-asso.org/ * -# * -# See the NOTICE file(s) distributed with this work for additional information regarding * -# copyright ownership. * -# * -# This program and the accompanying materials are made available under the terms of the Eclipse * -# Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * -# * -# SPDX-License-Identifier: EPL-2.0 * -# *************************************************************************************************/ +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ SET(EXECTUABLE_NAME keyplepluginstubcpplib_ut) -SET(KEYPLE_UTIL_DIR "../../../keyple-util-cpp-lib") -SET(KEYPLE_PLUGIN_DIR "../../../keyple-plugin-cpp-api") -SET(KEYPLE_COMMON_DIR "../../../keyple-common-cpp-api") - -SET(KEYPLE_UTIL_LIB "keypleutilcpplib") -SET(KEYPLE_STUB_LIB "keyplepluginstubcpplib") - INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../main - ${CMAKE_CURRENT_SOURCE_DIR}/../main/spi - - ${KEYPLE_UTIL_DIR}/src/main - ${KEYPLE_UTIL_DIR}/src/main/cpp - ${KEYPLE_UTIL_DIR}/src/main/cpp/exception - - ${KEYPLE_PLUGIN_DIR}/src/main - ${KEYPLE_PLUGIN_DIR}/src/main/spi - ${KEYPLE_PLUGIN_DIR}/src/main/spi/reader - ${KEYPLE_PLUGIN_DIR}/src/main/spi/reader/observable - ${KEYPLE_PLUGIN_DIR}/src/main/spi/reader/observable/state - ${KEYPLE_PLUGIN_DIR}/src/main/spi/reader/observable/state/insertion - ${KEYPLE_PLUGIN_DIR}/src/main/spi/reader/observable/state/processing - ${KEYPLE_PLUGIN_DIR}/src/main/spi/reader/observable/state/removal - - ${KEYPLE_COMMON_DIR}/src/main ) ADD_EXECUTABLE( + ${EXECTUABLE_NAME} - ${CMAKE_CURRENT_SOURCE_DIR}/MainTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/StubPluginAdapterTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/StubPluginFactoryAdapterTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/StubPoolPluginAdapterTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/StubPoolPluginFactoryAdapterTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/StubReaderAdapterTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/StubSmartCardTest.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/MainTest.cpp +) + +TARGET_INCLUDE_DIRECTORIES( + + ${EXECTUABLE_NAME} + + PUBLIC + + ${CMAKE_CURRENT_SOURCE_DIR} ) # Add Google Test SET(GOOGLETEST_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -INCLUDE(CMakeLists.txt.googletest) +INCLUDE("CMakeLists.txt.googletest") + +TARGET_LINK_LIBRARIES( -TARGET_LINK_LIBRARIES(${EXECTUABLE_NAME} gtest gmock ${KEYPLE_STUB_LIB}) + ${EXECTUABLE_NAME} + + PUBLIC + + gtest + gmock + + Keyple::Plugin::Stub +) diff --git a/src/test/CMakeLists.txt.googletest b/src/test/CMakeLists.txt.googletest index 3b56093..0117ef8 100644 --- a/src/test/CMakeLists.txt.googletest +++ b/src/test/CMakeLists.txt.googletest @@ -1,35 +1,41 @@ -CONFIGURE_FILE(CMakeLists.txt.in ${GOOGLETEST_DIRECTORY}/googletest-download/CMakeLists.txt) -EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${GOOGLETEST_DIRECTORY}/googletest-download -) - -# Prevent overriding the parent project's compiler/linker -# settings on Windows -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ -IF(result) - MESSAGE(FATAL_ERROR "CMake step for googletest failed: ${result}") -ENDIF() +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/googletest-src") + + MESSAGE("-- > Fetching GTest from keyple plugin stub") + + FetchContent_Declare( + + googletest -EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${GOOGLETEST_DIRECTORY}/googletest-download -) + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.14.0 + ) + +ELSE() + + FetchContent_Declare( + + googletest + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/googletest-src + ) -IF(result) - MESSAGE(FATAL_ERROR "Build step for googletest failed: ${result}") ENDIF() -# Prevent overriding the parent project's compiler/linker -# settings on Windows -#SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -# Add googletest directly to our build. This defines -# the gtest and gtest_main targets. -ADD_SUBDIRECTORY(${GOOGLETEST_DIRECTORY}/googletest-src - ${GOOGLETEST_DIRECTORY}/googletest-build - EXCLUDE_FROM_ALL -) \ No newline at end of file +FetchContent_MakeAvailable(googletest) diff --git a/src/test/CMakeLists.txt.in b/src/test/CMakeLists.txt.in deleted file mode 100644 index 5f1bbe5..0000000 --- a/src/test/CMakeLists.txt.in +++ /dev/null @@ -1,28 +0,0 @@ -# ************************************************************************************************* -# Copyright (c) 2021 Calypso Networks Association * -# https://www.calypsonet-asso.org/ * -# * -# See the NOTICE file(s) distributed with this work for additional information regarding * -# copyright ownership. * -# * -# This program and the accompanying materials are made available under the terms of the Eclipse * -# Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * -# * -# SPDX-License-Identifier: EPL-2.0 * -# *************************************************************************************************/ - -cmake_minimum_required(VERSION 2.8.2) - -project(googletest-download NONE) - -include(ExternalProject) -ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.11.0 - SOURCE_DIR "${GOOGLETEST_DIRECTORY}/googletest-src" - BINARY_DIR "${GOOGLETEST_DIRECTORY}/googletest-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/src/test/MainTest.cpp b/src/test/MainTest.cpp index 008dbcc..b1bada4 100644 --- a/src/test/MainTest.cpp +++ b/src/test/MainTest.cpp @@ -1,32 +1,21 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association * - * https://www.calypsonet-asso.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ #include "gtest/gtest.h" -/* Util */ -#include "Logger.h" - -using namespace testing; - -using namespace keyple::core::util::cpp; - -int main(int argc, char **argv) +int +main(int argc, char** argv) { /* Initialize GTest */ ::testing::InitGoogleTest(&argc, argv); - Logger::setLoggerLevel(Logger::Level::logError); - /* Run */ return RUN_ALL_TESTS(); -} \ No newline at end of file +} diff --git a/src/test/StubPluginAdapterTest.cpp b/src/test/StubPluginAdapterTest.cpp index 3089a2c..f2ad2a6 100644 --- a/src/test/StubPluginAdapterTest.cpp +++ b/src/test/StubPluginAdapterTest.cpp @@ -1,53 +1,61 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" -/* Keyple Plugin Stub */ -#include "StubPluginAdapter.h" -#include "StubPluginFactoryAdapter.h" -#include "StubSmartCard.h" +#include "keyple/plugin/stub/StubPluginAdapter.hpp" +#include "keyple/plugin/stub/StubPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" -using namespace testing; +using keyple::plugin::stub::StubPluginAdapter; +using keyple::plugin::stub::StubPluginFactoryAdapter; +using keyple::plugin::stub::StubSmartCard; -using namespace keyple::plugin::stub; - -using StubReaderConfiguration = StubPluginFactoryAdapter::StubReaderConfiguration; +using StubReaderConfiguration + = StubPluginFactoryAdapter::StubReaderConfiguration; static std::shared_ptr pluginAdapter; static std::shared_ptr card; static const std::string NAME = "name"; -static std::vector> readerConfigurations; +static std::vector> + readerConfigurations; static const std::vector powerOnData(1); static const std::string protocol = "protocol"; static const std::string commandHex = "1234567890ABCDEFFEDCBA0987654321"; static const std::string responseHex = "response"; -static std::shared_ptr buildACard() +static std::shared_ptr +buildACard() { - return StubSmartCard::builder()->withPowerOnData(powerOnData) - .withProtocol(protocol) - .withSimulatedCommand(commandHex, responseHex) - .build(); + return StubSmartCard::builder() + ->withPowerOnData(powerOnData) + .withProtocol(protocol) + .withSimulatedCommand(commandHex, responseHex) + .build(); } -static void setUp() +static void +setUp() { - pluginAdapter = std::make_shared(NAME, readerConfigurations, 0); + pluginAdapter + = std::make_shared(NAME, readerConfigurations, 0); card = buildACard(); } -static void tearDown() +static void +tearDown() { card.reset(); pluginAdapter.reset(); @@ -57,8 +65,10 @@ TEST(StubPluginAdapterTest, initPlugin_withOneReader) { setUp(); - readerConfigurations.push_back(std::make_shared(NAME, true, card)); - pluginAdapter = std::make_shared(NAME, readerConfigurations, 0); + readerConfigurations.push_back( + std::make_shared(NAME, true, card)); + pluginAdapter + = std::make_shared(NAME, readerConfigurations, 0); ASSERT_EQ(pluginAdapter->searchAvailableReaders().size(), 1); ASSERT_EQ(pluginAdapter->searchAvailableReaderNames().size(), 1); diff --git a/src/test/StubPluginFactoryAdapterTest.cpp b/src/test/StubPluginFactoryAdapterTest.cpp index 4a2fae3..d244bd0 100644 --- a/src/test/StubPluginFactoryAdapterTest.cpp +++ b/src/test/StubPluginFactoryAdapterTest.cpp @@ -1,37 +1,39 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include +#include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" -/* Keyple Plugin Stub */ -#include "StubPluginAdapter.h" -#include "StubPluginFactoryAdapter.h" -#include "StubPluginFactoryBuilder.h" -#include "StubSmartCard.h" - -/* Keyple Core Plugin */ -#include "PluginApiProperties.h" - -/* Keyple Core Common */ -#include "CommonApiProperties.h" - -using namespace testing; - -using namespace keyple::core::common; -using namespace keyple::core::plugin; -using namespace keyple::plugin::stub; - -using StubReaderConfiguration = StubPluginFactoryAdapter::StubReaderConfiguration; +#include "keyple/core/common/CommonApiProperties.hpp" +#include "keyple/core/plugin/PluginApiProperties.hpp" +#include "keyple/plugin/stub/StubPluginAdapter.hpp" +#include "keyple/plugin/stub/StubPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubPluginFactoryBuilder.hpp" +#include "keyple/plugin/stub/StubReaderAdapter.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" + +using keyple::core::common::CommonApiProperties_VERSION; +using keyple::core::plugin::PluginApiProperties_VERSION; +using keyple::plugin::stub::StubPluginAdapter; +using keyple::plugin::stub::StubPluginFactoryAdapter; +using keyple::plugin::stub::StubPluginFactoryBuilder; +using keyple::plugin::stub::StubReaderAdapter; +using keyple::plugin::stub::StubSmartCard; + +using StubReaderConfiguration + = StubPluginFactoryAdapter::StubReaderConfiguration; static std::shared_ptr factory; static std::shared_ptr card; @@ -42,20 +44,24 @@ static const std::string protocol = "protocol"; static const std::string commandHex = "1234567890ABCDEFFEDCBA0987654321"; static const std::string responseHex = "response"; -static std::shared_ptr buildACard() +static std::shared_ptr +buildACard() { - return StubSmartCard::builder()->withPowerOnData(powerOnData) - .withProtocol(protocol) - .withSimulatedCommand(commandHex, responseHex) - .build(); + return StubSmartCard::builder() + ->withPowerOnData(powerOnData) + .withProtocol(protocol) + .withSimulatedCommand(commandHex, responseHex) + .build(); } -static void setUp() +static void +setUp() { card = buildACard(); } -static void tearDown() +static void +tearDown() { card.reset(); } @@ -65,14 +71,16 @@ TEST(StubPluginFactoryAdapterTest, init_factory_with_reader_configuration) setUp(); factory = std::dynamic_pointer_cast( - StubPluginFactoryBuilder::builder()->withStubReader(READER_NAME, true, card) - .withMonitoringCycleDuration(monitoringCycle) - .build()); + StubPluginFactoryBuilder::builder() + ->withStubReader(READER_NAME, true, card) + .withMonitoringCycleDuration(monitoringCycle) + .build()); ASSERT_EQ(factory->getPluginApiVersion(), PluginApiProperties_VERSION); ASSERT_EQ(factory->getCommonApiVersion(), CommonApiProperties_VERSION); - auto stubPlugin = std::dynamic_pointer_cast(factory->getPlugin()); + auto stubPlugin + = std::dynamic_pointer_cast(factory->getPlugin()); ASSERT_NE(stubPlugin, nullptr); ASSERT_EQ(stubPlugin->getName(), StubPluginFactoryBuilder::PLUGIN_NAME); @@ -80,11 +88,11 @@ TEST(StubPluginFactoryAdapterTest, init_factory_with_reader_configuration) ASSERT_EQ(stubPlugin->searchAvailableReaders().size(), 1); auto reader = std::dynamic_pointer_cast( - stubPlugin->searchReader(READER_NAME)); + stubPlugin->searchReader(READER_NAME)); ASSERT_NE(reader, nullptr); ASSERT_EQ(reader->getSmartcard(), card); ASSERT_TRUE(reader->isContactless()); tearDown(); -} \ No newline at end of file +} diff --git a/src/test/StubPoolPluginAdapterTest.cpp b/src/test/StubPoolPluginAdapterTest.cpp index 4fac3d5..16af914 100644 --- a/src/test/StubPoolPluginAdapterTest.cpp +++ b/src/test/StubPoolPluginAdapterTest.cpp @@ -1,46 +1,48 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include +#include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" -/* Keyple Plugin Stub */ -#include "StubPluginAdapter.h" -#include "StubPluginFactoryAdapter.h" -#include "StubPoolPluginAdapter.h" -#include "StubSmartCard.h" - -/* Keyple Core Plugin */ -#include "PluginApiProperties.h" -#include "PluginIOException.h" - -/* Keyple Core Common */ -#include "CommonApiProperties.h" - -/* Keyple Core Util */ -#include "Arrays.h" - -using namespace testing; - -using namespace keyple::core::common; -using namespace keyple::core::plugin; -using namespace keyple::core::util::cpp; -using namespace keyple::plugin::stub; - -using StubPoolReaderConfiguration = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; +#include "keyple/core/plugin/PluginApiProperties.hpp" +#include "keyple/core/plugin/PluginIOException.hpp" +#include "keyple/core/plugin/spi/reader/ReaderSpi.hpp" +#include "keyple/core/util/cpp/Arrays.hpp" +#include "keyple/plugin/stub/StubPluginAdapter.hpp" +#include "keyple/plugin/stub/StubPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubPoolPluginAdapter.hpp" +#include "keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" + +using keyple::core::plugin::PluginApiProperties_VERSION; +using keyple::core::plugin::PluginIOException; +using keyple::core::plugin::spi::reader::ReaderSpi; +using keyple::core::util::cpp::Arrays; +using keyple::plugin::stub::StubPluginAdapter; +using keyple::plugin::stub::StubPluginFactoryAdapter; +using keyple::plugin::stub::StubPoolPluginAdapter; +using keyple::plugin::stub::StubPoolPluginFactoryAdapter; +using keyple::plugin::stub::StubSmartCard; + +using StubPoolReaderConfiguration + = StubPoolPluginFactoryAdapter::StubPoolReaderConfiguration; static std::shared_ptr pluginPoolAdapter; static std::shared_ptr card; -static std::vector> readerConfigurations; +static std::vector> + readerConfigurations; static const std::string READER_NAME = "readerName"; static const std::string READER_NAME_2 = "readerName2"; static const std::string group1 = "group1"; @@ -50,33 +52,44 @@ static const std::string protocol = "protocol"; static const std::string commandHex = "1234567890ABCDEFFEDCBA0987654321"; static const std::string responseHex = "response"; -static std::shared_ptr buildACard() +static std::shared_ptr +buildACard() { - return StubSmartCard::builder()->withPowerOnData(powerOnData) - .withProtocol(protocol) - .withSimulatedCommand(commandHex, responseHex) - .build(); + return StubSmartCard::builder() + ->withPowerOnData(powerOnData) + .withProtocol(protocol) + .withSimulatedCommand(commandHex, responseHex) + .build(); } -static void setUp() +static void +setUp() { - pluginPoolAdapter = std::make_shared(READER_NAME, readerConfigurations, 0); + pluginPoolAdapter = std::make_shared( + READER_NAME, readerConfigurations, 0); card = buildACard(); } -static void tearDown() +static void +tearDown() { card.reset(); pluginPoolAdapter.reset(); readerConfigurations.clear(); } -static void __initPlugin_withMultipleReader() +static void +__initPlugin_withMultipleReader() { - readerConfigurations.push_back(std::make_shared(group1, READER_NAME, card)); - readerConfigurations.push_back(std::make_shared(group1, READER_NAME_2, card)); + readerConfigurations.push_back( + std::make_shared( + group1, READER_NAME, card)); + readerConfigurations.push_back( + std::make_shared( + group1, READER_NAME_2, card)); - pluginPoolAdapter = std::make_shared(READER_NAME, readerConfigurations, 0); + pluginPoolAdapter = std::make_shared( + READER_NAME, readerConfigurations, 0); ASSERT_EQ(pluginPoolAdapter->searchAvailableReaders().size(), 2); ASSERT_FALSE(pluginPoolAdapter->searchReader(READER_NAME)->isContactless()); @@ -91,7 +104,8 @@ TEST(StubPoolPluginAdapterTest, initPlugin_withMultipleReader) tearDown(); } -static void __plugReader_should_create_reader() +static void +__plugReader_should_create_reader() { pluginPoolAdapter->plugPoolReader(group1, READER_NAME, card); @@ -121,11 +135,13 @@ TEST(StubPoolPluginAdapterTest, allocate_reader_without_group) tearDown(); } -static void __allocate_reader_with_group() +static void +__allocate_reader_with_group() { __plugReader_should_create_reader(); - std::shared_ptr reader = pluginPoolAdapter->allocateReader(group1); + std::shared_ptr reader + = pluginPoolAdapter->allocateReader(group1); ASSERT_EQ(reader->getName(), READER_NAME); } @@ -167,7 +183,8 @@ TEST(StubPoolPluginAdapterTest, unplugReaders_should_remove_readers) tearDown(); } -TEST(StubPoolPluginAdapterTest, allocate_reader_on_group_when_no_reader_throw_ex) +TEST( + StubPoolPluginAdapterTest, allocate_reader_on_group_when_no_reader_throw_ex) { setUp(); diff --git a/src/test/StubPoolPluginFactoryAdapterTest.cpp b/src/test/StubPoolPluginFactoryAdapterTest.cpp index 0bf8412..698b510 100644 --- a/src/test/StubPoolPluginFactoryAdapterTest.cpp +++ b/src/test/StubPoolPluginFactoryAdapterTest.cpp @@ -1,35 +1,35 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" -/* Keyple Plugin Stub */ -#include "StubPoolPluginAdapter.h" -#include "StubPoolPluginFactoryAdapter.h" -#include "StubPoolPluginFactoryBuilder.h" -#include "StubSmartCard.h" - -/* Keyple Core Plugin */ -#include "PluginApiProperties.h" - -/* Keyple Core Common */ -#include "CommonApiProperties.h" - -using namespace testing; - -using namespace keyple::core::common; -using namespace keyple::core::plugin; -using namespace keyple::plugin::stub; +#include "keyple/core/common/CommonApiProperties.hpp" +#include "keyple/core/plugin/PluginApiProperties.hpp" +#include "keyple/plugin/stub/StubPoolPluginAdapter.hpp" +#include "keyple/plugin/stub/StubPoolPluginFactoryAdapter.hpp" +#include "keyple/plugin/stub/StubPoolPluginFactoryBuilder.hpp" +#include "keyple/plugin/stub/StubReaderAdapter.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" + +using keyple::core::common::CommonApiProperties_VERSION; +using keyple::core::plugin::PluginApiProperties_VERSION; +using keyple::plugin::stub::StubPoolPluginAdapter; +using keyple::plugin::stub::StubPoolPluginFactoryAdapter; +using keyple::plugin::stub::StubPoolPluginFactoryBuilder; +using keyple::plugin::stub::StubReaderAdapter; +using keyple::plugin::stub::StubSmartCard; static std::shared_ptr factory; static std::shared_ptr card; @@ -42,20 +42,24 @@ static const std::string protocol = "protocol"; static const std::string commandHex = "1234567890ABCDEFFEDCBA0987654321"; static const std::string responseHex = "response"; -static std::shared_ptr buildACard() +static std::shared_ptr +buildACard() { - return StubSmartCard::builder()->withPowerOnData(powerOnData) - .withProtocol(protocol) - .withSimulatedCommand(commandHex, responseHex) - .build(); + return StubSmartCard::builder() + ->withPowerOnData(powerOnData) + .withProtocol(protocol) + .withSimulatedCommand(commandHex, responseHex) + .build(); } -static void setUp() +static void +setUp() { card = buildACard(); } -static void tearDown() +static void +tearDown() { card.reset(); } @@ -65,15 +69,17 @@ TEST(StubPoolPluginFactoryAdapterTest, init_factory_with_reader_configuration) setUp(); factory = std::dynamic_pointer_cast( - StubPoolPluginFactoryBuilder::builder()->withStubReader(GROUP, READER_NAME, card) - .withStubReader(GROUP, READER_NAME_2, card) - .withMonitoringCycleDuration(monitoringCycle) - .build()); + StubPoolPluginFactoryBuilder::builder() + ->withStubReader(GROUP, READER_NAME, card) + .withStubReader(GROUP, READER_NAME_2, card) + .withMonitoringCycleDuration(monitoringCycle) + .build()); ASSERT_EQ(factory->getPluginApiVersion(), PluginApiProperties_VERSION); ASSERT_EQ(factory->getCommonApiVersion(), CommonApiProperties_VERSION); - auto stubPlugin = std::dynamic_pointer_cast(factory->getPoolPlugin()); + auto stubPlugin = std::dynamic_pointer_cast( + factory->getPoolPlugin()); ASSERT_NE(stubPlugin, nullptr); ASSERT_EQ(stubPlugin->getName(), StubPoolPluginFactoryBuilder::PLUGIN_NAME); @@ -81,7 +87,7 @@ TEST(StubPoolPluginFactoryAdapterTest, init_factory_with_reader_configuration) ASSERT_EQ(stubPlugin->searchAvailableReaders().size(), 2); auto reader = std::dynamic_pointer_cast( - stubPlugin->searchReader(READER_NAME)); + stubPlugin->searchReader(READER_NAME)); ASSERT_NE(reader, nullptr); ASSERT_EQ(reader->getName(), READER_NAME); @@ -89,7 +95,7 @@ TEST(StubPoolPluginFactoryAdapterTest, init_factory_with_reader_configuration) ASSERT_FALSE(reader->isContactless()); auto reader2 = std::dynamic_pointer_cast( - stubPlugin->searchReader(READER_NAME_2)); + stubPlugin->searchReader(READER_NAME_2)); ASSERT_NE(reader2, nullptr); ASSERT_EQ(reader2->getName(), READER_NAME_2); diff --git a/src/test/StubReaderAdapterTest.cpp b/src/test/StubReaderAdapterTest.cpp index f517bad..57c265c 100644 --- a/src/test/StubReaderAdapterTest.cpp +++ b/src/test/StubReaderAdapterTest.cpp @@ -1,35 +1,31 @@ -/************************************************************************************************** - * Copyright (c) 2022 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" -/* Keyple Plugin Stub */ -#include "StubReaderAdapter.h" -#include "StubSmartCard.h" +#include "keyple/core/plugin/CardIOException.hpp" +#include "keyple/core/util/HexUtil.hpp" +#include "keyple/core/util/cpp/exception/IllegalArgumentException.hpp" +#include "keyple/plugin/stub/StubReaderAdapter.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" -/* Keyple Core Plugin */ -#include "CardIOException.h" - -/* Keyple Core Util */ -#include "HexUtil.h" -#include "IllegalArgumentException.h" - -using namespace testing; - -using namespace keyple::core::plugin; -using namespace keyple::core::util; -using namespace keyple::core::util::cpp::exception; -using namespace keyple::plugin::stub; +using keyple::core::plugin::CardIOException; +using keyple::core::util::HexUtil; +using keyple::core::util::cpp::exception::IllegalArgumentException; +using keyple::plugin::stub::StubReaderAdapter; +using keyple::plugin::stub::StubSmartCard; static std::shared_ptr adapter; static std::shared_ptr card; @@ -39,21 +35,26 @@ static bool IS_CONTACT_LESS = true; static const std::string commandHex = "1234567890ABCDEFFEDCBA0987654321"; static const std::string responseHex = "response"; -static std::shared_ptr buildCard(const std::string& protocol) +static std::shared_ptr +buildCard(const std::string& protocol) { - return StubSmartCard::builder()->withPowerOnData(HexUtil::toByteArray("0000")) - .withProtocol(protocol) - .withSimulatedCommand(commandHex, responseHex) - .build(); + return StubSmartCard::builder() + ->withPowerOnData(HexUtil::toByteArray("0000")) + .withProtocol(protocol) + .withSimulatedCommand(commandHex, responseHex) + .build(); } -static void setUp() +static void +setUp() { card = buildCard(PROTOCOL); - adapter = std::make_shared(NAME, IS_CONTACT_LESS, nullptr); + adapter + = std::make_shared(NAME, IS_CONTACT_LESS, nullptr); } -static void tearDown() +static void +tearDown() { adapter.reset(); card.reset(); @@ -87,12 +88,14 @@ TEST(StubReaderAdapterTest, insert_card_with_activated_protocol) adapter->insertCard(card); ASSERT_EQ(adapter->getSmartcard(), card); - ASSERT_EQ(adapter->getPowerOnData(), HexUtil::toHex(card->getPowerOnData())); + ASSERT_EQ( + adapter->getPowerOnData(), HexUtil::toHex(card->getPowerOnData())); ASSERT_EQ(adapter->isPhysicalChannelOpen(), card->isPhysicalChannelOpen()); ASSERT_TRUE(adapter->checkCardPresence()); ASSERT_TRUE(adapter->isCurrentProtocol(PROTOCOL)); - ASSERT_EQ(adapter->transmitApdu(HexUtil::toByteArray(commandHex)), - HexUtil::toByteArray(responseHex)); + ASSERT_EQ( + adapter->transmitApdu(HexUtil::toByteArray(commandHex)), + HexUtil::toByteArray(responseHex)); tearDown(); } @@ -166,7 +169,9 @@ TEST(StubReaderAdapterTest, op_without_card) ASSERT_FALSE(adapter->isCurrentProtocol("any")); - EXPECT_THROW(adapter->transmitApdu(HexUtil::toByteArray(commandHex)), CardIOException); + EXPECT_THROW( + adapter->transmitApdu(HexUtil::toByteArray(commandHex)), + CardIOException); tearDown(); } diff --git a/src/test/StubSmartCardTest.cpp b/src/test/StubSmartCardTest.cpp index 08ef6bb..10f7bf5 100644 --- a/src/test/StubSmartCardTest.cpp +++ b/src/test/StubSmartCardTest.cpp @@ -1,34 +1,29 @@ -/************************************************************************************************** - * Copyright (c) 2022 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" -/* Keyple Plugin Stub */ -#include "ApduResponseProviderSpi.h" -#include "StubSmartCard.h" +#include "keyple/core/plugin/CardIOException.hpp" +#include "keyple/core/util/HexUtil.hpp" +#include "keyple/plugin/stub/StubSmartCard.hpp" +#include "keyple/plugin/stub/spi/ApduResponseProviderSpi.hpp" -/* Keyple Core Util */ -#include "HexUtil.h" - -/* Keyple Core Plugin */ -#include "CardIOException.h" - -using namespace testing; - -using namespace keyple::core::plugin; -using namespace keyple::core::util; -using namespace keyple::plugin::stub; -using namespace keyple::plugin::stub::spi; +using keyple::core::plugin::CardIOException; +using keyple::core::util::HexUtil; +using keyple::plugin::stub::StubSmartCard; +using keyple::plugin::stub::spi::ApduResponseProviderSpi; static std::shared_ptr card; static const std::vector powerOnData(1); @@ -39,26 +34,31 @@ static const std::string responseHex = "response"; class ApduResponseProviderSpiMock : public ApduResponseProviderSpi { public: - const std::string getResponseFromRequest(const std::string& apduRequest) override + const std::string + getResponseFromRequest(const std::string& apduRequest) override { return (apduRequest == commandHex) ? responseHex : ""; } }; -static std::shared_ptr buildACard() +static std::shared_ptr +buildACard() { - return StubSmartCard::builder()->withPowerOnData(powerOnData) - .withProtocol(protocol) - .withSimulatedCommand(commandHex, responseHex) - .build(); + return StubSmartCard::builder() + ->withPowerOnData(powerOnData) + .withProtocol(protocol) + .withSimulatedCommand(commandHex, responseHex) + .build(); } -static void setUp() +static void +setUp() { card = buildACard(); } -static void tearDown() +static void +tearDown() { card.reset(); } @@ -67,7 +67,8 @@ TEST(StubSmartCardTest, sendApdu_apduExists_sendResponse) { setUp(); - const std::vector apduResponse = card->processApdu(HexUtil::toByteArray(commandHex)); + const std::vector apduResponse + = card->processApdu(HexUtil::toByteArray(commandHex)); ASSERT_EQ(apduResponse, HexUtil::toByteArray(responseHex)); @@ -78,11 +79,13 @@ TEST(StubSmartCardTest, sendApdu_adpuRegexpExists_sendResponse) { setUp(); - card = StubSmartCard::builder()->withPowerOnData(powerOnData) - .withProtocol(protocol) - .withSimulatedCommand(commandHexRegexp, responseHex) - .build(); - const std::vector apduResponse = card->processApdu(HexUtil::toByteArray(commandHex)); + card = StubSmartCard::builder() + ->withPowerOnData(powerOnData) + .withProtocol(protocol) + .withSimulatedCommand(commandHexRegexp, responseHex) + .build(); + const std::vector apduResponse + = card->processApdu(HexUtil::toByteArray(commandHex)); ASSERT_EQ(apduResponse, HexUtil::toByteArray(responseHex)); @@ -93,7 +96,8 @@ TEST(StubSmartCardTest, sendApdu_adpuNotExists_sendException) { setUp(); - EXPECT_THROW(card->processApdu(HexUtil::toByteArray("excp")), CardIOException); + EXPECT_THROW( + card->processApdu(HexUtil::toByteArray("excp")), CardIOException); tearDown(); } @@ -102,12 +106,16 @@ TEST(StubSmartCardTest, shouldUse_a_apduResponseProvider_to_sendResponse) { setUp(); - const auto response = std::dynamic_pointer_cast(std::make_shared()); - card = StubSmartCard::builder()->withPowerOnData(powerOnData) - .withProtocol(protocol) - .withApduResponseProvider(response) - .build(); - const std::vector apduResponse = card->processApdu(HexUtil::toByteArray(commandHex)); + const auto response + = std::dynamic_pointer_cast( + std::make_shared()); + card = StubSmartCard::builder() + ->withPowerOnData(powerOnData) + .withProtocol(protocol) + .withApduResponseProvider(response) + .build(); + const std::vector apduResponse + = card->processApdu(HexUtil::toByteArray(commandHex)); ASSERT_EQ(apduResponse, HexUtil::toByteArray(responseHex)); diff --git a/toolchain/arm-unknown-gnueabi-linux.cmake b/toolchain/arm-unknown-gnueabi-linux.cmake index c7c68bc..3683870 100644 --- a/toolchain/arm-unknown-gnueabi-linux.cmake +++ b/toolchain/arm-unknown-gnueabi-linux.cmake @@ -9,10 +9,10 @@ SET(ARM_SYSROOT_DIR ${ARM_TOOLCHAIN_DIR}/arm-unknown-linux-gnueabi/sysroot) # Which C and C++ compiler to use SET(CMAKE_C_COMPILER ${ARM_COMPILER_DIR}/arm-unknown-linux-gnueabi-gcc) -SET(CMAKE_CXX_COMPILER ${ARM_COMPILER_DIR}/arm-unknown-linux-gnueabi-g++) +SET(CMAKE_CXX_COMPILER ${ARM_COMPILER_DIR}/arm-unknown-linux-gnueabi-g++) # Here is the target environment located -SET(CMAKE_FIND_ROOT_PATH ${ARM_SYSROOT_DIR}) +SET(CMAKE_FIND_ROOT_PATH ${ARM_SYSROOT_DIR}) # Adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, @@ -24,4 +24,3 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) # Linker SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${ARM_SYSROOT_DIR}") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${ARM_SYSROOT_DIR} -L${ARM_SYSROOT_DIR}") - diff --git a/toolchain/clang-8-linux.cmake b/toolchain/clang-8-linux.cmake index 1a932d1..93222ef 100644 --- a/toolchain/clang-8-linux.cmake +++ b/toolchain/clang-8-linux.cmake @@ -42,4 +42,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/clang-9-linux.cmake b/toolchain/clang-9-linux.cmake index ac30418..4c13b7f 100644 --- a/toolchain/clang-9-linux.cmake +++ b/toolchain/clang-9-linux.cmake @@ -42,4 +42,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/clang-linux.cmake b/toolchain/clang-linux.cmake index 31cea4d..6282777 100644 --- a/toolchain/clang-linux.cmake +++ b/toolchain/clang-linux.cmake @@ -42,4 +42,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/clang-macos.cmake b/toolchain/clang-macos.cmake index f965786..29a03d5 100644 --- a/toolchain/clang-macos.cmake +++ b/toolchain/clang-macos.cmake @@ -42,4 +42,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/clang-windows.cmake b/toolchain/clang-windows.cmake index 606fe65..85be998 100644 --- a/toolchain/clang-windows.cmake +++ b/toolchain/clang-windows.cmake @@ -45,8 +45,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MDd") # debug multi thread dll SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS") # buffers security check SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise") # floating point SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t") # standard behaviour -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:forScope") # -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:inline") # +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:forScope") # +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:inline") # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR") # enables RTTI SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gd") # uses __cdecl convention SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /TP") # all sources are C++ @@ -67,4 +67,3 @@ SET(LIBRARY_TYPE SHARED) # Special tricks INCLUDE(GenerateExportHeader) - diff --git a/toolchain/gcc-10-linux.cmake b/toolchain/gcc-10-linux.cmake index 3fbe78b..3282cd6 100644 --- a/toolchain/gcc-10-linux.cmake +++ b/toolchain/gcc-10-linux.cmake @@ -43,4 +43,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/gcc-4.8.3-linux.cmake b/toolchain/gcc-4.8.3-linux.cmake index f6af177..e6d3df0 100644 --- a/toolchain/gcc-4.8.3-linux.cmake +++ b/toolchain/gcc-4.8.3-linux.cmake @@ -27,4 +27,3 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) # Linker #SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR}") #SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR} -L${GCC_SYSROOT_DIR}") - diff --git a/toolchain/gcc-8-linux.cmake b/toolchain/gcc-8-linux.cmake index 6272eb1..db27a7b 100644 --- a/toolchain/gcc-8-linux.cmake +++ b/toolchain/gcc-8-linux.cmake @@ -43,4 +43,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/gcc-9-linux.cmake b/toolchain/gcc-9-linux.cmake index 21685b2..a6e923d 100644 --- a/toolchain/gcc-9-linux.cmake +++ b/toolchain/gcc-9-linux.cmake @@ -43,4 +43,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/gcc-linux.cmake b/toolchain/gcc-linux.cmake index a62432d..ff67b6e 100644 --- a/toolchain/gcc-linux.cmake +++ b/toolchain/gcc-linux.cmake @@ -43,4 +43,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/ios-macos.cmake b/toolchain/ios-macos.cmake index 990470f..3407d82 100644 --- a/toolchain/ios-macos.cmake +++ b/toolchain/ios-macos.cmake @@ -92,4 +92,3 @@ SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-search_paths_first") # Libraries type SET(LIBRARY_TYPE STATIC) -