blob: 8239291accff9659ccccd748194c6adc4a74788d [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
Darin Petkov25665aa2012-05-21 14:08:12 +02005#ifndef SHILL_DBUS_PROPERTIES_H_
6#define SHILL_DBUS_PROPERTIES_H_
Darin Petkove0a312e2011-07-20 13:45:28 -07007
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;
Arman Uguray2c39fab2012-12-12 16:56:34 -080020typedef std::map<uint32_t, DBus::Variant> DBusEnumValueMap;
Darin Petkove0a312e2011-07-20 13:45:28 -070021
22class DBusProperties {
23 public:
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040024 static bool GetBool(const DBusPropertiesMap &properties,
25 const std::string &key,
26 bool *value);
27
28 static bool GetInt32(const DBusPropertiesMap &properties,
29 const std::string &key,
30 int32 *value);
Darin Petkove0a312e2011-07-20 13:45:28 -070031
Nathan Williamse9840802012-04-18 18:47:40 -040032 static bool GetObjectPath(const DBusPropertiesMap &properties,
33 const std::string &key,
34 std::string *value);
35
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040036 static bool GetString(const DBusPropertiesMap &properties,
Darin Petkove0a312e2011-07-20 13:45:28 -070037 const std::string &key,
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040038 std::string *value);
Darin Petkove0a312e2011-07-20 13:45:28 -070039
Jason Glasgow9c09e362012-04-18 15:16:29 -040040 static bool GetStrings(const DBusPropertiesMap &properties,
41 const std::string &key,
42 std::vector<std::string> *value);
43
Darin Petkovceb68172011-07-29 14:47:48 -070044 static bool GetUint16(const DBusPropertiesMap &properties,
45 const std::string &key,
46 uint16 *value);
47
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040048 static bool GetUint32(const DBusPropertiesMap &properties,
49 const std::string &key,
50 uint32 *value);
51
Darin Petkove4b27022012-05-16 13:28:50 +020052 static bool GetRpcIdentifiers(const DBusPropertiesMap &properties,
53 const std::string &key,
Darin Petkov9893d9c2012-05-17 15:27:31 -070054 RpcIdentifiers *value);
55
56 static void ConvertPathsToRpcIdentifiers(
57 const std::vector<DBus::Path> &dbus_paths,
58 RpcIdentifiers *rpc_identifiers);
Darin Petkove4b27022012-05-16 13:28:50 +020059
Darin Petkov25665aa2012-05-21 14:08:12 +020060 static void ConvertKeyValueStoreToMap(
61 const KeyValueStore &store, DBusPropertiesMap *properties);
62
Gary Morain610977f2012-05-04 16:03:52 -070063 static std::string KeysToString(const std::map<std::string,
64 ::DBus::Variant> &args);
65
Darin Petkove0a312e2011-07-20 13:45:28 -070066 private:
67 DISALLOW_COPY_AND_ASSIGN(DBusProperties);
68};
69
70} // namespace shill
71
Darin Petkov25665aa2012-05-21 14:08:12 +020072#endif // SHILL_DBUS_PROPERTIES_H_