Keyple Service Resource C++ Library - 3.1.1
Component of the Keyple C++ middleware
CardResourceAdapter.cpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional *
5 * information regarding copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the *
8 * terms of the Eclipse Public License 2.0 which is available at *
9 * http://www.eclipse.org/legal/epl-2.0 *
10 * *
11 * SPDX-License-Identifier: EPL-2.0 *
12 ******************************************************************************/
13
14#include "keyple/core/service/resource/CardResourceAdapter.hpp"
15
16#include <ostream>
17
18#include "keyple/core/util/HexUtil.hpp"
19#include "keyple/core/util/cpp/System.hpp"
20
21namespace keyple {
22namespace core {
23namespace service {
24namespace resource {
25
26using keyple::core::util::HexUtil;
27using keyple::core::util::cpp::System;
28
29CardResourceAdapter::CardResourceAdapter(
30 const std::shared_ptr<CardReader> reader,
31 const std::shared_ptr<KeypleReaderExtension> readerExtension,
32 const std::shared_ptr<SmartCard> smartCard)
33: mReader(reader)
34, mReaderExtension(readerExtension)
35, mSmartCard(smartCard)
36{
37}
38
39std::shared_ptr<CardReader> CardResourceAdapter::getReader() const
40{
41 return mReader;
42}
43
44std::shared_ptr<KeypleReaderExtension>
45CardResourceAdapter::getReaderExtension() const
46{
47 return mReaderExtension;
48}
49
50std::shared_ptr<SmartCard>
51CardResourceAdapter::getSmartCard() const
52{
53 return mSmartCard;
54}
55
56std::ostream&
57operator<<(std::ostream& os, const CardResourceAdapter& cra)
58{
59 os << "CARD_RESOURCE_ADAPTER: {"
60 << "READER_NAME: " << cra.mReader->getName() << ", "
61 << "READER_HASH_CODE: "
62 << HexUtil::toHex(System::identityHashCode(cra.mReader)) << ", "
63 << "SMART_CARD_HASH_CODE: "
64 << HexUtil::toHex(System::identityHashCode(cra.mSmartCard)) << ", "
65 << "}";
66
67 return os;
68}
69
73std::ostream&
75 std::ostream& os, const std::shared_ptr<CardResourceAdapter> cra)
76{
77 if (cra == nullptr) {
78 os << "CARD_RESOURCE_ADAPTER: null";
79 } else {
80 os << "CARD_RESOURCE_ADAPTER: {"
81 << "HASH_CODE: " << HexUtil::toHex(System::identityHashCode(cra)) << ", "
82 << "READER_NAME: " << cra->mReader->getName() << ", "
83 << "READER_HASH_CODE: "
84 << HexUtil::toHex(System::identityHashCode(cra->mReader)) << ", "
85 << "SMART_CARD_HASH_CODE: "
86 << HexUtil::toHex(System::identityHashCode(cra->mSmartCard)) << ", "
87 << "}";
88 }
89
90 return os;
91}
92
93} /* namespace resource */
94} /* namespace service */
95} /* namespace core */
96} /* namespace keyple */
std::ostream & operator<<(std::ostream &os, const std::shared_ptr< CardResourceAdapter > cra)