discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Sub-classing a block defined in an _impl class


From: Jeff Long
Subject: Re: [Discuss-gnuradio] Sub-classing a block defined in an _impl class
Date: Fri, 10 Oct 2014 06:37:31 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1

The good part is the separation of the API from the implementation. The not so good thing is that the implementations themselves often contain all the logic, usually because they are fairly simple. So, your choices are to subclass or copy/edit the implementation files. [Just saw Sylvain's not about phase_detector() being privite - OK].

Also, the implementations are free to change without affecting the API. Guaranteeing stability of implementations (even the _impl.h) makes the implementations part of the API, which would be bad. If there were a family of carrier tracking algorithms, it would make sense to have them subclass from a common abstract class.

In more complicated blocks, like some in the filter area, a good portion of the logic is separated out and reusable.

The

On 10/10/2014 06:25 AM, Johannes Demel wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Daniele,

_impl classes are not meant to be subclassed usually.
GR distinguishes between interface or public headers, which are
located in the include directory and private headers which are located
in the lib directory.
You can just add new classes to your lib folder and use them within
this folder. But if you want to export these classes and make them
accessable from Python, you need a public header for it.

On 10.10.2014 12:03, Daniele Nicolodi wrote:
Hello,

this question my arise from my ignorance about C++, but I don't
understand how, if it is possible, to sub-class a GNURadio block
that has moat of his code in an _impl class.

To my understanding I would need to subclass both the class
defining the block and his _impl class. However, it seems that the
_impl class is not part of the exposed API, therefore there is no
way to subclass it. There is way to achieve this without copying
around significant portions of code?
The public description of a block is in the corresponding include
folder. It is pure virtual to make sure it remains as an interface file.

The case at hand is subclassing gr::analog::pll_carriertracking_cc
changing the phase_detector() method to use the regular atan2()
instead of the fast version.
You may just change this in GR directly. You have a personal copy of
the code so there is nothing that should contradict this approach.
Unless you want to compare the two but even then you should be able to
accomplish that.

I hope that gives you an idea of the structure and may help you solve
your problem.

Cheers
Johannes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUN7P9AAoJEO7fmkDsqywMpggP/0dQEXmkffTmzeg4cvW5xlmJ
RWzT+eEA1prFMMR3iBSTrlPnLMyQfVz4nxE63AbBx+pEBsHzu6fUUHWZLtlzVwpy
Bq89/Sd5G8sM40TWGKrFfUjxd5ND/4HuKar6JC/Wx9tnfZYCa3q3f3O2vi1S/6wu
Ir6xKGpSGsR9Ro3RZ8iL+d/WoxAv86cH+GxFdo6R496hkqi1gZYdVkBJO1vCAL6S
8s2mvNDkSTcXaGcrF3VhhIBnjcwvhn3GYQMCjeSbcbyk++dLhZH+dmitB27lv6qW
/u/eTNtXVGN2TzzQ0hLW4YI8pLGOj/cENHbBc31zUzRbRwt/ebOWC78bx9dyKALr
WB0kDVM2XI9veYeyxMwvdtFncO7B7MGh+ocozhg53WaWijnFLGwD55yxZedXNcEr
iIdq9Px7smsJ87s6ABgB7MfrhGgxT0ZJxop5D68HBLE4/v1OnRxjfi1V0JpKmIxt
uueDgbKWGQEaDrgQX0BnrQ6bA68Z1HuTHk68j6WOnZ36a2mAZZfnZ8iKVckX/PJv
CFhJLFtTQpfg3DR7lEN7x1gwbyyQGEk6w68sVK+e/LdPc5BHO9d4AcVCgfLaO/Ov
i3QYb+Oqjv7P+jl2N2nAohh+AyNjwSRm2DxQGGwnvbhfChii5Cr5mIc+3y/JeoVf
Vm7RMlaj1ESE9XAifvQC
=z5WH
-----END PGP SIGNATURE-----

_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio





reply via email to

[Prev in Thread] Current Thread [Next in Thread]