shill: Add Technology class
Move Technology enum out into its own class, and create static
functions for converting between these and strings.
BUG=chromium-os:20114
TEST=Rerun unit tests
Change-Id: I9e3aea44e5d0b14d844328f023b01d7f8ea04c42
Reviewed-on: http://gerrit.chromium.org/gerrit/8204
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/technology.cc b/technology.cc
new file mode 100644
index 0000000..1be4184
--- /dev/null
+++ b/technology.cc
@@ -0,0 +1,42 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "shill/technology.h"
+
+#include <string>
+
+#include <chromeos/dbus/service_constants.h>
+
+namespace shill {
+
+using std::string;
+
+const char Technology::kUnknownName[] = "Unknown";
+
+
+Technology::Identifier Technology::IdentifierFromName(const std::string &name) {
+ if (name == flimflam::kTypeEthernet) {
+ return kEthernet;
+ } else if (name == flimflam::kTypeWifi) {
+ return kWifi;
+ } else if (name == flimflam::kTypeCellular) {
+ return kCellular;
+ } else {
+ return kUnknown;
+ }
+}
+
+std::string Technology::NameFromIdentifier(Technology::Identifier id) {
+ if (id == kEthernet) {
+ return flimflam::kTypeEthernet;
+ } else if (id == kWifi) {
+ return flimflam::kTypeWifi;
+ } else if (id == kCellular) {
+ return flimflam::kTypeCellular;
+ } else {
+ return kUnknownName;
+ }
+}
+
+} // namespace shill