activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiram Chirino" <hi...@hiramchirino.com>
Subject Re: openwire C++ client
Date Sun, 26 Mar 2006 21:47:57 GMT
Hi Nathan,

On 3/26/06, Nathan Mittler <nathan.mittler@gmail.com> wrote:
> I've taken a closer look at the openwire C++ client this weekend and noticed
> a few things ...
>
> 1) I think there are a few cases where we could reduce the usage of smart
> pointers.
>
> One instance where I think smart pointer usage is questionable is when
> openwire is referencing an object that it doesn't control.  For example,
> when my code declares a class that is an IMessageListener, it seems strange
> that this should be passed in as a smart pointer to openwire functions.
> Openwire doesn't control the lifetime of this object, so I don't believe it
> should be referencing it in a "managed" way.
>
> Another case where smart pointers could be avoided is strings.  If all
> string member variables are std::strings, then the setXXX method could just
> take a "const char*" and the const getXXX method could simply return a
> "const char*" (which would be the value returned from the mystr.c_str()
> method).  This makes for a much simpler and symmetric API.
>

I agreed.  I think it may be possible to be even more aggressive and
avoid having the interface classes use smart pointers at all.  I think
the if we define good ownership rules, then we do not need to have the
API user need to worry about smart pointers.

On a related note, It would be nice if the name spaces used were
changed so that they paralleled the .NET stuff a little closer.  It
might be nice to have a 'cms' name space the holds all the interface
classes and a 'activemq', 'activemq::transport', etc. name space that
holds all the activemq implementation of the interfaces.  Using
'org::apache::activemq' seems a little verbose to me.

Regards,
Hiram

> 2) ITextMessage should extend IMessage
>
> It seems that the ITextMessage class was at one time derived from IMessage,
> but it is commented out (probably to get through compilation :-) ).  If you
> try to call send() on the MessagePublisher class with an ITextMessage, the
> code won't compile.
>

agreed.

> I've gotten around this by making ITextMessage extend IMessage - the trick
> is that when you do this, ActiveMQTextMessage gets IMessage from two
> branches.  In one branch, it gets the methods from IMessage implemented for
> it ( by ActiveMQMessage) and in the other branch (ITextMessage), it
> doesn't.  So you have to have ActiveMQTextMessage implement all the methods
> from the IMessage interface and delegate them to the ActiveMQMessage base
> class.  This seems to do the trick.
>

The joys of multiple inheritance :)


--
Regards,
Hiram

Mime
View raw message