Dear Marcus,
Correct me if I am wrong.
The reason why the constructor is defined as private, is to disallowed this (below) from happening, either intentionally or unintentionally:Hence the constructor is usually defined as private as below:
class byte_source_impl : public byte_source
{
{
private:
byte_source_impl();
}
}
But in the code attached in the previous email, the constructor is defined as public instead.
Does this mean that gr_modtool has generated wrong code ..?
Shall we just manually correct this by moving the constructor to "private" rather than leaving it in "public" ?
Please advise, thanks.
activecat
On Thu, Jan 23, 2014 at 3:07 PM, Marcus Müller <marcus@hostalia.de> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Activecat,
the _impl classes are usually not instantiated by themselves; in fact,
their symbols are usually not exported and not wrapped by swig.
Instead, an instance of them is usually generated using the
superclass' ::make method. So there is need for at least that make
method being able to access the constructor.
Hope that cleared things up a little!
Greetings,
Marcus
On 23.01.2014 07:33, Activecat wrote:
> Dear Sir,
>
> From the documentation, the constructor of user-defined block is
> often private. But how come it is defined as public, refer below
> code. This is a typical code generated by gr_modtool:
>
> Filename: byte_source_impl.h
>
> /* -*- c++ -*- */#ifndef INCLUDED_HOWTO_BYTE_SOURCE_IMPL_H#define
> INCLUDED_HOWTO_BYTE_SOURCE_IMPL_H #include <howto/byte_source.h>
> namespace gr { namespace howto {
>
> class byte_source_impl : public byte_source { private: unsigned int
> counter;
>
>
> public: byte_source_impl(); // constructor is public ??
> ~byte_source_impl();
>
> void forecast (int noutput_items, gr_vector_int
> &ninput_items_required);
>
> int general_work(int noutput_items, gr_vector_int &ninput_items,
> gr_vector_const_void_star &input_items, gr_vector_void_star
> &output_items); };
>
> } // namespace howto } // namespace gr
No comments:
Post a Comment