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
=== modified file 'debian/changelog'
--- debian/changelog 2014-07-09 10:15:33 +0000
+++ debian/changelog 2014-07-15 22:21:04 +0000
@@ -1,13 +1,3 @@
1dbus-cpp (3.0.0+14.10.20140709.2-0ubuntu1) utopic; urgency=low
2
3 [ Ubuntu daily release ]
4 * New rebuild forced
5
6 [ Antti Kaijanmäki ]
7 * Fix read-only property PropertiesChanged updates. (LP: #1339589)
8
9 -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 09 Jul 2014 10:15:33 +0000
10
11dbus-cpp (3.0.0+14.10.20140612-0ubuntu1) utopic; urgency=low1dbus-cpp (3.0.0+14.10.20140612-0ubuntu1) utopic; urgency=low
122
13 [ Manuel de la Peña ]3 [ Manuel de la Peña ]
144
=== modified file 'include/core/dbus/impl/property.h'
--- include/core/dbus/impl/property.h 2014-06-10 08:44:17 +0000
+++ include/core/dbus/impl/property.h 2014-07-15 22:21:04 +0000
@@ -161,14 +161,10 @@
161 try161 try
162 {162 {
163 auto value = arg.as<typename PropertyType::ValueType>();163 auto value = arg.as<typename PropertyType::ValueType>();
164 Super::set(value);164 set(value);
165 }
166 catch (const std::exception &e){
167 std::cout << __PRETTY_FUNCTION__ << ": " << e.what() << std::endl;
168 }165 }
169 catch (...)166 catch (...)
170 {167 {
171 std::cout << __PRETTY_FUNCTION__ << ": " << "Unknown exception." << std::endl;
172 }168 }
173}169}
174}170}
175171
=== modified file 'include/core/dbus/service.h'
--- include/core/dbus/service.h 2013-11-27 18:57:42 +0000
+++ include/core/dbus/service.h 2014-07-15 22:21:04 +0000
@@ -60,28 +60,53 @@
60 typedef std::shared_ptr<Service> Ptr; 60 typedef std::shared_ptr<Service> Ptr;
6161
62 /**62 /**
63 * @brief Exposes a service on the bus.63 * @brief Exposes a service on the bus, trying to acquire the given name.
64 * @returns An instance of Service or nullptr in case of errors.64 * @returns An instance of Service or nullptr in case of errors.
65 * @tparam Interface Needs to a model of concept Service.65 * @tparam Interface Needs to a model of concept Service.
66 * @param [in] connection Bus to expose the service upon.66 * @param [in] connection Bus to expose the service upon.
67 * @param [in] name The name to acquire for this service.
67 * @param [in] flags Flags specifying behavior when requesting a name on the bus.68 * @param [in] flags Flags specifying behavior when requesting a name on the bus.
68 */69 */
69 template<typename Interface>
70 inline static Ptr add_service(70 inline static Ptr add_service(
71 const Bus::Ptr& connection,71 const Bus::Ptr& connection,
72 const std::string& name,
72 const Bus::RequestNameFlag& flags =73 const Bus::RequestNameFlag& flags =
73 Bus::RequestNameFlag::do_not_queue |74 Bus::RequestNameFlag::do_not_queue |
74 Bus::RequestNameFlag::replace_existing)75 Bus::RequestNameFlag::replace_existing)
75 {76 {
76 static Ptr instance(77 Ptr instance(
77 new Service(78 new Service(
78 connection, 79 connection,
79 traits::Service<Interface>::interface_name(), 80 name,
80 flags));81 flags));
81 return instance;82 return instance;
82 }83 }
8384
84 /**85 /**
86 * @brief Exposes a service on the bus.
87 * @returns An instance of Service or nullptr in case of errors.
88 * @tparam Interface Needs to a model of concept Service.
89 * @param [in] connection Bus to expose the service upon.
90 * @param [in] flags Flags specifying behavior when requesting a name on the bus.
91 */
92 template<typename Interface>
93 inline static Ptr add_service(
94 const Bus::Ptr& connection,
95 const Bus::RequestNameFlag& flags =
96 Bus::RequestNameFlag::do_not_queue |
97 Bus::RequestNameFlag::replace_existing)
98 {
99 static Ptr instance
100 {
101 add_service(connection,
102 traits::Service<Interface>::interface_name(),
103 flags)
104 };
105
106 return instance;
107 }
108
109 /**
85 * @brief Provides access to a service on the bus via a proxy object.110 * @brief Provides access to a service on the bus via a proxy object.
86 * @returns An instance of Service or nullptr in case of errors.111 * @returns An instance of Service or nullptr in case of errors.
87 * @tparam Interface Needs to be a model of concept Service.112 * @tparam Interface Needs to be a model of concept Service.
88113
=== modified file 'tests/service_test.cpp'
--- tests/service_test.cpp 2014-06-10 08:44:17 +0000
+++ tests/service_test.cpp 2014-07-15 22:21:04 +0000
@@ -82,25 +82,11 @@
82 auto writable_property = skeleton->get_property<test::Service::Properties::Dummy>();82 auto writable_property = skeleton->get_property<test::Service::Properties::Dummy>();
83 writable_property->set(expected_value);83 writable_property->set(expected_value);
8484
85 auto readonly_property = skeleton->get_property<test::Service::Properties::ReadOnly>();85 skeleton->install_method_handler<test::Service::Method>([bus, skeleton, expected_value](const dbus::Message::Ptr& msg)
86 readonly_property->set(7);
87
88 skeleton->install_method_handler<test::Service::Method>([bus, skeleton, &readonly_property, expected_value](const dbus::Message::Ptr& msg)
89 {86 {
90 auto reply = dbus::Message::make_method_return(msg);87 auto reply = dbus::Message::make_method_return(msg);
91 reply->writer() << expected_value;88 reply->writer() << expected_value;
92 bus->send(reply);89 bus->send(reply);
93
94 readonly_property->set(expected_value);
95 auto changed_signal = skeleton->get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>();
96 core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType
97 args("this.is.unlikely.to.exist.Service",
98 {{test::Service::Properties::ReadOnly::name(),
99 core::dbus::types::TypedVariant<test::Service::Properties::ReadOnly::ValueType>(expected_value)}},
100 {});
101 skeleton->emit_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged, core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType>(args);
102 changed_signal->emit(args);
103
104 skeleton->emit_signal<test::Service::Signals::Dummy, int64_t>(expected_value);90 skeleton->emit_signal<test::Service::Signals::Dummy, int64_t>(expected_value);
105 });91 });
10692
@@ -132,14 +118,6 @@
132 {118 {
133 std::cout << "Dummy property changed: " << d << std::endl;119 std::cout << "Dummy property changed: " << d << std::endl;
134 });120 });
135
136 auto readonly_property = stub->get_property<test::Service::Properties::ReadOnly>();
137 EXPECT_EQ(readonly_property->get(), 7);
138 std::uint32_t changed_value = 0;
139 readonly_property->changed().connect([&changed_value](std::uint32_t value){
140 changed_value = value;
141 });
142
143 auto signal = stub->get_signal<test::Service::Signals::Dummy>();121 auto signal = stub->get_signal<test::Service::Signals::Dummy>();
144 int64_t received_signal_value = -1;122 int64_t received_signal_value = -1;
145 signal->connect([bus, &received_signal_value](const int32_t& value)123 signal->connect([bus, &received_signal_value](const int32_t& value)
@@ -166,8 +144,6 @@
166 t.join();144 t.join();
167145
168 EXPECT_EQ(expected_value, received_signal_value);146 EXPECT_EQ(expected_value, received_signal_value);
169 EXPECT_EQ(expected_value, readonly_property->get());
170 EXPECT_EQ(changed_value, expected_value);
171147
172 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;148 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
173 };149 };
174150
=== modified file 'tests/test_service.h'
--- tests/test_service.h 2014-06-03 08:25:03 +0000
+++ tests/test_service.h 2014-07-15 22:21:04 +0000
@@ -68,18 +68,6 @@
68 static const bool readable = true;68 static const bool readable = true;
69 static const bool writable = true;69 static const bool writable = true;
70 };70 };
71
72 struct ReadOnly
73 {
74 inline static std::string name()
75 {
76 return "ReadOnly";
77 };
78 typedef Service Interface;
79 typedef std::uint32_t ValueType;
80 static const bool readable = true;
81 static const bool writable = false;
82 };
83 };71 };
8472
85 struct Interfaces73 struct Interfaces

Subscribers

People subscribed via source and target branches