1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "device/bluetooth/bluetooth_adapter.h"
7 #include "base/stl_util.h"
8 #include "device/bluetooth/bluetooth_device.h"
12 BluetoothAdapter::BluetoothAdapter() {
15 BluetoothAdapter::~BluetoothAdapter() {
16 STLDeleteValues(&devices_
);
19 BluetoothAdapter::DeviceList
BluetoothAdapter::GetDevices() {
20 ConstDeviceList const_devices
=
21 const_cast<const BluetoothAdapter
*>(this)->GetDevices();
24 for (ConstDeviceList::const_iterator i
= const_devices
.begin();
25 i
!= const_devices
.end(); ++i
)
26 devices
.push_back(const_cast<BluetoothDevice
*>(*i
));
31 BluetoothAdapter::ConstDeviceList
BluetoothAdapter::GetDevices() const {
32 ConstDeviceList devices
;
33 for (DevicesMap::const_iterator iter
= devices_
.begin();
34 iter
!= devices_
.end();
36 devices
.push_back(iter
->second
);
41 BluetoothDevice
* BluetoothAdapter::GetDevice(const std::string
& address
) {
42 return const_cast<BluetoothDevice
*>(
43 const_cast<const BluetoothAdapter
*>(this)->GetDevice(address
));
46 const BluetoothDevice
* BluetoothAdapter::GetDevice(
47 const std::string
& address
) const {
48 DevicesMap::const_iterator iter
= devices_
.find(address
);
49 if (iter
!= devices_
.end())