Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #12769 > unrolled thread
| Started by | ittium <ittium@gmail.com> |
|---|---|
| First post | 2011-12-23 20:36 +0530 |
| Last post | 2011-12-25 10:33 +0530 |
| Articles | 8 — 5 participants |
Back to article view | Back to comp.lang.c++
wrapper class and N-to-1-uses-a relationship ittium <ittium@gmail.com> - 2011-12-23 20:36 +0530
Re: wrapper class and N-to-1-uses-a relationship zindorsky <nephi.allred@gmail.com> - 2011-12-23 11:03 -0800
Re: wrapper class and N-to-1-uses-a relationship red floyd <no.spam.here@its.invalid> - 2011-12-23 11:29 -0800
Re: wrapper class and N-to-1-uses-a relationship ittium <ittium@gmail.com> - 2011-12-24 09:18 +0530
Re: wrapper class and N-to-1-uses-a relationship Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-24 03:58 -0600
Re: wrapper class and N-to-1-uses-a relationship Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-24 09:00 -0500
Re: wrapper class and N-to-1-uses-a relationship Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-24 09:46 -0600
Re: wrapper class and N-to-1-uses-a relationship ittium <ittium@gmail.com> - 2011-12-25 10:33 +0530
| From | ittium <ittium@gmail.com> |
|---|---|
| Date | 2011-12-23 20:36 +0530 |
| Subject | wrapper class and N-to-1-uses-a relationship |
| Message-ID | <jd25dr$6b6$1@dont-email.me> |
Group, I have a small doubt regarding http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq-31.4 As per this faq, only valid places(apart from virtual/dynamic data) to use reference semantic are - wrapper class -N-to-1-uses-a relationship These are generic terms, will appreciate if some one could explain or probably direct me to some link. Google search did not offer much. thanks Ittium
[toc] | [next] | [standalone]
| From | zindorsky <nephi.allred@gmail.com> |
|---|---|
| Date | 2011-12-23 11:03 -0800 |
| Subject | Re: wrapper class and N-to-1-uses-a relationship |
| Message-ID | <0ff7aca2-35b2-4804-b674-64f396e20a33@h7g2000prn.googlegroups.com> |
| In reply to | #12769 |
On Dec 23, 8:06 am, ittium <itt...@gmail.com> wrote: > Group, > I have a small doubt This has been bugging me for a while, so I'm going to finally say something. You do not have a doubt. You have a question. In English "doubt" does not have the meaning you seem to think it does.
[toc] | [prev] | [next] | [standalone]
| From | red floyd <no.spam.here@its.invalid> |
|---|---|
| Date | 2011-12-23 11:29 -0800 |
| Subject | Re: wrapper class and N-to-1-uses-a relationship |
| Message-ID | <jd2krl$2d9$1@dont-email.me> |
| In reply to | #12775 |
On 12/23/2011 11:03 AM, zindorsky wrote: > On Dec 23, 8:06 am, ittium<itt...@gmail.com> wrote: >> Group, >> I have a small doubt > > This has been bugging me for a while, so I'm going to finally say > something. You do not have a doubt. You have a question. In English > "doubt" does not have the meaning you seem to think it does. > I believe it's the dialect that they use in India.
[toc] | [prev] | [next] | [standalone]
| From | ittium <ittium@gmail.com> |
|---|---|
| Date | 2011-12-24 09:18 +0530 |
| Subject | Re: wrapper class and N-to-1-uses-a relationship |
| Message-ID | <jd3i2e$ap$1@dont-email.me> |
| In reply to | #12776 |
On 24-12-2011 AM 12:59, red floyd wrote: > On 12/23/2011 11:03 AM, zindorsky wrote: >> On Dec 23, 8:06 am, ittium<itt...@gmail.com> wrote: >>> Group, >>> I have a small doubt >> >> This has been bugging me for a while, so I'm going to finally say >> something. You do not have a doubt. You have a question. In English >> "doubt" does not have the meaning you seem to think it does. >> > > I believe it's the dialect that they use in India. Thanks for pointing this out. This actually is a question. But I think, in comp news groups, question is more important than small grammatical errors.
[toc] | [prev] | [next] | [standalone]
| From | Paavo Helde <myfirstname@osa.pri.ee> |
|---|---|
| Date | 2011-12-24 03:58 -0600 |
| Message-ID | <Xns9FC579C396910myfirstnameosapriee@216.196.109.131> |
| In reply to | #12769 |
ittium <ittium@gmail.com> wrote in news:jd25dr$6b6$1@dont-email.me: > Group, > I have a small doubt regarding > http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq-3 > 1.4 As per this faq, only valid places(apart from virtual/dynamic > data) to use reference semantic are > - wrapper class > -N-to-1-uses-a relationship > These are generic terms, will appreciate if some one could explain or > probably direct me to some link. Google search did not offer much. N-to-1 is easier to explain. This means that the same object of type A must be accessible from N objects of type B. In C++, an object is a region of memory, having a certain size (as reported by the sizeof() operator). As it is physically impossible the some region of memory (A) belongs at the same time into several different memory regions of same type (B), it means that for having this kind of relationship, A must be a separate object and all B objects should contain a pointer or reference to the A object. With the wrapper classes it is not so clear what the author has meant. I guess in this context this just means that the A object is already existing and must remain accessible from other parts of the program as the A object. Maybe it is a member in some std::map<A> or other container. However, other parts of the program want to have access to the exact same object, but via different interface. As it might not be possible or feasible to add this interface directly to the A class, a wrapper class B is defined instead, which provides the needed interface and forwards the actual function calls to the original A object. For doing this it must contain a pointer or reference to the A object. hth Paavo
[toc] | [prev] | [next] | [standalone]
| From | Victor Bazarov <v.bazarov@comcast.invalid> |
|---|---|
| Date | 2011-12-24 09:00 -0500 |
| Message-ID | <jd4lt5$knq$2@dont-email.me> |
| In reply to | #12786 |
On 12/24/2011 4:58 AM, Paavo Helde wrote: > ittium<ittium@gmail.com> wrote in news:jd25dr$6b6$1@dont-email.me: > >> Group, >> I have a small doubt regarding >> http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq-3 >> 1.4 As per this faq, only valid places(apart from virtual/dynamic >> data) to use reference semantic are >> - wrapper class >> -N-to-1-uses-a relationship >> These are generic terms, will appreciate if some one could explain or >> probably direct me to some link. Google search did not offer much. > > N-to-1 is easier to explain. This means that the same object of type A must > be accessible from N objects of type B. In C++, an object is a region of > memory, having a certain size (as reported by the sizeof() operator). As it > is physically impossible the some region of memory (A) belongs at the same > time into several different memory regions of same type (B), it means that > for having this kind of relationship, A must be a separate object and all B > objects should contain a pointer or reference to the A object. > > With the wrapper classes it is not so clear what the author has meant. I > guess in this context this just means that the A object is already existing > and must remain accessible from other parts of the program as the A object. > Maybe it is a member in some std::map<A> or other container. However, other > parts of the program want to have access to the exact same object, but via > different interface. As it might not be possible or feasible to add this > interface directly to the A class, a wrapper class B is defined instead, > which provides the needed interface and forwards the actual function calls > to the original A object. For doing this it must contain a pointer or > reference to the A object. I believe a more appropriate term for the latter is "adapter" instead of "wrapper". Wrappers *usually* contain the object they "wrap". V -- I do not respond to top-posted replies, please don't ask
[toc] | [prev] | [next] | [standalone]
| From | Paavo Helde <myfirstname@osa.pri.ee> |
|---|---|
| Date | 2011-12-24 09:46 -0600 |
| Message-ID | <Xns9FC5B4D48D83Dmyfirstnameosapriee@216.196.109.131> |
| In reply to | #12788 |
Victor Bazarov <v.bazarov@comcast.invalid> wrote in news:jd4lt5$knq$2@dont-email.me: > On 12/24/2011 4:58 AM, Paavo Helde wrote: >> ittium<ittium@gmail.com> wrote in news:jd25dr$6b6$1@dont-email.me: >> >>> Group, >>> I have a small doubt regarding >>> http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq >>> -3 1.4 As per this faq, only valid places(apart from virtual/dynamic >>> data) to use reference semantic are >>> - wrapper class >>> -N-to-1-uses-a relationship >>> These are generic terms, will appreciate if some one could explain >>> or probably direct me to some link. Google search did not offer >>> much. [...] >> With the wrapper classes it is not so clear what the author has >> meant. I guess in this context this just means that the A object is >> already existing and must remain accessible from other parts of the >> program as the A object. Maybe it is a member in some std::map<A> or >> other container. However, other parts of the program want to have >> access to the exact same object, but via different interface. As it >> might not be possible or feasible to add this interface directly to >> the A class, a wrapper class B is defined instead, which provides the >> needed interface and forwards the actual function calls to the >> original A object. For doing this it must contain a pointer or >> reference to the A object. > > I believe a more appropriate term for the latter is "adapter" instead > of "wrapper". Wrappers *usually* contain the object they "wrap". Yes, "adaptor" would be more appropriate. Nevertheless, from this FAQ section I get a feeling that by "wrapper" they mean just a "class wrapping a pointer or reference to an object of another class". But then it seems very close to to a tautology to claim that this requires storing a pointer or reference. Cheers Paavo
[toc] | [prev] | [next] | [standalone]
| From | ittium <ittium@gmail.com> |
|---|---|
| Date | 2011-12-25 10:33 +0530 |
| Message-ID | <4EF6AEAE.1010300@gmail.com> |
| In reply to | #12791 |
On 24-12-2011 PM 09:16, Paavo Helde wrote: > Victor Bazarov<v.bazarov@comcast.invalid> wrote in > news:jd4lt5$knq$2@dont-email.me: > >> On 12/24/2011 4:58 AM, Paavo Helde wrote: >>> ittium<ittium@gmail.com> wrote in news:jd25dr$6b6$1@dont-email.me: >>> >>>> Group, >>>> I have a small doubt regarding >>>> http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq >>>> -3 1.4 As per this faq, only valid places(apart from virtual/dynamic >>>> data) to use reference semantic are >>>> - wrapper class >>>> -N-to-1-uses-a relationship >>>> These are generic terms, will appreciate if some one could explain >>>> or probably direct me to some link. Google search did not offer >>>> much. > [...] >>> With the wrapper classes it is not so clear what the author has >>> meant. I guess in this context this just means that the A object is >>> already existing and must remain accessible from other parts of the >>> program as the A object. Maybe it is a member in some std::map<A> or >>> other container. However, other parts of the program want to have >>> access to the exact same object, but via different interface. As it >>> might not be possible or feasible to add this interface directly to >>> the A class, a wrapper class B is defined instead, which provides the >>> needed interface and forwards the actual function calls to the >>> original A object. For doing this it must contain a pointer or >>> reference to the A object. >> >> I believe a more appropriate term for the latter is "adapter" instead >> of "wrapper". Wrappers *usually* contain the object they "wrap". > > Yes, "adaptor" would be more appropriate. Nevertheless, from this FAQ > section I get a feeling that by "wrapper" they mean just a "class wrapping > a pointer or reference to an object of another class". But then it seems > very close to to a tautology to claim that this requires storing a pointer > or reference. > > Cheers > Paavo > Copying it to Marshall Cline, He might like to add something.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web