Use covariant return type for clone()
-------------------------------------

                 Key: AMQCPP-34
                 URL: https://issues.apache.org/activemq/browse/AMQCPP-34
             Project: ActiveMQ C++ Client
          Issue Type: Improvement
          Components: CMS Impl
    Affects Versions: 1.1
            Reporter: Albert Strasheim
         Assigned To: Nathan Mittler
         Attachments: covariant-clones.diff

The cms::Message type has a pure virtual clone() method that returns a 
cms::Message*. cms::BytesMessage doesn't have a clone method. So it continues 
down the inheritance chain until we get to classes like 
activemq::connector::stomp::commands::TextMessageCommand which implement 
clone() and define it to return cms::Message*.

This means that in my message listener I have to cast the result of a 
BytesMessage->clone() (which I already know is a BytesMessage) to BytesMessage 
before I can use it as such.

Instead, BytesMessage should override clone() with another pure virtual that 
returns cms::BytesMessage. I think this is called a covariant return type. 
After that, TextMessageCommand's clone should probably be modified to return 
TextMessageCommand*. I don't know if there's anything in between that warrants 
a clone with a covariant return type.

Fixing this will make the library slightly easier to use.

Basic patch attached. There's probably more places to fix. Patch also has a few 
typo fixes.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to