Merge lp:~thomas-voss/dbus-cpp/add_service_with_custom_name into lp:dbus-cpp

Proposed by Thomas Voß
Status: Rejected
Rejected by: Thomas Voß
Proposed branch: lp:~thomas-voss/dbus-cpp/add_service_with_custom_name
Merge into: lp:dbus-cpp
Diff against target: 178 lines (+32/-57)
5 files modified
debian/changelog (+0/-10)
include/core/dbus/impl/property.h (+1/-5)
include/core/dbus/service.h (+30/-5)
tests/service_test.cpp (+1/-25)
tests/test_service.h (+0/-12)
To merge this branch: bzr merge lp:~thomas-voss/dbus-cpp/add_service_with_custom_name
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Manuel de la Peña (community) Approve
Pete Woods (community) Approve
Review via email: mp+225332@code.launchpad.net

Commit message

Allow for adding services without the need to describe the service with a type.
Allow for consumers of the library to specify a policy for announcing property changes, defaults to a policy that does not allow changes to maintain stable behavior.

Description of the change

Allow for adding services without the need to describe the service with a type.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
61. By Thomas Voß

Ensure that caching logic for service instances is correct.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
62. By Thomas Voß

Add property change announcement policies.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
63. By Thomas Voß

Adjust symbols to account for new functions.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) wrote :

Please add a couple of assertions around the behaviour of announcing policy. Other than that, looks good. :)

review: Needs Fixing
64. By Thomas Voß

Revert inlined changes.
Add check for Property::Changed signal being emitted.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
65. By Thomas Voß

[ Ubuntu daily release ]
* New rebuild forced
[ Antti Kaijanmäki ]
* Fix read-only property PropertiesChanged updates. (LP: #1339589)

Revision history for this message
Thomas Voß (thomas-voss) wrote :

> Please add a couple of assertions around the behaviour of announcing policy.
> Other than that, looks good. :)

Added a simple test for a signal being invoked in TEST_F(Service, AddingServiceAndObjectAndCallingIntoItSucceeds).

Revision history for this message
Pete Woods (pete-woods) wrote :

> > Please add a couple of assertions around the behaviour of announcing policy.
> > Other than that, looks good. :)
>
> Added a simple test for a signal being invoked in TEST_F(Service,
> AddingServiceAndObjectAndCallingIntoItSucceeds).

Awesome stuff.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Manuel de la Peña (mandel) :
review: Approve
66. By Thomas Voß

Revert changes for adding property changed signal emission policies.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

66. By Thomas Voß

Revert changes for adding property changed signal emission policies.

65. By Thomas Voß

