Keyple Card Calypso C++ Library 2.1.0
Reference Terminal Reader API for C++
ElementaryFileAdapter.cpp
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2022 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
15namespace keyple {
16namespace card {
17namespace calypso {
18
20: mSfi(sfi), mData(std::make_shared<FileDataAdapter>()) {}
21
22ElementaryFileAdapter::ElementaryFileAdapter(const std::shared_ptr<ElementaryFile> source)
23: mSfi(source->getSfi()),
24 mHeader(source->getHeader() != nullptr ?
25 std::make_shared<FileHeaderAdapter>(source->getHeader()) : nullptr),
26 mData(std::make_shared<FileDataAdapter>(source->getData())) {}
27
28ElementaryFile& ElementaryFileAdapter::setHeader(const std::shared_ptr<FileHeaderAdapter> header)
29{
30 mHeader = header;
31
32 return *this;
33}
34
36{
37 return mSfi;
38}
39
40const std::shared_ptr<FileHeader> ElementaryFileAdapter::getHeader() const
41{
42 return mHeader;
43}
44
45const std::shared_ptr<FileData> ElementaryFileAdapter::getData() const
46{
47 return mData;
48}
49
51{
52 return mSfi == o.mSfi;
53}
54
55bool ElementaryFileAdapter::operator==(const std::shared_ptr<ElementaryFileAdapter> o) const
56{
57 if (o == nullptr) {
58 return false;
59 }
60
61 if (this == o.get()) {
62 return true;
63 }
64
65 return *this == *o.get();
66}
67
68std::ostream& operator<<(std::ostream& os, const ElementaryFileAdapter& fha)
69{
70 os << "ELEMENTARY_FILE_ADAPTER: {"
71 << "SFI = " << fha.mSfi << ", "
72 << "HEADER = " << fha.mHeader << ", "
73 << "DATA = " << fha.mData
74 << "}";
75
76 return os;
77}
78
79std::ostream& operator<<(std::ostream& os, const std::shared_ptr<ElementaryFileAdapter> fha)
80{
81 if (fha == nullptr) {
82 os << "ELEMENTARY_FILE_ADAPTER: {null}";
83 } else {
84 os << *fha.get();
85 }
86
87 return os;
88}
89
90}
91}
92}
const std::shared_ptr< FileHeader > getHeader() const override
const std::shared_ptr< FileData > getData() const override
bool operator==(const ElementaryFileAdapter &o) const
ElementaryFile & setHeader(const std::shared_ptr< FileHeaderAdapter > header)
std::ostream & operator<<(std::ostream &os, const std::shared_ptr< ApduRequestAdapter > ara)