Hi Vipin,

> implies that I can simply define a simple class member of the custom
> block C++ class to store the state.
Indeed!

> Do class member variables of custom GRC block retain their state
> across two different calls of the function? 
Yes! As said, this is bog-normal C++ or Python. What would be the sense
in having a member variable if it wasn't persistent?

> Does the custom block class’ object gets created once during
> initialization and only the general work function gets called multiple
> times for processing.
Exactly.

> The only state we loose are the local variables which get defined in
> the general work function itself.
That's not a state, that's parameterization of the function, if you will.

Not quite sure what to recommend here – on one hand, it looks like
you're actually very intensely consider what you're doing on a level
that most software developers simply wouldn't think about (since the
language takes care of that for them), but that on the other hand might
be an indication of you not being overly used to writing procedural and
object-oriented code at all. But that is really just a hunch!

Best regards,
Marcus

On 10/08/2017 09:17 AM, Vipin Sharma wrote:
> Marcus,
>
> Your comment:
>
> “just give your block, which is a
> normal C++ or Python class, a member that holds the state”
>
> implies that I can simply define a simple class member of the custom
> block C++ class to store the state. 
>
> However, I was initially thinking that would mean feedback as well.
> After thinking through though it shouldn’t be because member variables
> are not input/output streams. 
>
> I still have one question though. Do class member variables of custom
> GRC block retain their state across two different calls of the
> function? I guess I don’t really understand how GRC calls the custom
> block during runtime. Does the custom block class’ object gets created
> once during initialization and only the general work function gets
> called multiple times for processing. That way all custom block’s
> class’ object retain all their state across the calls? The only state
> we loose are the local variables which get defined in the general work
> function itself. 
>
> Vipin 
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

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

Reply via email to