OLD | NEW |
---|---|
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 #include <utility> | |
11 #include <vector> | |
10 | 12 |
11 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
12 #include "base/bind.h" | 14 #include "base/bind.h" |
13 #include "base/callback.h" | 15 #include "base/callback.h" |
14 #include "dbus/dbus_export.h" | 16 #include "dbus/dbus_export.h" |
15 #include "dbus/message.h" | 17 #include "dbus/message.h" |
16 #include "dbus/object_proxy.h" | 18 #include "dbus/object_proxy.h" |
17 | 19 |
18 // D-Bus objects frequently provide sets of properties accessed via a | 20 // D-Bus objects frequently provide sets of properties accessed via a |
19 // standard interface of method calls and signals to obtain the current value, | 21 // standard interface of method calls and signals to obtain the current value, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 // if (property_name == properties.version.name()) { | 153 // if (property_name == properties.version.name()) { |
152 // // Handle version property changing | 154 // // Handle version property changing |
153 // } | 155 // } |
154 // } | 156 // } |
155 const std::string& name() const { return name_; } | 157 const std::string& name() const { return name_; } |
156 | 158 |
157 // Method used by PropertySet to retrieve the value from a MessageReader, | 159 // Method used by PropertySet to retrieve the value from a MessageReader, |
158 // no knowledge of the contained type is required, this method returns | 160 // no knowledge of the contained type is required, this method returns |
159 // true if its expected type was found, false if not. | 161 // true if its expected type was found, false if not. |
160 // Implementation provided by specialization. | 162 // Implementation provided by specialization. |
161 virtual bool PopValueFromReader(MessageReader*) = 0; | 163 virtual bool PopValueFromReader(MessageReader* reader) = 0; |
162 | 164 |
163 // Method used by PropertySet to append the set value to a MessageWriter, | 165 // Method used by PropertySet to append the set value to a MessageWriter, |
164 // no knowledge of the contained type is required. | 166 // no knowledge of the contained type is required. |
165 // Implementation provided by specialization. | 167 // Implementation provided by specialization. |
166 virtual void AppendSetValueToWriter(MessageWriter* writer) = 0; | 168 virtual void AppendSetValueToWriter(MessageWriter* writer) = 0; |
167 | 169 |
168 // Method used by test and stub implementations of dbus::PropertySet::Set | 170 // Method used by test and stub implementations of dbus::PropertySet::Set |
169 // to replace the property value with the set value without using a | 171 // to replace the property value with the set value without using a |
170 // dbus::MessageReader. | 172 // dbus::MessageReader. |
171 virtual void ReplaceValueWithSetValue() = 0; | 173 virtual void ReplaceValueWithSetValue() = 0; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 void RegisterProperty(const std::string& name, PropertyBase* property); | 224 void RegisterProperty(const std::string& name, PropertyBase* property); |
223 | 225 |
224 // Connects property change notification signals to the object, generally | 226 // Connects property change notification signals to the object, generally |
225 // called immediately after the object is created and before calls to other | 227 // called immediately after the object is created and before calls to other |
226 // methods. Sub-classes may override to use different D-Bus signals. | 228 // methods. Sub-classes may override to use different D-Bus signals. |
227 virtual void ConnectSignals(); | 229 virtual void ConnectSignals(); |
228 | 230 |
229 // Methods connected by ConnectSignals() and called by dbus:: when | 231 // Methods connected by ConnectSignals() and called by dbus:: when |
230 // a property is changed. Sub-classes may override if the property | 232 // a property is changed. Sub-classes may override if the property |
231 // changed signal provides different arguments. | 233 // changed signal provides different arguments. |
232 virtual void ChangedReceived(Signal*); | 234 virtual void ChangedReceived(Signal* signal); |
233 virtual void ChangedConnected(const std::string& interface_name, | 235 virtual void ChangedConnected(const std::string& interface_name, |
234 const std::string& signal_name, | 236 const std::string& signal_name, |
235 bool success); | 237 bool success); |
236 | 238 |
237 // Callback for Get() method, |success| indicates whether or not the | 239 // Callback for Get() method, |success| indicates whether or not the |
238 // value could be retrived, if true the new value can be obtained by | 240 // value could be retrived, if true the new value can be obtained by |
239 // calling value() on the property. | 241 // calling value() on the property. |
240 typedef base::Callback<void(bool success)> GetCallback; | 242 typedef base::Callback<void(bool success)> GetCallback; |
241 | 243 |
242 // Requests an updated value from the remote object for |property| | 244 // Requests an updated value from the remote object for |property| |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 // request, however the new value may not be available depending on the | 371 // request, however the new value may not be available depending on the |
370 // remote object. | 372 // remote object. |
371 virtual void Set(const T& value, dbus::PropertySet::SetCallback callback) { | 373 virtual void Set(const T& value, dbus::PropertySet::SetCallback callback) { |
372 set_value_ = value; | 374 set_value_ = value; |
373 property_set()->Set(this, callback); | 375 property_set()->Set(this, callback); |
374 } | 376 } |
375 | 377 |
376 // Method used by PropertySet to retrieve the value from a MessageReader, | 378 // Method used by PropertySet to retrieve the value from a MessageReader, |
377 // no knowledge of the contained type is required, this method returns | 379 // no knowledge of the contained type is required, this method returns |
378 // true if its expected type was found, false if not. | 380 // true if its expected type was found, false if not. |
379 bool PopValueFromReader(MessageReader*) override; | 381 bool PopValueFromReader(MessageReader* reader) override; |
380 | 382 |
381 // Method used by PropertySet to append the set value to a MessageWriter, | 383 // Method used by PropertySet to append the set value to a MessageWriter, |
382 // no knowledge of the contained type is required. | 384 // no knowledge of the contained type is required. |
383 // Implementation provided by specialization. | 385 // Implementation provided by specialization. |
384 void AppendSetValueToWriter(MessageWriter* writer) override; | 386 void AppendSetValueToWriter(MessageWriter* writer) override; |
385 | 387 |
386 // Method used by test and stub implementations of dbus::PropertySet::Set | 388 // Method used by test and stub implementations of dbus::PropertySet::Set |
387 // to replace the property value with the set value without using a | 389 // to replace the property value with the set value without using a |
388 // dbus::MessageReader. | 390 // dbus::MessageReader. |
389 void ReplaceValueWithSetValue() override { | 391 void ReplaceValueWithSetValue() override { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 template <> void Property<std::vector<ObjectPath> >::AppendSetValueToWriter( | 480 template <> void Property<std::vector<ObjectPath> >::AppendSetValueToWriter( |
479 MessageWriter* writer); | 481 MessageWriter* writer); |
480 extern template class Property<std::vector<ObjectPath> >; | 482 extern template class Property<std::vector<ObjectPath> >; |
481 | 483 |
482 template <> bool Property<std::vector<uint8> >::PopValueFromReader( | 484 template <> bool Property<std::vector<uint8> >::PopValueFromReader( |
483 MessageReader* reader); | 485 MessageReader* reader); |
484 template <> void Property<std::vector<uint8> >::AppendSetValueToWriter( | 486 template <> void Property<std::vector<uint8> >::AppendSetValueToWriter( |
485 MessageWriter* writer); | 487 MessageWriter* writer); |
486 extern template class Property<std::vector<uint8> >; | 488 extern template class Property<std::vector<uint8> >; |
487 | 489 |
490 template <> | |
491 bool Property<std::map<std::string, std::string>>::PopValueFromReader( | |
492 MessageReader* reader); | |
493 template <> | |
494 void Property<std::map<std::string, std::string>>::AppendSetValueToWriter( | |
495 MessageWriter* writer); | |
496 extern template class Property<std::map<std::string, std::string>>; | |
497 | |
498 template <> | |
499 bool Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: | |
500 PopValueFromReader(MessageReader* reader); | |
501 template <> | |
502 void Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: | |
503 AppendSetValueToWriter(MessageWriter* writer); | |
504 extern template class Property< | |
505 std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; | |
hashimoto
2015/02/06 07:45:12
It's unfortunate property.h should be changed to s
dtapuska
2015/02/06 15:56:01
Acknowledged.
| |
506 | |
488 } // namespace dbus | 507 } // namespace dbus |
489 | 508 |
490 #endif // DBUS_PROPERTY_H_ | 509 #endif // DBUS_PROPERTY_H_ |
OLD | NEW |