OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DBUS_OBJECT_MANAGER_H_ | 5 #ifndef DBUS_OBJECT_MANAGER_H_ |
6 #define DBUS_OBJECT_MANAGER_H_ | 6 #define DBUS_OBJECT_MANAGER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 | 11 |
| 12 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
12 #include "dbus/object_path.h" | 15 #include "dbus/object_path.h" |
13 #include "dbus/property.h" | 16 #include "dbus/property.h" |
14 | 17 |
15 // Newer D-Bus services implement the Object Manager interface to inform other | 18 // Newer D-Bus services implement the Object Manager interface to inform other |
16 // clients about the objects they export, the properties of those objects, and | 19 // clients about the objects they export, the properties of those objects, and |
17 // notification of changes in the set of available objects: | 20 // notification of changes in the set of available objects: |
18 // http://dbus.freedesktop.org/doc/dbus-specification.html | 21 // http://dbus.freedesktop.org/doc/dbus-specification.html |
19 // #standard-interfaces-objectmanager | 22 // #standard-interfaces-objectmanager |
20 // | 23 // |
21 // This interface is very closely tied to the Properties interface, and uses | 24 // This interface is very closely tied to the Properties interface, and uses |
22 // even more levels of nested dictionaries and variants. In addition to | 25 // even more levels of nested dictionaries and variants. In addition to |
23 // simplifying implementation, since there tends to be a single object manager | 26 // simplifying implementation, since there tends to be a single object manager |
24 // per service, spanning the complete set of objects an interfaces available, | 27 // per service, spanning the complete set of objects an interfaces available, |
25 // the classes implemented here make dealing with this interface simpler. | 28 // the classes implemented here make dealing with this interface simpler. |
26 // | 29 // |
27 // Except where noted, use of this class replaces the need for the code | 30 // Except where noted, use of this class replaces the need for the code |
28 // documented in dbus/property.h | 31 // documented in dbus/property.h |
29 // | 32 // |
30 // Client implementation classes should begin by deriving from the | 33 // Client implementation classes should begin by deriving from the |
31 // dbus::ObjectManager::Interface class, and defining a Properties structure as | 34 // dbus::ObjectManager::Interface class, and defining a Properties structure as |
32 // documented in dbus/property.h. | 35 // documented in dbus/property.h. |
33 // | 36 // |
34 // Example: | 37 // Example: |
35 // class ExampleClient : public dbus::ObjectManager::Interface { | 38 // class ExampleClient : public dbus::ObjectManager::Interface { |
36 // public: | 39 // public: |
37 // struct Properties : public dbus::PropertySet { | 40 // struct Properties : public dbus::PropertySet { |
38 // dbus::Property<std::string> name; | 41 // dbus::Property<std::string> name; |
39 // dbus::Property<uint16> version; | 42 // dbus::Property<uint16_t> version; |
40 // dbus::Property<dbus::ObjectPath> parent; | 43 // dbus::Property<dbus::ObjectPath> parent; |
41 // dbus::Property<std::vector<std::string> > children; | 44 // dbus::Property<std::vector<std::string> > children; |
42 // | 45 // |
43 // Properties(dbus::ObjectProxy* object_proxy, | 46 // Properties(dbus::ObjectProxy* object_proxy, |
44 // const PropertyChangedCallback callback) | 47 // const PropertyChangedCallback callback) |
45 // : dbus::PropertySet(object_proxy, kExampleInterface, callback) { | 48 // : dbus::PropertySet(object_proxy, kExampleInterface, callback) { |
46 // RegisterProperty("Name", &name); | 49 // RegisterProperty("Name", &name); |
47 // RegisterProperty("Version", &version); | 50 // RegisterProperty("Version", &version); |
48 // RegisterProperty("Parent", &parent); | 51 // RegisterProperty("Parent", &parent); |
49 // RegisterProperty("Children", &children); | 52 // RegisterProperty("Children", &children); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 // Note: This should remain the last member so it'll be destroyed and | 355 // Note: This should remain the last member so it'll be destroyed and |
353 // invalidate its weak pointers before any other members are destroyed. | 356 // invalidate its weak pointers before any other members are destroyed. |
354 base::WeakPtrFactory<ObjectManager> weak_ptr_factory_; | 357 base::WeakPtrFactory<ObjectManager> weak_ptr_factory_; |
355 | 358 |
356 DISALLOW_COPY_AND_ASSIGN(ObjectManager); | 359 DISALLOW_COPY_AND_ASSIGN(ObjectManager); |
357 }; | 360 }; |
358 | 361 |
359 } // namespace dbus | 362 } // namespace dbus |
360 | 363 |
361 #endif // DBUS_OBJECT_MANAGER_H_ | 364 #endif // DBUS_OBJECT_MANAGER_H_ |
OLD | NEW |