You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Rakhi Kumari <ra...@gmail.com> on 2021/04/11 17:32:51 UTC

Fwd: [jira] [Commented] (PROTON-2370) [cpp] An accessor for the delivery tag

Hi,

I'm working on PROTON-2370
<https://issues.apache.org/jira/browse/PROTON-2370> and created the draft PR
<https://github.com/apache/qpid-proton/pull/309> for the same. While
working on it I was seeing code snippets similar to "struct pn_session_t;",
I haven't seen this C++ syntax before. Can you please tell me what it
means?

https://github.com/apache/qpid-proton/blob/df978869030bb811b5e9cd99f6c390c9ca9bf97c/cpp/src/proton_bits.hpp#L42


I'm trying to understand the above in order to fix the build error I'm
getting on the same PR. In case you already know what's wrong here, can you
please guide me?

https://github.com/apache/qpid-proton/blob/df978869030bb811b5e9cd99f6c390c9ca9bf97c/cpp/include/proton/tag.hpp#L42


[image: image.png]


Best regards,
Rakhi

---------- Forwarded message ---------
From: ASF GitHub Bot (Jira) <ji...@apache.org>
Date: Sun, Apr 11, 2021 at 6:03 PM
Subject: [jira] [Commented] (PROTON-2370) [cpp] An accessor for the
delivery tag
To: <de...@qpid.apache.org>



    [
https://issues.apache.org/jira/browse/PROTON-2370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17318756#comment-17318756
]

ASF GitHub Bot commented on PROTON-2370:
----------------------------------------

DreamPearl opened a new pull request #309:
URL: https://github.com/apache/qpid-proton/pull/309


   Work In Progress


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> [cpp] An accessor for the delivery tag
> --------------------------------------
>
>                 Key: PROTON-2370
>                 URL: https://issues.apache.org/jira/browse/PROTON-2370
>             Project: Qpid Proton
>          Issue Type: Improvement
>          Components: cpp-binding
>            Reporter: Justin Ross
>            Priority: Major
>
> *Assignee: Rakhi*
> Steps:
>  * Get familiar with the AMQP idea of a delivery tag
>  * Add a delivery tag accessor to the C++ delivery class
>  * Document the accessor in the C++ header
>  * Add a test for the accessor to the C++ test suite
> Resources:
>  * [
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#doc-idp438000
]
>  * [
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-delivery-tag
]
>  * [
https://github.com/apache/qpid-proton/blob/main/c/include/proton/delivery.h#L106
]
>  * [
https://github.com/apache/qpid-proton/blob/main/cpp/include/proton/delivery.hpp
]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org

Re: [jira] [Commented] (PROTON-2370) [cpp] An accessor for the delivery tag

Posted by Rakhi Kumari <ra...@gmail.com>.
Thanks, Jiri for the detailed explanation. It really answered my query very
well. I will continue with the PR, thanks for the comments there.

On Sun, Apr 11, 2021 at 11:47 PM Jiri Daněk <jd...@redhat.com> wrote:

> On Sun, Apr 11, 2021 at 7:33 PM Rakhi Kumari <ra...@gmail.com> wrote:
>
>> Hi,
>>
>> I'm working on PROTON-2370
>> <https://issues.apache.org/jira/browse/PROTON-2370> and created the
>> draft PR <https://github.com/apache/qpid-proton/pull/309> for the same.
>> While working on it I was seeing code snippets similar to "struct
>> pn_session_t;", I haven't seen this C++ syntax before. Can you please tell
>> me what it means?
>>
>
> Hey, I am not sure what exactly you are asking, so I am going to give a
> long-winded answer, sorry. A struct is a carry-over from the C language. So
> the answer depends on whether you are compiling your code as C or C++.
>
> In C++ a struct it is like a class where the default access modifier is
> public:, unless you declare it otherwise. In a C++ class, all members are
> private: by default, unless you declare otherwise.
>
> When you compile as C, a struct can only have data members, no methods.
> That's because C is not an object-oriented language, so the C++ syntax to
> add methods is not supported. If you want to have objects in C, you can
> define functions that take the struct (or pointer to a struct, more like)
> as their first argument (for consistency), name the functions in a
> consistent way, and only manipulate the struct using these functions; which
> is exactly what Proton-c does. You cannot have inheritance in C, though.
> Well, actually, you can use a library to add some object support to C, for
> example https://en.wikibooks.org/wiki/C_Programming/GObject, but Proton-c
> does not use any of that.
>
>
>>
>> https://github.com/apache/qpid-proton/blob/df978869030bb811b5e9cd99f6c390c9ca9bf97c/cpp/src/proton_bits.hpp#L42
>>
>
> That on line 42 is a forward declaration of a struct. You can do this
> instead of actually including the header file, and then you can use the
> type as a reference (pointer). You cannot use it as a value because with
> only a forward-declaration, the compiler does not know the size of the
> struct. Usually it is better to simply include the header; you may not want
> to do that 1) for compile efficiency, if the header file is very big 2) if
> the header file is not available, as e.g. in this case in Proton, the
> header is called "engine-internal.h"; private headers are one way in C to
> achieve encapsulation; here the C++ binding is breaking encapsulation, to
> some (small) degree, hopefully for good reasons.
>
>
>> I'm trying to understand the above in order to fix the build error I'm
>> getting on the same PR. In case you already know what's wrong here, can you
>> please guide me?
>>
>>
>> https://github.com/apache/qpid-proton/blob/df978869030bb811b5e9cd99f6c390c9ca9bf97c/cpp/include/proton/tag.hpp#L42
>>
>>
>> [image: image.png]
>>
>
> Please don't include pictures in e-mails to the mailing list; the mailing
> list is afaik striping them, the only reason I see this is that you sent me
> a CC in addition 'P Simply copy-paste the text from the terminal. The text
> color does not matter.
>
> I'm going to comment on the PR directly, just because I can 'P BTW, thanks
> for posting the PR, it helps with debugging. I can simply pull your code in
> its entirety and play with it...
> --
> Mit freundlichen Grüßen / Kind regards
> Jiri Daněk
>