[ Ubuntu daily release ]
* New rebuild forced
[ Antti Kaijanmäki ]
* Fix read-only property PropertiesChanged updates. (LP: #1339589)

64. By Thomas Voß

Revert inlined changes.
Add check for Property::Changed signal being emitted.

63. By Thomas Voß

Adjust symbols to account for new functions.

62. By Thomas Voß

Add property change announcement policies.

61. By Thomas Voß

Ensure that caching logic for service instances is correct.

60. By Thomas Voß

Allow for adding services without the need to describe the service with a type.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-07-09 10:15:33 +0000
3+++ debian/changelog 2014-07-15 22:21:04 +0000
4@@ -1,13 +1,3 @@
5-dbus-cpp (3.0.0+14.10.20140709.2-0ubuntu1) utopic; urgency=low
6-
7- [ Ubuntu daily release ]
8- * New rebuild forced
9-
10- [ Antti Kaijanmäki ]
11- * Fix read-only property PropertiesChanged updates. (LP: #1339589)
12-
13- -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 09 Jul 2014 10:15:33 +0000
14-
15 dbus-cpp (3.0.0+14.10.20140612-0ubuntu1) utopic; urgency=low
16
17 [ Manuel de la Peña ]
18
19=== modified file 'include/core/dbus/impl/property.h'
20--- include/core/dbus/impl/property.h 2014-06-10 08:44:17 +0000
21+++ include/core/dbus/impl/property.h 2014-07-15 22:21:04 +0000
22@@ -161,14 +161,10 @@
23 try
24 {
25 auto value = arg.as<typename PropertyType::ValueType>();
26- Super::set(value);
27- }
28- catch (const std::exception &e){
29- std::cout << __PRETTY_FUNCTION__ << ": " << e.what() << std::endl;
30+ set(value);
31 }
32 catch (...)
33 {
34- std::cout << __PRETTY_FUNCTION__ << ": " << "Unknown exception." << std::endl;
35 }
36 }
37 }
38
39=== modified file 'include/core/dbus/service.h'
40--- include/core/dbus/service.h 2013-11-27 18:57:42 +0000
41+++ include/core/dbus/service.h 2014-07-15 22:21:04 +0000
42@@ -60,28 +60,53 @@
43 typedef std::shared_ptr<Service> Ptr;
44
45 /**
46- * @brief Exposes a service on the bus.
47+ * @brief Exposes a service on the bus, trying to acquire the given name.
48 * @returns An instance of Service or nullptr in case of errors.
49 * @tparam Interface Needs to a model of concept Service.
50 * @param [in] connection Bus to expose the service upon.
51+ * @param [in] name The name to acquire for this service.
52 * @param [in] flags Flags specifying behavior when requesting a name on the bus.
53 */
54- template<typename Interface>
55 inline static Ptr add_service(
56 const Bus::Ptr& connection,
57+ const std::string& name,
58 const Bus::RequestNameFlag& flags =
59 Bus::RequestNameFlag::do_not_queue |
60 Bus::RequestNameFlag::replace_existing)
61 {
62- static Ptr instance(
63+ Ptr instance(
64 new Service(
65- connection,
66- traits::Service<Interface>::interface_name(),
67+ connection,
68+ name,
69 flags));
70 return instance;
71 }
72
73 /**
74+ * @brief Exposes a service on the bus.
75+ * @returns An instance of Service or nullptr in case of errors.
76+ * @tparam Interface Needs to a model of concept Service.
77+ * @param [in] connection Bus to expose the service upon.
78+ * @param [in] flags Flags specifying behavior when requesting a name on the bus.
79+ */
80+ template<typename Interface>
81+ inline static Ptr add_service(
82+ const Bus::Ptr& connection,
83+ const Bus::RequestNameFlag& flags =
84+ Bus::RequestNameFlag::do_not_queue |
85+ Bus::RequestNameFlag::replace_existing)
86+ {
87+ static Ptr instance
88+ {
89+ add_service(connection,
90+ traits::Service<Interface>::interface_name(),
91+ flags)
92+ };
93+
94+ return instance;
95+ }
96+
97+ /**
98 * @brief Provides access to a service on the bus via a proxy object.
99 * @returns An instance of Service or nullptr in case of errors.
100 * @tparam Interface Needs to be a model of concept Service.
101
102=== modified file 'tests/service_test.cpp'
103--- tests/service_test.cpp 2014-06-10 08:44:17 +0000
104+++ tests/service_test.cpp 2014-07-15 22:21:04 +0000
105@@ -82,25 +82,11 @@
106 auto writable_property = skeleton->get_property<test::Service::Properties::Dummy>();
107 writable_property->set(expected_value);
108
109- auto readonly_property = skeleton->get_property<test::Service::Properties::ReadOnly>();
110- readonly_property->set(7);
111-
112- skeleton->install_method_handler<test::Service::Method>([bus, skeleton, &readonly_property, expected_value](const dbus::Message::Ptr& msg)
113+ skeleton->install_method_handler<test::Service::Method>([bus, skeleton, expected_value](const dbus::Message::Ptr& msg)
114 {
115 auto reply = dbus::Message::make_method_return(msg);
116 reply->writer() << expected_value;
117 bus->send(reply);
118-
119- readonly_property->set(expected_value);
120- auto changed_signal = skeleton->get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>();
121- core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType
122- args("this.is.unlikely.to.exist.Service",
123- {{test::Service::Properties::ReadOnly::name(),
124- core::dbus::types::TypedVariant<test::Service::Properties::ReadOnly::ValueType>(expected_value)}},
125- {});
126- skeleton->emit_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged, core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType>(args);
127- changed_signal->emit(args);
128-
129 skeleton->emit_signal<test::Service::Signals::Dummy, int64_t>(expected_value);
130 });
131
132@@ -132,14 +118,6 @@
133 {
134 std::cout << "Dummy property changed: " << d << std::endl;
135 });
136-
137- auto readonly_property = stub->get_property<test::Service::Properties::ReadOnly>();
138- EXPECT_EQ(readonly_property->get(), 7);
139- std::uint32_t changed_value = 0;
140- readonly_property->changed().connect([&changed_value](std::uint32_t value){
141- changed_value = value;
142- });
143-
144 auto signal = stub->get_signal<test::Service::Signals::Dummy>();
145 int64_t received_signal_value = -1;
146 signal->connect([bus, &received_signal_value](const int32_t& value)
147@@ -166,8 +144,6 @@
148 t.join();
149
150 EXPECT_EQ(expected_value, received_signal_value);
151- EXPECT_EQ(expected_value, readonly_property->get());
152- EXPECT_EQ(changed_value, expected_value);
153
154 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
155 };
156
157=== modified file 'tests/test_service.h'
158--- tests/test_service.h 2014-06-03 08:25:03 +0000
159+++ tests/test_service.h 2014-07-15 22:21:04 +0000
160@@ -68,18 +68,6 @@
161 static const bool readable = true;
162 static const bool writable = true;
163 };
164-
165- struct ReadOnly
166- {
167- inline static std::string name()
168- {
169- return "ReadOnly";
170- };
171- typedef Service Interface;
172- typedef std::uint32_t ValueType;
173- static const bool readable = true;
174- static const bool writable = false;
175- };
176 };
177
178 struct Interfaces

Subscribers

People subscribed via source and target branches