Vitaly Buka | 87eb788 | 2015-10-27 22:23:49 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Weave 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 "src/privet/device_ui_kind.h" |
| 6 | |
Paul Westbrook | c078108 | 2015-12-09 01:15:06 -0800 | [diff] [blame] | 7 | #include <unordered_map> |
| 8 | |
Vitaly Buka | 87eb788 | 2015-10-27 22:23:49 -0700 | [diff] [blame] | 9 | #include <base/logging.h> |
| 10 | |
| 11 | namespace weave { |
| 12 | namespace privet { |
| 13 | |
| 14 | std::string GetDeviceUiKind(const std::string& manifest_id) { |
Paul Westbrook | c078108 | 2015-12-09 01:15:06 -0800 | [diff] [blame] | 15 | // Map of device short id to ui device kind |
| 16 | static const std::unordered_map<std::string, std::string> device_kind_map = { |
Vitaly Buka | 34668e7 | 2015-12-15 14:46:47 -0800 | [diff] [blame] | 17 | // clang-format off |
Paul Westbrook | c078108 | 2015-12-09 01:15:06 -0800 | [diff] [blame] | 18 | {"AC", "accessPoint"}, |
| 19 | {"AK", "aggregator"}, |
| 20 | {"AM", "camera"}, |
| 21 | {"AB", "developmentBoard"}, |
| 22 | {"AH", "acHeating"}, |
| 23 | {"AI", "light"}, |
| 24 | {"AO", "lock"}, |
| 25 | {"AE", "printer"}, |
| 26 | {"AF", "scanner"}, |
| 27 | {"AD", "speaker"}, |
| 28 | {"AL", "storage"}, |
| 29 | {"AJ", "toy"}, |
| 30 | {"AA", "vendor"}, |
Vitaly Buka | 34668e7 | 2015-12-15 14:46:47 -0800 | [diff] [blame] | 31 | {"AN", "video"}, |
| 32 | // clang-format on |
Paul Westbrook | c078108 | 2015-12-09 01:15:06 -0800 | [diff] [blame] | 33 | }; |
| 34 | |
Vitaly Buka | 87eb788 | 2015-10-27 22:23:49 -0700 | [diff] [blame] | 35 | CHECK_EQ(5u, manifest_id.size()); |
Paul Westbrook | c078108 | 2015-12-09 01:15:06 -0800 | [diff] [blame] | 36 | std::string short_id = manifest_id.substr(0, 2); |
| 37 | |
| 38 | auto iter = device_kind_map.find(short_id); |
| 39 | if (iter != device_kind_map.end()) |
| 40 | return iter->second; |
| 41 | |
Vitaly Buka | 87eb788 | 2015-10-27 22:23:49 -0700 | [diff] [blame] | 42 | LOG(FATAL) << "Invalid model id: " << manifest_id; |
| 43 | return std::string(); |
| 44 | } |
| 45 | |
| 46 | } // namespace privet |
| 47 | } // namespace weave |