blob: db678f24014b3cf8b4b0cc05dc93ce9f413bf6d8 [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;
Arman Uguray2c39fab2012-12-12 16:56:34 -080021typedef 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
29 static bool GetInt32(const DBusPropertiesMap &properties,
30 const std::string &key,
31 int32 *value);
Darin Petkove0a312e2011-07-20 13:45:28 -070032
Nathan Williamse9840802012-04-18 18:47:40 -040033 static bool GetObjectPath(const DBusPropertiesMap &properties,
34 const std::string &key,
35 std::string *value);
36
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040037 static bool GetString(const DBusPropertiesMap &properties,
Darin Petkove0a312e2011-07-20 13:45:28 -070038 const std::string &key,
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040039 std::string *value);
Darin Petkove0a312e2011-07-20 13:45:28 -070040
Jason Glasgow9c09e362012-04-18 15:16:29 -040041 static bool GetStrings(const DBusPropertiesMap &properties,
42 const std::string &key,
43 std::vector<std::string> *value);
44
Darin Petkovceb68172011-07-29 14:47:48 -070045 static bool GetUint16(const DBusPropertiesMap &properties,
46 const std::string &key,
47 uint16 *value);
48
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040049 static bool GetUint32(const DBusPropertiesMap &properties,
50 const std::string &key,
51 uint32 *value);
52
Darin Petkove4b27022012-05-16 13:28:50 +020053 static bool GetRpcIdentifiers(const DBusPropertiesMap &properties,
54 const std::string &key,
Darin Petkov9893d9c2012-05-17 15:27:31 -070055 RpcIdentifiers *value);
56
57 static void ConvertPathsToRpcIdentifiers(
58 const std::vector<DBus::Path> &dbus_paths,
59 RpcIdentifiers *rpc_identifiers);
Darin Petkove4b27022012-05-16 13:28:50 +020060
Darin Petkov25665aa2012-05-21 14:08:12 +020061 static void ConvertKeyValueStoreToMap(
62 const KeyValueStore &store, DBusPropertiesMap *properties);
63
Gary Morain610977f2012-05-04 16:03:52 -070064 static std::string KeysToString(const std::map<std::string,
65 ::DBus::Variant> &args);
66
Darin Petkove0a312e2011-07-20 13:45:28 -070067 private:
68 DISALLOW_COPY_AND_ASSIGN(DBusProperties);
69};
70
71} // namespace shill
72
Darin Petkov25665aa2012-05-21 14:08:12 +020073#endif // SHILL_DBUS_PROPERTIES_H_