blob: 15722940a75f5f6b9d15a3f3a0f22876858b3b88 [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 Chan7fab8972014-08-10 17:14:46 -070021typedef std::map<uint32_t, 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,
Ben Chan7fab8972014-08-10 17:14:46 -070039 int16_t *value);
Ben Chan0a3a3a52013-07-10 11:34:07 -070040
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040041 static bool GetInt32(const DBusPropertiesMap &properties,
42 const std::string &key,
Ben Chan7fab8972014-08-10 17:14:46 -070043 int32_t *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,
Ben Chan7fab8972014-08-10 17:14:46 -070047 int64_t *value);
Ben Chan0a3a3a52013-07-10 11:34:07 -070048
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
Arman Uguray631c7e42013-07-30 16:41:12 -070057 static bool GetStringmap(const DBusPropertiesMap &properties,
58 const std::string &key,
59 std::map<std::string, std::string> *value);
60
Jason Glasgow9c09e362012-04-18 15:16:29 -040061 static bool GetStrings(const DBusPropertiesMap &properties,
62 const std::string &key,
63 std::vector<std::string> *value);
64
Ben Chan0a3a3a52013-07-10 11:34:07 -070065 static bool GetUint8(const DBusPropertiesMap &properties,
66 const std::string &key,
Ben Chan7fab8972014-08-10 17:14:46 -070067 uint8_t *value);
Ben Chan0a3a3a52013-07-10 11:34:07 -070068
Darin Petkovceb68172011-07-29 14:47:48 -070069 static bool GetUint16(const DBusPropertiesMap &properties,
70 const std::string &key,
Ben Chan7fab8972014-08-10 17:14:46 -070071 uint16_t *value);
Darin Petkovceb68172011-07-29 14:47:48 -070072
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040073 static bool GetUint32(const DBusPropertiesMap &properties,
74 const std::string &key,
Ben Chan7fab8972014-08-10 17:14:46 -070075 uint32_t *value);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040076
Ben Chan0a3a3a52013-07-10 11:34:07 -070077 static bool GetUint64(const DBusPropertiesMap &properties,
78 const std::string &key,
Ben Chan7fab8972014-08-10 17:14:46 -070079 uint64_t *value);
Ben Chan0a3a3a52013-07-10 11:34:07 -070080
Darin Petkove4b27022012-05-16 13:28:50 +020081 static bool GetRpcIdentifiers(const DBusPropertiesMap &properties,
82 const std::string &key,
Darin Petkov9893d9c2012-05-17 15:27:31 -070083 RpcIdentifiers *value);
84
85 static void ConvertPathsToRpcIdentifiers(
86 const std::vector<DBus::Path> &dbus_paths,
87 RpcIdentifiers *rpc_identifiers);
Darin Petkove4b27022012-05-16 13:28:50 +020088
Darin Petkov25665aa2012-05-21 14:08:12 +020089 static void ConvertKeyValueStoreToMap(
90 const KeyValueStore &store, DBusPropertiesMap *properties);
91
Ben Chan0a3a3a52013-07-10 11:34:07 -070092 static std::string KeysToString(const DBusPropertiesMap &properties);
Gary Morain610977f2012-05-04 16:03:52 -070093
Darin Petkove0a312e2011-07-20 13:45:28 -070094 private:
95 DISALLOW_COPY_AND_ASSIGN(DBusProperties);
96};
97
98} // namespace shill
99
Darin Petkov25665aa2012-05-21 14:08:12 +0200100#endif // SHILL_DBUS_PROPERTIES_H_