1 /* 2 * Copyright 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 <string> 19 20 #include "common/byte_array.h" 21 #include "hci/address.h" 22 #include "storage/config_cache.h" 23 #include "storage/device.h" 24 25 namespace bluetooth { 26 namespace storage { 27 28 class AdapterConfig { 29 public: 30 AdapterConfig(ConfigCache* config, ConfigCache* memory_only_config, std::string section); 31 32 // for move 33 AdapterConfig(AdapterConfig&& other) noexcept = default; 34 AdapterConfig& operator=(AdapterConfig&& other) noexcept = default; 35 36 // for copy 37 AdapterConfig(const AdapterConfig& other) noexcept = default; 38 AdapterConfig& operator=(const AdapterConfig& other) noexcept = default; 39 40 // operators 41 bool operator==(const AdapterConfig& other) const { 42 return config_ == other.config_ && memory_only_config_ == other.memory_only_config_ && section_ == other.section_; 43 } 44 bool operator!=(const AdapterConfig& other) const { 45 return !(*this == other); 46 } 47 bool operator<(const AdapterConfig& other) const { 48 return config_ < other.config_ && memory_only_config_ < other.memory_only_config_ && section_ < other.section_; 49 } 50 bool operator>(const AdapterConfig& rhs) const { 51 return (rhs < *this); 52 } 53 bool operator<=(const AdapterConfig& rhs) const { 54 return !(*this > rhs); 55 } 56 bool operator>=(const AdapterConfig& rhs) const { 57 return !(*this < rhs); 58 } 59 60 private: 61 ConfigCache* config_; 62 ConfigCache* memory_only_config_; 63 std::string section_; 64 65 public: 66 GENERATE_PROPERTY_GETTER_SETTER_REMOVER(Address, hci::Address, "Address"); 67 GENERATE_PROPERTY_GETTER_SETTER_REMOVER(LeIdentityResolvingKey, common::ByteArray<16>, "LE_LOCAL_KEY_IRK"); 68 GENERATE_PROPERTY_GETTER_SETTER_REMOVER(LegacyScanMode, hci::LegacyScanMode, "ScanMode"); 69 GENERATE_PROPERTY_GETTER_SETTER_REMOVER(DiscoveryTimeoutSeconds, int, "DiscoveryTimeout"); 70 }; 71 72 } // namespace storage 73 } // namespace bluetooth