[IGSTK-Developers] Re: adding a method into state machine

David Gobbi dgobbi at atamai.com
Mon Sep 19 15:10:45 EDT 2005


Hi Hee-Su,

I think it is a good idea to have a map to translate a return value
into a state machine input.

I'm not sure if we need a new state machine method, though,
since the following code is already elegant and easy to understand:

m_StateMachine.PushInput( myIntToInputMap[myIntValue] );

The main reason I think that the above code is better, is that
in the case of Read and Write we know that only three return
values are possible, so there is no need for a "default" input.

- David


Hee-su Kim wrote:

>Hi, guys,
>
>I'm trying to modify SerialCommunication::Write & Read to return values as David suggested.
>
>Write & Read methods return values such as SUCCESS, FAILURE, TIMEOUT.
>
>Because there are 3 result values, it can't be handled with PushInputBoolean().
>
>So, I'm considering to add the following method. 
>
>It maps an integer value to an Input.
>
>How do you think about this?
>
>
>template<class TClass>
>void
>StateMachine< TClass >
>::PushInputMap( int condition, const map<int, const InputType> &conditionInputMap,
>                    const InputType & inputDefault )
>{
>  const InputType *input = & inputDefault;
>
>  if ( conditionInputMap.find(condition) != conditionInputMap.end() )
>    {
>    input = & conditionInputMap[condition];
>    }
>
>  m_QueuedInputs.push( input->GetIdentifier() );
>}
>
>Hee-Su
>
>  
>




More information about the IGSTK-Developers mailing list