discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] constructor of block is not private


From: Activecat
Subject: Re: [Discuss-gnuradio] constructor of block is not private
Date: Thu, 23 Jan 2014 16:27:28 +0800

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:

  byte_source_impl   block2;


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 <address@hidden> 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 #endif /*
> INCLUDED_HOWTO_BYTE_SOURCE_IMPL_H */
>
>
>
> Please advise, thanks.
>
> Regards. address@hidden
>
>
>
> _______________________________________________ Discuss-gnuradio
> mailing list address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJS4L+lAAoJEAFxB7BbsDrLzKgH/3hXX64ZTxL0jMsns+Iukaqv
D8dp31yTa2dLDlaB/C+/SuZx1bRRjSEwUSWSl9/heqL90M80R7FLbr4AiGBlmPWu
o/c5kSTimPjSmEjND2yDJbEBacK7p4ha2S77BRNXi1eFcWCYBrDDJD3gkisGlFop
Tw0sYZHnGrt6RydNm/BCPSTufY9hpdM0dnYIEOIG0ox5DOXK5ZIKZvbEnfG+GZW9
yiN0sUgZQa+RSuxpbHL8IOwXgXN1s+XkrMFpqSIzeXN6GRduuXKl0+qYw2sJEV94
mPvO2deLBeaBEafioCMubO25w3sEJzv41Et7gld45VlMwhY69+DusJXH37gJwcU=
=2xFR
-----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]