Keypop Card C++ API - 2.0.1
Component of the Keypop C++ API
CardSelectionRequestSpi.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * This program and the accompanying materials are made available under the *
5 * terms of the MIT License which is available at *
6 * https://opensource.org/licenses/MIT. *
7 * *
8 * SPDX-License-Identifier: MIT *
9 ******************************************************************************/
10
11#pragma once
12
13#include <memory>
14#include <ostream>
15#include <vector>
16
18
19namespace keypop {
20namespace card {
21namespace spi {
22
33public:
37 virtual ~CardSelectionRequestSpi() = default;
38
45 virtual const std::vector<int>& getSuccessfulSelectionStatusWords() const
46 = 0;
47
54 virtual const std::shared_ptr<CardRequestSpi> getCardRequest() const = 0;
55
59 friend std::ostream&
60 operator<<(std::ostream& os, const CardSelectionRequestSpi& csr) {
61 const std::vector<int> sw = csr.getSuccessfulSelectionStatusWords();
62
63 std::stringstream ssSw;
64 for (auto it = std::begin(sw); it != std::end(sw); ++it) {
65 ssSw << std::uppercase << std::hex << std::setfill('0')
66 << std::setw(4) << static_cast<int>(*it);
67 if (it != sw.end() - 1) {
68 ssSw << ", ";
69 }
70 }
71
72 os << "CARD_SELECTION_REQUEST_SPI: {"
73 << "SUCCESSFUL_SELECTON_STATUS_WORDS: " << ssSw.str() << ", "
74 << "CARD_REQUEST: " << csr.getCardRequest() << "}";
75
76 return os;
77 }
78
82 friend std::ostream&
84 std::ostream& os, const std::shared_ptr<CardSelectionRequestSpi> csr) {
85 os << *csr.get();
86
87 return os;
88 }
89
93 friend std::ostream&
95 std::ostream& os,
96 const std::vector<std::shared_ptr<CardSelectionRequestSpi>>& csrs) {
97 os << "CARD_SELECTION_REQUEST_SPIS: {";
98
99 for (auto it = std::begin(csrs); it != std::end(csrs); ++it) {
100 os << *it;
101 if (it != csrs.end() - 1) {
102 os << ", ";
103 }
104 }
105
106 os << "}";
107
108 return os;
109 }
110};
111
112} /* namespace spi */
113} /* namespace card */
114} /* namespace keypop */
Data provided as input to the selection process.
friend std::ostream & operator<<(std::ostream &os, const CardSelectionRequestSpi &csr)
virtual const std::vector< int > & getSuccessfulSelectionStatusWords() const =0
Gets the list of successful selection status words.
virtual const std::shared_ptr< CardRequestSpi > getCardRequest() const =0
Gets the card request.
virtual ~CardSelectionRequestSpi()=default
Virtual destructor.