blob: 9513ba76f419a7e0a22cb69e3f03f4ca6c21adf1 [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"
Gaurav Shah3df47b72013-03-22 15:40:41 -070016#include "shill/dbus_variant_gmock_printer.h"
Darin Petkove4b27022012-05-16 13:28:50 +020017
Darin Petkove0a312e2011-07-20 13:45:28 -070018namespace shill {
19
20typedef std::map<std::string, DBus::Variant> DBusPropertiesMap;
Ben Chan0a3a3a52013-07-10 11:34:07 -070021typedef std::map<uint32, DBus::Variant> DBusEnumValueMap;
Darin Petkove0a312e2011-07-20 13:45:28 -070022
23class DBusProperties {
24 public:
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040025 static bool GetBool(const DBusPropertiesMap &properties,
26 const std::string &key,
27 bool *value);
28
Ben Chan0a3a3a52013-07-10 11:34:07 -070029 static bool GetDBusPropertiesMap(const DBusPropertiesMap &properties,
30 const std::string &key,
31 DBusPropertiesMap *value);
32
33 static bool GetDouble(const DBusPropertiesMap &properties,
34 const std::string &key,
35 double *value);
36
37 static bool GetInt16(const DBusPropertiesMap &properties,
38 const std::string &key,
39 int16 *value);
40
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040041 static bool GetInt32(const DBusPropertiesMap &properties,
42 const std::string &key,
43 int32 *value);
Darin Petkove0a312e2011-07-20 13:45:28 -070044
Ben Chan0a3a3a52013-07-10 11:34:07 -070045 static bool GetInt64(const DBusPropertiesMap &properties,
46 const std::string &key,
47 int64 *value);
48
Nathan Williamse9840802012-04-18 18:47:40 -040049 static bool GetObjectPath(const DBusPropertiesMap &properties,
50 const std::string &key,
Ben Chan0a3a3a52013-07-10 11:34:07 -070051 DBus::Path *value);
Nathan Williamse9840802012-04-18 18:47:40 -040052
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040053 static bool GetString(const DBusPropertiesMap &properties,
Darin Petkove0a312e2011-07-20 13:45:28 -070054 const std::string &key,
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040055 std::string *value);
Darin Petkove0a312e2011-07-20 13:45:28 -070056
Jason Glasgow9c09e362012-04-18 15:16:29 -040057 static bool GetStrings(const DBusPropertiesMap &properties,
58 const std::string &key,
59 std::vector<std::string> *value);
60
Ben Chan0a3a3a52013-07-10 11:34:07 -070061 static bool GetUint8(const DBusPropertiesMap &properties,
62 const std::string &key,
63 uint8 *value);
64
Darin Petkovceb68172011-07-29 14:47:48 -070065 static bool GetUint16(const DBusPropertiesMap &properties,
66 const std::string &key,
67 uint16 *value);
68
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040069 static bool GetUint32(const DBusPropertiesMap &properties,
70 const std::string &key,
71 uint32 *value);
72
Ben Chan0a3a3a52013-07-10 11:34:07 -070073 static bool GetUint64(const DBusPropertiesMap &properties,
74 const std::string &key,
75 uint64 *value);
76
Darin Petkove4b27022012-05-16 13:28:50 +020077 static bool GetRpcIdentifiers(const DBusPropertiesMap &properties,
78 const std::string &key,
Darin Petkov9893d9c2012-05-17 15:27:31 -070079 RpcIdentifiers *value);
80
81 static void ConvertPathsToRpcIdentifiers(
82 const std::vector<DBus::Path> &dbus_paths,
83 RpcIdentifiers *rpc_identifiers);
Darin Petkove4b27022012-05-16 13:28:50 +020084
Darin Petkov25665aa2012-05-21 14:08:12 +020085 static void ConvertKeyValueStoreToMap(
86 const KeyValueStore &store, DBusPropertiesMap *properties);
87
Ben Chan0a3a3a52013-07-10 11:34:07 -070088 static std::string KeysToString(const DBusPropertiesMap &properties);
Gary Morain610977f2012-05-04 16:03:52 -070089
Darin Petkove0a312e2011-07-20 13:45:28 -070090 private:
91 DISALLOW_COPY_AND_ASSIGN(DBusProperties);
92};
93
94} // namespace shill
95
Darin Petkov25665aa2012-05-21 14:08:12 +020096#endif // SHILL_DBUS_PROPERTIES_H_