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

Side by Side Diff: dbus/property.h

Issue 10823301: bluetooth: Create stub manager, adapter and device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 4 months 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
« no previous file with comments | « chromeos/dbus/bluetooth_node_client.cc ('k') | dbus/property.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 20 matching lines...) Expand all
31 // Example: 31 // Example:
32 // class ExampleClient { 32 // class ExampleClient {
33 // public: 33 // public:
34 // struct Properties : public dbus::PropertySet { 34 // struct Properties : public dbus::PropertySet {
35 // dbus::Property<std::string> name; 35 // dbus::Property<std::string> name;
36 // dbus::Property<uint16> version; 36 // dbus::Property<uint16> version;
37 // dbus::Property<dbus::ObjectPath> parent; 37 // dbus::Property<dbus::ObjectPath> parent;
38 // dbus::Property<std::vector<std::string> > children; 38 // dbus::Property<std::vector<std::string> > children;
39 // 39 //
40 // Properties(dbus::ObjectProxy* object_proxy, 40 // Properties(dbus::ObjectProxy* object_proxy,
41 // PropertyChangedCallback callback) 41 // const PropertyChangedCallback callback)
42 // : dbus::PropertySet(object_proxy, "com.example.DBus", callback) { 42 // : dbus::PropertySet(object_proxy, "com.example.DBus", callback) {
43 // RegisterProperty("Name", &name); 43 // RegisterProperty("Name", &name);
44 // RegisterProperty("Version", &version); 44 // RegisterProperty("Version", &version);
45 // RegisterProperty("Parent", &parent); 45 // RegisterProperty("Parent", &parent);
46 // RegisterProperty("Children", &children); 46 // RegisterProperty("Children", &children);
47 // } 47 // }
48 // virtual ~Properties() {} 48 // virtual ~Properties() {}
49 // }; 49 // };
50 // 50 //
51 // The Properties structure requires a pointer to the object proxy of the 51 // The Properties structure requires a pointer to the object proxy of the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // no knowledge of the contained type is required, this method returns 157 // no knowledge of the contained type is required, this method returns
158 // true if its expected type was found, false if not. 158 // true if its expected type was found, false if not.
159 // Implementation provided by specialization. 159 // Implementation provided by specialization.
160 virtual bool PopValueFromReader(MessageReader*) = 0; 160 virtual bool PopValueFromReader(MessageReader*) = 0;
161 161
162 // Method used by PropertySet to append the set value to a MessageWriter, 162 // Method used by PropertySet to append the set value to a MessageWriter,
163 // no knowledge of the contained type is required. 163 // no knowledge of the contained type is required.
164 // Implementation provided by specialization. 164 // Implementation provided by specialization.
165 virtual void AppendSetValueToWriter(MessageWriter* writer) = 0; 165 virtual void AppendSetValueToWriter(MessageWriter* writer) = 0;
166 166
167 // Method used by test and stub implementations of dbus::PropertySet::Set
168 // to replace the property value with the set value without using a
169 // dbus::MessageReader.
170 virtual void ReplaceValueWithSetValue() = 0;
171
167 protected: 172 protected:
168 // Retrieves the associated property set. 173 // Retrieves the associated property set.
169 PropertySet* property_set() { return property_set_; } 174 PropertySet* property_set() { return property_set_; }
170 175
171 private: 176 private:
172 // Pointer to the PropertySet instance that this instance is a member of, 177 // Pointer to the PropertySet instance that this instance is a member of,
173 // no ownership is taken and |property_set_| must outlive this class. 178 // no ownership is taken and |property_set_| must outlive this class.
174 PropertySet* property_set_; 179 PropertySet* property_set_;
175 180
176 // Name of the property. 181 // Name of the property.
(...skipping 19 matching lines...) Expand all
196 // argument specifies the name of the property changed. 201 // argument specifies the name of the property changed.
197 typedef base::Callback<void(const std::string& name)> PropertyChangedCallback; 202 typedef base::Callback<void(const std::string& name)> PropertyChangedCallback;
198 203
199 // Constructs a property set, where |object_proxy| specifies the proxy for 204 // Constructs a property set, where |object_proxy| specifies the proxy for
200 // the/ remote object that these properties are for, care should be taken to 205 // the/ remote object that these properties are for, care should be taken to
201 // ensure that this object does not outlive the lifetime of the proxy; 206 // ensure that this object does not outlive the lifetime of the proxy;
202 // |interface| specifies the D-Bus interface of these properties, and 207 // |interface| specifies the D-Bus interface of these properties, and
203 // |property_changed_callback| specifies the callback for when properties 208 // |property_changed_callback| specifies the callback for when properties
204 // are changed, this may be a NULL callback. 209 // are changed, this may be a NULL callback.
205 PropertySet(ObjectProxy* object_proxy, const std::string& interface, 210 PropertySet(ObjectProxy* object_proxy, const std::string& interface,
206 PropertyChangedCallback property_changed_callback); 211 const PropertyChangedCallback& property_changed_callback);
207 212
208 // Destructor; we don't hold on to any references or memory that needs 213 // Destructor; we don't hold on to any references or memory that needs
209 // explicit clean-up, but clang thinks we might. 214 // explicit clean-up, but clang thinks we might.
210 virtual ~PropertySet(); 215 virtual ~PropertySet();
211 216
212 // Registers a property, generally called from the subclass constructor; 217 // Registers a property, generally called from the subclass constructor;
213 // pass the |name| of the property as used in method calls and signals, 218 // pass the |name| of the property as used in method calls and signals,
214 // and the pointer to the |property| member of the structure. This will 219 // and the pointer to the |property| member of the structure. This will
215 // call the PropertyBase::Init method. 220 // call the PropertyBase::Init method.
216 void RegisterProperty(const std::string& name, PropertyBase* property); 221 void RegisterProperty(const std::string& name, PropertyBase* property);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // Method used by PropertySet to retrieve the value from a MessageReader, 375 // Method used by PropertySet to retrieve the value from a MessageReader,
371 // no knowledge of the contained type is required, this method returns 376 // no knowledge of the contained type is required, this method returns
372 // true if its expected type was found, false if not. 377 // true if its expected type was found, false if not.
373 virtual bool PopValueFromReader(MessageReader*); 378 virtual bool PopValueFromReader(MessageReader*);
374 379
375 // Method used by PropertySet to append the set value to a MessageWriter, 380 // Method used by PropertySet to append the set value to a MessageWriter,
376 // no knowledge of the contained type is required. 381 // no knowledge of the contained type is required.
377 // Implementation provided by specialization. 382 // Implementation provided by specialization.
378 virtual void AppendSetValueToWriter(MessageWriter* writer); 383 virtual void AppendSetValueToWriter(MessageWriter* writer);
379 384
385 // Method used by test and stub implementations of dbus::PropertySet::Set
386 // to replace the property value with the set value without using a
387 // dbus::MessageReader.
388 virtual void ReplaceValueWithSetValue() { value_ = set_value_; }
389
390 // Method used by test and stub implementations to directly set the
391 // value of a property.
392 void ReplaceValue(const T& value) { value_ = value; }
393
380 private: 394 private:
381 // Current cached value of the property. 395 // Current cached value of the property.
382 T value_; 396 T value_;
383 397
384 // Replacement value of the property. 398 // Replacement value of the property.
385 T set_value_; 399 T set_value_;
386 }; 400 };
387 401
388 } // namespace dbus 402 } // namespace dbus
389 403
390 #endif // DBUS_PROPERTY_H_ 404 #endif // DBUS_PROPERTY_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/bluetooth_node_client.cc ('k') | dbus/property.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698