Keyple Card Calypso C++ Library 2.1.0
Reference Terminal Reader API for C++
CalypsoExtensionService.cpp
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional information regarding *
5 * copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the terms of the Eclipse *
8 * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 *
9 * *
10 * SPDX-License-Identifier: EPL-2.0 *
11 **************************************************************************************************/
12
14
15/* Calypsonet Terminal Calypso */
17
18/* Calypsonet Terminal Card */
19#include "CardApiProperties.h"
20
21/* Calypsonet Terminal Reader */
22#include "ReaderApiProperties.h"
23
24/* Keyple Card Calypso */
27
28/* Keyple Core Common */
29#include "CommonApiProperties.h"
30
31/* Keyple Core Util */
32#include "KeypleAssert.h"
33
34namespace keyple {
35namespace card {
36namespace calypso {
37
38using namespace calypsonet::terminal::calypso;
39using namespace calypsonet::terminal::card;
40using namespace calypsonet::terminal::reader;
41using namespace keyple::core::common;
42using namespace keyple::core::util;
43
44const std::string CalypsoExtensionService::PRODUCT_TYPE = "productType";
45std::shared_ptr<CalypsoExtensionService> CalypsoExtensionService::mInstance;
46
47CalypsoExtensionService::CalypsoExtensionService() {}
48
49std::shared_ptr<CalypsoExtensionService> CalypsoExtensionService::getInstance()
50{
51 if (mInstance == nullptr) {
52 mInstance = std::shared_ptr<CalypsoExtensionService>(new CalypsoExtensionService());
53 }
54
55 return mInstance;
56}
57
59{
60 return ReaderApiProperties_VERSION;
61}
62
64{
65 return CardApiProperties_VERSION;
66}
67
69{
70 return CommonApiProperties_VERSION;
71}
72
73std::shared_ptr<SearchCommandData> CalypsoExtensionService::createSearchCommandData() const
74{
75 return std::make_shared<SearchCommandDataAdapter>();
76}
77
78std::shared_ptr<CalypsoCardSelection> CalypsoExtensionService::createCardSelection() const
79{
80 return std::make_shared<CalypsoCardSelectionAdapter>();
81}
82
83std::shared_ptr<CalypsoSamSelection> CalypsoExtensionService::createSamSelection() const
84{
85 return std::make_shared<CalypsoSamSelectionAdapter>();
86}
87
88std::shared_ptr<CardResourceProfileExtension>
90 const std::shared_ptr<CalypsoSamSelection> calypsoSamSelection) const
91{
92 Assert::getInstance().notNull(calypsoSamSelection, "calypsoSamSelection");
93
94 return std::make_shared<CalypsoSamResourceProfileExtensionAdapter>(calypsoSamSelection);
95}
96
97std::shared_ptr<CardSecuritySetting> CalypsoExtensionService::createCardSecuritySetting() const
98{
99 return std::make_shared<CardSecuritySettingAdapter>();
100}
101
102std::shared_ptr<CardTransactionManager> CalypsoExtensionService::createCardTransaction(
103 std::shared_ptr<CardReader> reader,
104 const std::shared_ptr<CalypsoCard> calypsoCard,
105 const std::shared_ptr<CardSecuritySetting> cardSecuritySetting)
106{
107
108 Assert::getInstance().notNull(reader, "reader")
109 .notNull(calypsoCard, "calypsoCard")
110 .notNull(cardSecuritySetting, "cardSecuritySetting");
111
112 /*
113 * C++: check args data *after* nullity has been ruled out. Calls order doesn't seem
114 * respected by MSVC
115 */
116 Assert::getInstance().isTrue(calypsoCard->getProductType() != CalypsoCard::ProductType::UNKNOWN,
118
119 return std::make_shared<CardTransactionManagerAdapter>(reader,
120 calypsoCard,
121 cardSecuritySetting);
122}
123
124std::shared_ptr<CardTransactionManager>
126 std::shared_ptr<CardReader> reader, const std::shared_ptr<CalypsoCard> calypsoCard)
127{
128 Assert::getInstance().notNull(reader, "reader")
129 .notNull(calypsoCard, "calypsoCard");
130
131 /*
132 * C++: check args data *after* nullity has been ruled out. Calls order doesn't seem
133 * respected by MSVC
134 */
135 Assert::getInstance().isTrue(calypsoCard->getProductType() != CalypsoCard::ProductType::UNKNOWN,
137
138 return std::make_shared<CardTransactionManagerAdapter>(reader, calypsoCard);
139}
140
141
142}
143}
144}
std::shared_ptr< CalypsoSamSelection > createSamSelection() const
std::shared_ptr< CardTransactionManager > createCardTransactionWithoutSecurity(std::shared_ptr< CardReader > reader, const std::shared_ptr< CalypsoCard > calypsoCard)
std::shared_ptr< CardResourceProfileExtension > createSamResourceProfileExtension(const std::shared_ptr< CalypsoSamSelection > calypsoSamSelection) const
const std::string & getReaderApiVersion() const override
std::shared_ptr< CardTransactionManager > createCardTransaction(std::shared_ptr< CardReader > reader, const std::shared_ptr< CalypsoCard > calypsoCard, const std::shared_ptr< CardSecuritySetting > cardSecuritySetting)
std::shared_ptr< CardSecuritySetting > createCardSecuritySetting() const
const std::string & getCardApiVersion() const override
std::shared_ptr< SearchCommandData > createSearchCommandData() const
const std::string & getCommonApiVersion() const override
std::shared_ptr< CalypsoCardSelection > createCardSelection() const
static std::shared_ptr< CalypsoExtensionService > getInstance()