blob: 776b72c1e8058f59cda7b93764ea00294a78ba3f [file] [log] [blame]
Darin Petkove4b27022012-05-16 13:28:50 +02001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkove0a312e2011-07-20 13:45:28 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_DBUS_PROPERTIES_
6#define SHILL_DBUS_PROPERTIES_
7
8#include <map>
9#include <string>
Jason Glasgow9c09e362012-04-18 15:16:29 -040010#include <vector>
Darin Petkove0a312e2011-07-20 13:45:28 -070011
12#include <base/basictypes.h>
13#include <dbus-c++/types.h>
14
Darin Petkove4b27022012-05-16 13:28:50 +020015#include "shill/accessor_interface.h"
16
Darin Petkove0a312e2011-07-20 13:45:28 -070017namespace shill {
18
19typedef std::map<std::string, DBus::Variant> DBusPropertiesMap;
20
21class DBusProperties {
22 public:
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040023 static bool GetBool(const DBusPropertiesMap &properties,
24 const std::string &key,
25 bool *value);
26
27 static bool GetInt32(const DBusPropertiesMap &properties,
28 const std::string &key,
29 int32 *value);
Darin Petkove0a312e2011-07-20 13:45:28 -070030
Nathan Williamse9840802012-04-18 18:47:40 -040031 static bool GetObjectPath(const DBusPropertiesMap &properties,
32 const std::string &key,
33 std::string *value);
34
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040035 static bool GetString(const DBusPropertiesMap &properties,
Darin Petkove0a312e2011-07-20 13:45:28 -070036 const std::string &key,
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040037 std::string *value);
Darin Petkove0a312e2011-07-20 13:45:28 -070038
Jason Glasgow9c09e362012-04-18 15:16:29 -040039 static bool GetStrings(const DBusPropertiesMap &properties,
40 const std::string &key,
41 std::vector<std::string> *value);
42
Darin Petkovceb68172011-07-29 14:47:48 -070043 static bool GetUint16(const DBusPropertiesMap &properties,
44 const std::string &key,
45 uint16 *value);
46
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040047 static bool GetUint32(const DBusPropertiesMap &properties,
48 const std::string &key,
49 uint32 *value);
50
Darin Petkove4b27022012-05-16 13:28:50 +020051 static bool GetRpcIdentifiers(const DBusPropertiesMap &properties,
52 const std::string &key,
Darin Petkov9893d9c2012-05-17 15:27:31 -070053 RpcIdentifiers *value);
54
55 static void ConvertPathsToRpcIdentifiers(
56 const std::vector<DBus::Path> &dbus_paths,
57 RpcIdentifiers *rpc_identifiers);
Darin Petkove4b27022012-05-16 13:28:50 +020058
Gary Morain610977f2012-05-04 16:03:52 -070059 static std::string KeysToString(const std::map<std::string,
60 ::DBus::Variant> &args);
61
Darin Petkove0a312e2011-07-20 13:45:28 -070062 private:
63 DISALLOW_COPY_AND_ASSIGN(DBusProperties);
64};
65
66} // namespace shill
67
68#endif // SHILL_DBUS_PROPERTIES_