| 1 |
/* Copyright (c) 2021, 2026, Oracle and/or its affiliates. |
| 2 |
|
| 3 |
This program is free software; you can redistribute it and/or modify |
| 4 |
it under the terms of the GNU General Public License, version 2.0, |
| 5 |
as published by the Free Software Foundation. |
| 6 |
|
| 7 |
This program is designed to work with certain software (including |
| 8 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 9 |
as designated in a particular file or component or in included license |
| 10 |
documentation. The authors of MySQL hereby grant you an additional |
| 11 |
permission to link the program and your derivative works with the |
| 12 |
separately licensed software that they have either included with |
| 13 |
the program or referenced in the documentation. |
| 14 |
|
| 15 |
This program is distributed in the hope that it will be useful, |
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
GNU General Public License, version 2.0, for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU General Public License |
| 21 |
along with this program; if not, write to the Free Software |
| 22 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 23 |
|
| 24 |
#ifndef Data_extension_INCLUDED |
| 25 |
#define Data_extension_INCLUDED |
| 26 |
|
| 27 |
#include "data.h" /* data::Data */ |
| 28 |
|
| 29 |
namespace keyring_common { |
| 30 |
|
| 31 |
namespace data { |
| 32 |
/** |
| 33 |
Data wrapper to include backend specific extensions |
| 34 |
*/ |
| 35 |
|
| 36 |
template <typename Extension> |
| 37 |
class Data_extension final : public Data { |
| 38 |
public: |
| 39 |
/** Constructor */ |
| 40 |
Data_extension(const data::Data data, const Extension ext) |
| 41 |
: data::Data(data), ext_(ext) {} |
| 42 |
Data_extension() : Data_extension(data::Data{}, Extension{}) {} |
| 43 |
Data_extension(const data::Data data) : Data_extension(data, Extension{}) {} |
| 44 |
Data_extension(const Extension ext) : Data_extension(data::Data{}, ext) {} |
| 45 |
|
| 46 |
/** Copy constructor */ |
| 47 |
Data_extension(const Data_extension &src) |
| 48 |
: Data_extension(src.get_data(), src.ext_) {} |
| 49 |
|
| 50 |
/** Assignment operator */ |
| 51 |
Data_extension &operator=(const Data_extension &src) { |
| 52 |
Data::operator=(src); |
| 53 |
ext_ = src.ext_; |
| 54 |
|
| 55 |
return *this; |
| 56 |
} |
| 57 |
|
| 58 |
/* Get data */ |
| 59 |
const data::Data get_data() const override { return Data::get_data(); } |
| 60 |
|
| 61 |
/* Get Metadata extension details */ |
| 62 |
const Extension get_extension() const { return ext_; } |
| 63 |
|
| 64 |
/* Set data */ |
| 65 |
void set_data(const data::Data &data) override { Data::operator=(data); } |
| 66 |
/* Set metadata extension */ |
| 67 |
void set_extension(const Extension ext) { ext_ = ext; } |
| 68 |
|
| 69 |
private: |
| 70 |
/** Backend specific extensions */ |
| 71 |
Extension ext_; |
| 72 |
}; |
| 73 |
|
| 74 |
} // namespace data |
| 75 |
|
| 76 |
} // namespace keyring_common |
| 77 |
|
| 78 |
#endif // !Data_extension_INCLUDED |