1 // 2 // Copyright (C) 2020 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #pragma once 17 18 #include <vector> 19 20 #include "keymaster/serializable.h" 21 22 namespace cuttlefish { 23 24 /** 25 * A keymaster::Serializable type that refers to multiple other 26 * keymaster::Serializable instances by pointer. When data is serialized or 27 * deserialized, it's delegated to the instances pointed to. 28 * 29 * The serialization format is to put the instances one after the other in 30 * the byte stream. 31 */ 32 class CompositeSerializable : public keymaster::Serializable { 33 public: 34 CompositeSerializable(const std::vector<keymaster::Serializable*>&); 35 36 size_t SerializedSize() const override; 37 uint8_t* Serialize(uint8_t* buf, const uint8_t* end) const override; 38 bool Deserialize(const uint8_t** buf_ptr, const uint8_t* end) override; 39 private: 40 std::vector<keymaster::Serializable*> members_; 41 }; 42 43 } // namespace cuttlefish 44