Updating abstract classes


#1

This is more C++ than dsp - this compiles but segfaults:

atsc_equalizer.h:

class atsc_equalizer;
protected:
atsci_equalizer *d_equalizer;

atsc_equalizer.cc:

// peform the actual equalization

d_equalizer->filter (in, in_tags,
out, noutput_items);

atsci_equalizer.h:

class atsci_equalizer {
virtual void filter (const float *input_samples,
const atsc::syminfo *input_tags,

If I expunge all occurances of d_equalizer-> it’ll run w/o segfault.
Trying to change it to what worked in earlier updates:

atsc_equalizer.h:

class atsc_equalizer : public gr_sync_block
{
friend atsc_equalizer_sptr atsc_make_equalizer();

atsci_equalizer d_equalizer;

atsc_equalizer.cc:

// peform the actual equalization

d_equalizer.filter (in, in_tags,
out, noutput_items);

it fails to compile because:

./atsc_equalizer.h:41: error: cannot declare field
atsc_equalizer::d_equalizer' to be of typeatsci_equalizer’
./atsc_equalizer.h:41: error: because the following virtual functions
are abstract:
./atsci_equalizer.h:159: error: virtual void
atsci_equalizer::filter_field_sync(const float*, float*, int, int, int)
./atsci_equalizer.h:140: error: virtual void
atsci_equalizer::filter_data_seg_sync(const float*, float*, int, int)

Any advise on which way to go? I.e. should I just leave it
d_equalizer->filter() and look for problems elsewhere?

tia
–Chuck


#2

Quoting C. Swiger removed_email_address@domain.invalid:

./atsc_equalizer.h:41: error: cannot declare field
atsc_equalizer::d_equalizer' to be of typeatsci_equalizer’
./atsc_equalizer.h:41: error: because the following virtual functions
are abstract:
./atsci_equalizer.h:159: error: virtual void
atsci_equalizer::filter_field_sync(const float*, float*, int, int, int)
./atsci_equalizer.h:140: error: virtual void
atsci_equalizer::filter_data_seg_sync(const float*, float*, int, int)

I’m guessing that you don’t find these messages particularly
informative, so
here’s what they mean:

d_equalizer is of type atsci_equalizer; you’re trying to instantiate
one, but
atsci_equalizer is an abstract class because it doesn’t have definitions
for
these functions: filter_field_sync, filter_data_seq_sync. You can’t
instantiate
abstract classes, so you must either define those functions or you must
specify
a more specific type for d_equalizer that can be instantiated.

The reason you probably see segfaults with the pointer version is
because you
never actually create an object that d_equalizer would point to (at
least in
the code that you showed).

-Ilia


#3

On Wed, 2006-04-26 at 17:09 -0400, Ilia Mirkin wrote:

I’m guessing that you don’t find these messages particularly informative, so
The reason you probably see segfaults with the pointer version is because you
never actually create an object that d_equalizer would point to (at least in
the code that you showed).

Thanks, appreciate the explaination.

Another modules, atsc_fs_checker, which also has some abstract
classes DOES compile and run on meaningless streams w/o segfault
so I can go by that (tomorrow!).

Yeah - here’s what I left out (arg!)

d_equalizer = equalizer;

–Chuck


#4

On Wed, Apr 26, 2006 at 06:35:27PM -0400, Ilia Mirkin wrote:

and somewhere in the code, do

d_equalizer = create_atsci_equalizer_nop() or something.

If d_equalizer points to a properly set up object, and ->filter() segfaults,
then there must be a bug in the filter() routine (or the inputs to it are
sufficiently wrong.)

-Ilia

Hi Ilia,
Thanks for diving in.

Chuck,

After taking a look at the 0.9 code (atsc_rx.cc), it looks like we were
instantiating atsci_equalizer_lms.

atsci_equalizer_lms uses a single FIR filter.

atsci_equalizer_lms2 uses feedback and feedforward. Not sure we ever
got it sorted out.

Eric


#5

Quoting C. Swiger removed_email_address@domain.invalid:

a more specific type for d_equalizer that can be instantiated.
Another modules, atsc_fs_checker, which also has some abstract
classes DOES compile and run on meaningless streams w/o segfault
so I can go by that (tomorrow!).

Yeah - here’s what I left out (arg!)

d_equalizer = equalizer;

–Chuck

Yeah, so while atsci_equalizer doesn’t implement these things,
atsci_equalizer_{lms,lms2,nop} do implement them. So you want something
along
the lines of

atsci_equalizer *d_equalizer;

and somewhere in the code, do

d_equalizer = create_atsci_equalizer_nop() or something.

If d_equalizer points to a properly set up object, and ->filter()
segfaults,
then there must be a bug in the filter() routine (or the inputs to it
are
sufficiently wrong.)

-Ilia


#6

On Wed, 2006-04-26 at 17:53 -0700, Eric B. wrote:

atsci_equalizer_lms2 uses feedback and feedforward. Not sure we ever
got it sorted out.

That’s even more confusing :wink: I’m working from GrAtscEqualizer.cc|h.

What part controls which symbols get into python? I have it compiling
mostly as it is in GrAtscEqualizer, but get this:

from gnuradio import atsc
Traceback (most recent call last):
File “”, line 1, in ?
File “/usr/local/lib/python2.4/site-packages/gnuradio/atsc.py”, line
4, in ?
import _atsc
ImportError: /usr/local/lib/python2.4/site-packages/gnuradio/_atsc.so:
undefined symbol: _ZN14atsc_equalizerC1Ev

In atsc_equalizer.cc

atsc_equalizer::atsc_equalizer(atsci_equalizer *equalizer)
: gr_sync_block(“atsc_equalizer”,
gr_make_io_signature(2, 2, sizeof(float)),
gr_make_io_signature(2, 2, sizeof(float)))
{
d_equalizer = equalizer;
}

and in atsc_equalizer.h

class atsc_equalizer : public gr_sync_block
{
friend atsc_equalizer_sptr atsc_make_equalizer();

atsc_equalizer();

public:
void forecast (int noutput_items, gr_vector_int
&ninput_items_required);
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);

void reset() { /* nop */ }

atsc_equalizer(atsci_equalizer *equalizer);

protected:
atsci_equalizer *d_equalizer;

};


#7

Quoting C. Swiger removed_email_address@domain.invalid:

atsci_equalizer_lms uses a single FIR filter.

from gnuradio import atsc
Traceback (most recent call last):
File “”, line 1, in ?
File “/usr/local/lib/python2.4/site-packages/gnuradio/atsc.py”, line
4, in ?
import _atsc
ImportError: /usr/local/lib/python2.4/site-packages/gnuradio/_atsc.so:
undefined symbol: _ZN14atsc_equalizerC1Ev

If I had to guess, I’d say that atsc_equializer.cc isn’t being linked
in.

-Ilia


#8

On Wed, 2006-04-26 at 21:30 -0400, Ilia Mirkin wrote:

atsci_equalizer_lms2 uses feedback and feedforward. Not sure we ever
got it sorted out.

Ok, I get it - part of the routine was in atsc_rx.cc.
Solution was to #include <create_atsci_equalizer.h>
then d_equalizer = create_atsci_equalizer_lms();
just like you said.

And … no segfault on quickie test.

Tks and 73’s for tonight.

–Chuck