1 // Copyright 2020 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef CORE_INTERNAL_MEDIUMS_MEDIUMS_H_ 16 #define CORE_INTERNAL_MEDIUMS_MEDIUMS_H_ 17 18 #include "core/internal/mediums/ble.h" 19 #include "core/internal/mediums/bluetooth_classic.h" 20 #include "core/internal/mediums/bluetooth_radio.h" 21 #include "core/internal/mediums/webrtc.h" 22 #include "core/internal/mediums/wifi_lan.h" 23 24 namespace location { 25 namespace nearby { 26 namespace connections { 27 28 // Facilitates convenient and reliable usage of various wireless mediums. 29 class Mediums { 30 public: 31 Mediums() = default; 32 ~Mediums() = default; 33 34 // Returns a handle to the Bluetooth radio. 35 BluetoothRadio& GetBluetoothRadio(); 36 37 // Returns a handle to the Bluetooth Classic medium. 38 BluetoothClassic& GetBluetoothClassic(); 39 40 // Returns a handle to the Ble medium. 41 Ble& GetBle(); 42 43 // Returns a handle to the Wifi-Lan medium. 44 WifiLan& GetWifiLan(); 45 46 // Returns a handle to the WebRtc medium. 47 mediums::WebRtc& GetWebRtc(); 48 49 private: 50 // The order of declaration is critical for both construction and 51 // destruction. 52 // 53 // 1) Construction: The individual mediums have a dependency on the 54 // corresponding radio, so the radio must be initialized first. 55 // 56 // 2) Destruction: The individual mediums should be shut down before the 57 // corresponding radio. 58 BluetoothRadio bluetooth_radio_; 59 BluetoothClassic bluetooth_classic_{bluetooth_radio_}; 60 Ble ble_{bluetooth_radio_}; 61 WifiLan wifi_lan_; 62 mediums::WebRtc webrtc_; 63 }; 64 65 } // namespace connections 66 } // namespace nearby 67 } // namespace location 68 69 #endif // CORE_INTERNAL_MEDIUMS_MEDIUMS_H_ 70