Re: [jira] [Commented] (PROTON-2370) [cpp] An accessor for the delivery tag

Posted by Jiri Daněk <jd...@redhat.com>.
On Sun, Apr 11, 2021 at 7:33 PM Rakhi Kumari <ra...@gmail.com> wrote:

> Hi,
>
> I'm working on PROTON-2370
> <https://issues.apache.org/jira/browse/PROTON-2370> and created the draft
> PR <https://github.com/apache/qpid-proton/pull/309> for the same. While
> working on it I was seeing code snippets similar to "struct pn_session_t;",
> I haven't seen this C++ syntax before. Can you please tell me what it means?
>

Hey, I am not sure what exactly you are asking, so I am going to give a
long-winded answer, sorry. A struct is a carry-over from the C language. So
the answer depends on whether you are compiling your code as C or C++.

In C++ a struct it is like a class where the default access modifier is
public:, unless you declare it otherwise. In a C++ class, all members are
private: by default, unless you declare otherwise.

When you compile as C, a struct can only have data members, no methods.
That's because C is not an object-oriented language, so the C++ syntax to
add methods is not supported. If you want to have objects in C, you can
define functions that take the struct (or pointer to a struct, more like)
as their first argument (for consistency), name the functions in a
consistent way, and only manipulate the struct using these functions; which
is exactly what Proton-c does. You cannot have inheritance in C, though.
Well, actually, you can use a library to add some object support to C, for
example https://en.wikibooks.org/wiki/C_Programming/GObject, but Proton-c
does not use any of that.


>
> https://github.com/apache/qpid-proton/blob/df978869030bb811b5e9cd99f6c390c9ca9bf97c/cpp/src/proton_bits.hpp#L42
>

That on line 42 is a forward declaration of a struct. You can do this
instead of actually including the header file, and then you can use the
type as a reference (pointer). You cannot use it as a value because with
only a forward-declaration, the compiler does not know the size of the
struct. Usually it is better to simply include the header; you may not want
to do that 1) for compile efficiency, if the header file is very big 2) if
the header file is not available, as e.g. in this case in Proton, the
header is called "engine-internal.h"; private headers are one way in C to
achieve encapsulation; here the C++ binding is breaking encapsulation, to
some (small) degree, hopefully for good reasons.


> I'm trying to understand the above in order to fix the build error I'm
> getting on the same PR. In case you already know what's wrong here, can you
> please guide me?
>
>
> https://github.com/apache/qpid-proton/blob/df978869030bb811b5e9cd99f6c390c9ca9bf97c/cpp/include/proton/tag.hpp#L42
>
>
> [image: image.png]
>

Please don't include pictures in e-mails to the mailing list; the mailing
list is afaik striping them, the only reason I see this is that you sent me
a CC in addition 'P Simply copy-paste the text from the terminal. The text
color does not matter.

I'm going to comment on the PR directly, just because I can 'P BTW, thanks
for posting the PR, it helps with debugging. I can simply pull your code in
its entirety and play with it...
-- 
Mit freundlichen Grüßen / Kind regards
Jiri Daněk