Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: dbus/property.h

Issue 11364033: dbus: Make it possible to build as shared_library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHROME_DBUS_EXPORT Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PROPERTY_H_ 5 #ifndef DBUS_PROPERTY_H_
6 #define DBUS_PROPERTY_H_ 6 #define DBUS_PROPERTY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "dbus/dbus_export.h"
14 #include "dbus/message.h" 15 #include "dbus/message.h"
15 #include "dbus/object_proxy.h" 16 #include "dbus/object_proxy.h"
16 17
17 // D-Bus objects frequently provide sets of properties accessed via a 18 // D-Bus objects frequently provide sets of properties accessed via a
18 // standard interface of method calls and signals to obtain the current value, 19 // standard interface of method calls and signals to obtain the current value,
19 // set a new value and be notified of changes to the value. Unfortunately this 20 // set a new value and be notified of changes to the value. Unfortunately this
20 // interface makes heavy use of variants and dictionaries of variants. The 21 // interface makes heavy use of variants and dictionaries of variants. The
21 // classes defined here make dealing with properties in a type-safe manner 22 // classes defined here make dealing with properties in a type-safe manner
22 // possible. 23 // possible.
23 // 24 //
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // PropertySet groups a collection of properties for a remote object 188 // PropertySet groups a collection of properties for a remote object
188 // together into a single structure, fixing their types and name such 189 // together into a single structure, fixing their types and name such
189 // that calls made through it are type-safe. 190 // that calls made through it are type-safe.
190 // 191 //
191 // Clients always sub-class this to add the properties, and should always 192 // Clients always sub-class this to add the properties, and should always
192 // provide a constructor that chains up to this and then calls 193 // provide a constructor that chains up to this and then calls
193 // RegisterProperty() for each property defined. 194 // RegisterProperty() for each property defined.
194 // 195 //
195 // After creation, client code should call ConnectSignals() and most likely 196 // After creation, client code should call ConnectSignals() and most likely
196 // GetAll() to seed initial values and update as changes occur. 197 // GetAll() to seed initial values and update as changes occur.
197 class PropertySet { 198 class CHROME_DBUS_EXPORT PropertySet {
198 public: 199 public:
199 // Callback for changes to cached values of properties, either notified 200 // Callback for changes to cached values of properties, either notified
200 // via signal, or as a result of calls to Get() and GetAll(). The |name| 201 // via signal, or as a result of calls to Get() and GetAll(). The |name|
201 // argument specifies the name of the property changed. 202 // argument specifies the name of the property changed.
202 typedef base::Callback<void(const std::string& name)> PropertyChangedCallback; 203 typedef base::Callback<void(const std::string& name)> PropertyChangedCallback;
203 204
204 // Constructs a property set, where |object_proxy| specifies the proxy for 205 // Constructs a property set, where |object_proxy| specifies the proxy for
205 // the/ remote object that these properties are for, care should be taken to 206 // the/ remote object that these properties are for, care should be taken to
206 // ensure that this object does not outlive the lifetime of the proxy; 207 // ensure that this object does not outlive the lifetime of the proxy;
207 // |interface| specifies the D-Bus interface of these properties, and 208 // |interface| specifies the D-Bus interface of these properties, and
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // Where a round-trip is necessary, the Get() method is provided. And to 343 // Where a round-trip is necessary, the Get() method is provided. And to
343 // update the remote object value, the Set() method is also provided; these 344 // update the remote object value, the Set() method is also provided; these
344 // both simply call methods on PropertySet. 345 // both simply call methods on PropertySet.
345 // 346 //
346 // Handling of particular D-Bus types is performed via specialization, 347 // Handling of particular D-Bus types is performed via specialization,
347 // typically the PopValueFromReader() and AppendSetValueToWriter() methods 348 // typically the PopValueFromReader() and AppendSetValueToWriter() methods
348 // will need to be provided, and in rare cases a constructor to provide a 349 // will need to be provided, and in rare cases a constructor to provide a
349 // default value. Specializations for basic D-Bus types, strings, object 350 // default value. Specializations for basic D-Bus types, strings, object
350 // paths and arrays are provided for you. 351 // paths and arrays are provided for you.
351 template <class T> 352 template <class T>
352 class Property : public PropertyBase { 353 class CHROME_DBUS_EXPORT Property : public PropertyBase {
353 public: 354 public:
354 Property() {} 355 Property() {}
355 356
356 // Retrieves the cached value. 357 // Retrieves the cached value.
357 const T& value() const { return value_; } 358 const T& value() const { return value_; }
358 359
359 // Requests an updated value from the remote object incurring a 360 // Requests an updated value from the remote object incurring a
360 // round-trip. |callback| will be called when the new value is available. 361 // round-trip. |callback| will be called when the new value is available.
361 // This may not be implemented by some interfaces. 362 // This may not be implemented by some interfaces.
362 virtual void Get(dbus::PropertySet::GetCallback callback) { 363 virtual void Get(dbus::PropertySet::GetCallback callback) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 MessageWriter* writer); 456 MessageWriter* writer);
456 457
457 template <> bool Property<std::vector<ObjectPath> >::PopValueFromReader( 458 template <> bool Property<std::vector<ObjectPath> >::PopValueFromReader(
458 MessageReader* reader); 459 MessageReader* reader);
459 template <> void Property<std::vector<ObjectPath> >::AppendSetValueToWriter( 460 template <> void Property<std::vector<ObjectPath> >::AppendSetValueToWriter(
460 MessageWriter* writer); 461 MessageWriter* writer);
461 462
462 } // namespace dbus 463 } // namespace dbus
463 464
464 #endif // DBUS_PROPERTY_H_ 465 #endif // DBUS_PROPERTY_H_
OLDNEW
« dbus/dbus_export.h ('K') | « dbus/object_proxy.h ('k') | dbus/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698