http://bugzilla.moblin.org/show_bug.cgi?id=7700
--- Comment #27 from pohly <patrick.ohly(a)intel.com> 2010-02-02 23:13:40 PST ---
(In reply to comment #26)
(In reply to comment #25)
> (In reply to comment #24)
> > Please see the updated patches in presence branch
>
> Some general comments: your formatting is not consistent with the rest of the
> code. I don't care too much, but it is something that I keep noticing, so let
> me mention it.
Sorry, besides space before '{', is there any general formating comments you
will suggest?
Names of member functions is another one. The rest of the code uses
smallMixCase(), while you tend to use small_lower_case().
Now I get your idea. The API was designed to accept a plain function
pointer
because I thought this is easier to use by the user(he doesn't need to know
boost::function bind).
A valid concern, but the caller pays for that by having to instantiate the
template with two additional parameters. I think using boost::bind() is easier.
> Your approach of passing a DBusCallObject reference into
DBusClientCall0 is
> dangerous: it is not obvious how long that instance has to be valid. In the
> current code, it has to be valid as long as the DBusClientCall0 might get used.
> This is neither documented, not is it good style. I know that it is done
> elsewhere, but that is for long-lived instances, not for something as
> short-lived as this ConnmanClient instance.
>
> Using reference counting here would solve these issues.
I don't quite get it. From the API it is the same with the existing code
(EmitSignal for example),
The key difference is that in EmitSignal, the DBusServer instance provides the
DBusObject implementation, which is guaranteed to be around longer that the
EmitSignal instances created by the DBusServer. In addition, in that case
DBusObject provides static information about the *originator* of the signal.
You are turning this around so that DBusCallObject provides information about
the recipient of the call.
And I also think if constructing DBusClientCall requires a reference
for
DBusCallObject, it should also implies DBusCallObject should be lived as long
as DBusClientCall.
No. This assumption is wrong for plenty of C++ APIs. Lot's of APIs, for example
in std::string, take a const reference and all it guarantees is that the
argument must be valid while the call executes.
If the caller expects more, it needs to be documented or the call needs to copy
the relevant information (better).
Changing the API to pass a shared_ptr might works but not that
simple: the API
once requires a DBusCallObject and it is correct to pass a derived class
ConnmanClient; however when changing to shared_ptr wrapper class, it no longer
holds.
You could pass a shared_ptr, store it and the pass on the const reference to
that instance. Not nice. I'm sure there are better solutions, like passing the
relevant information in a plain struct that gets copied instead of relying on
virtual function calls.
--
Configure bugmail:
http://bugzilla.moblin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.