Monday, September 13, 2021

Re: can a hier_block2 have a work function?

Hi Jameson,

On 13/09/2021 13.21, Jameson Collins wrote:
> Is it possible to have a work function in a hier_block2 block?
no!

> It seems the answer is yes, in the sense that the code will compile.

That's C++: you can declare new methods that the parent class didn't have.
Hint: if you attach `override` to your method signature, for example

class jamesons_block_impl : public jamesons_block {
int work(…) override;
};

then the compiler will gladly complain if you're implementing a method
that you thought was something present in the parent class(es), but that
isn't.

> However the work function will never be executed.

On what would it be executed?

> I get that if it did execute that there'd be some ambiguity about where
> in the chain it is (i.e. is the first, or last thing executed in the
> signal processing chain).

Exactly! If you want a signal processing block, derive from gr::block,
gr::sync_block etc.; hier_block2 is really for hierarchical blocks only
meant to enclose a subgraph, not one or multiple vertices of such a graph.

Best regards,
Marcus

No comments:

Post a Comment