Boost logo

Boost :

Subject: Re: [boost] Flow-based programming library for Boost?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-01-04 13:50:39


Le 04/01/13 16:35, Marcus Tomlinson a écrit :
> On 04 Jan 2013, at 16:53, "Vicente J. Botet Escriba" <vicente.botet_at_[hidden]> wrote:
>
>> Le 04/01/13 12:56, Marcus Tomlinson a écrit :
>>> On Fri, Jan 4, 2013 at 1:24 PM, Vicente J. Botet Escriba <
>>> vicente.botet_at_[hidden]> wrote:
>>>
>>>> Le 04/01/13 11:36, Marcus Tomlinson a écrit :
>>>>
>>>> On 04 Jan 2013, at 11:46 AM, "Vicente J. Botet Escriba" <
>>>>
>>>>
>>>> Could you show a simple example that makes use of this kind of changes?
>>>> BTW, what happens when you connect a char and you try to get/set an int or
>>>> a complex? Do you get an exception?
>>> Here's an example of the above vector<char> to a vector<int> situation
>>> (this component sets the gain of the audio signal passing through it):
>>>
>>> virtual void Process_( DspSignalBus& inputs, DspSignalBus& outputs )
>>> {
>>>
>>> // Audio input of char samples
>>>
>>> std::vector< char > _charStream;
>>> if( inputs.GetValue( 0, _charStream ) )
>>> {
>>> for( unsigned long i = 0; i < _charStream.size(); i++ )
>>> {
>>> _charStream[i] *= _gain;
>>> }
>>> outputs.SetValue( 0, _charStream );
>>> }
>>>
>>> // Audio input of int samples
>>>
>>> std::vector< int > _intStream;
>>> else if( inputs.GetValue( 0, _intStream ) )
>>> {
>>> for( unsigned long i = 0; i < _intStream.size(); i++ )
>>> {
>>> _intStream[i] *= _gain;
>>> }
>>> outputs.SetValue( 0, _intStream );
>>> }
>>>
>>> }
>>>
>>> The GetValue() and SetValue() methods simply return false if the type
>>> you're trying to get/set is mismatched. We use this in order to determine
>>> what data we have received.
>> Couldn't this signal (if it is a single one) be split on two signals towards two specific components?
>> Or, couldn't a signal with type boost::variant<std::vector<char>, std::vector<int>> be used instead?
> Yes and yes :) But the option you choose depends on the application. It could get overly complicated if say, an mp3 decoder component has 20 output ports per sample type, or say a variant that extends across a whole line. Having options means flexibility. And you know how I feel about that :D
>
I was just trying to see if the dynamic is a "must have" or a "nice to
have". From your answer I would say it is not a must have feature, and
typing the signals will give some type safety that a lot of us like.

Best,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk