• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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.
4 
5 #include "device/nfc/nfc_adapter.h"
6 
7 #include "base/stl_util.h"
8 #include "device/nfc/nfc_peer.h"
9 #include "device/nfc/nfc_tag.h"
10 
11 namespace device {
12 
NfcAdapter()13 NfcAdapter::NfcAdapter() {
14 }
15 
~NfcAdapter()16 NfcAdapter::~NfcAdapter() {
17   STLDeleteValues(&peers_);
18   STLDeleteValues(&tags_);
19 }
20 
GetPeers(PeerList * peer_list) const21 void NfcAdapter::GetPeers(PeerList* peer_list) const {
22   peer_list->clear();
23   for (PeersMap::const_iterator iter = peers_.begin();
24        iter != peers_.end(); ++iter) {
25     peer_list->push_back(iter->second);
26   }
27 }
28 
GetTags(TagList * tag_list) const29 void NfcAdapter::GetTags(TagList* tag_list) const {
30   tag_list->clear();
31   for (TagsMap::const_iterator iter = tags_.begin();
32        iter != tags_.end(); ++iter) {
33     tag_list->push_back(iter->second);
34   }
35 }
36 
GetPeer(const std::string & identifier) const37 NfcPeer* NfcAdapter::GetPeer(const std::string& identifier) const {
38   PeersMap::const_iterator iter = peers_.find(identifier);
39   if (iter != peers_.end())
40     return iter->second;
41   return NULL;
42 }
43 
GetTag(const std::string & identifier) const44 NfcTag* NfcAdapter::GetTag(const std::string& identifier) const {
45   TagsMap::const_iterator iter = tags_.find(identifier);
46   if (iter != tags_.end())
47     return iter->second;
48   return NULL;
49 }
50 
51 }  // namespace device
52