parameters: ( modelName, valueName, numValues, mg )
docstring: Generates a helper make*Values function and writes it
docstring_summary: Generates a helper make*Values function and writes it
docstring_tokens: Generates a helper make * Values function and writes it
function: def writeValueMakerFunc( modelName, valueName, numValues, mg ):
      '''Generates a helper make*Values function and writes it'''
  
      vals = 'vals'
      if numValues == 0:
          vals = ''
      
      if 'VarValues' in valueName:
          paramType = 'Models::VarInit'
      elif 'WUVarReference' in valueName:
          paramType = 'Models::WUVarReference'
      # **YUCK** note this has to be tested AFTER WUVarReference because this is a substring
      elif 'VarReference' in valueName:
          paramType = 'Models::VarReference'
      else:
          paramType = 'double'
      mg.write( 'static {0}::{1}::{2}* make{2}( const std::vector<{3}> & {4} )'.format(
          mg.name,
          modelName,
          valueName,
          paramType,
          vals
          ) )
      with CppBlockScope( mg ):
          if numValues != 0:
              mg.write( paramType + ' ' + ', '.join( ['v{0} = vals[{0}]'.format( i )
                                            for i in range(numValues)] ) + ';\n' )
          mg.write( 'return new {}::{}({});\n'.format(
              mg.name + '::' + modelName,
              valueName,
              ', '.join( [('v' + str( i )) for i in range(numValues)] ) ) )
function_tokens: def writeValueMakerFunc ( modelName , valueName , numValues , mg ) : vals = 'vals' if numValues == 0 : vals = '' if 'VarValues' in valueName : paramType = 'Models::VarInit' elif 'WUVarReference' in valueName : paramType = 'Models::WUVarReference' # **YUCK** note this has to be tested AFTER WUVarReference because this is a substring elif 'VarReference' in valueName : paramType = 'Models::VarReference' else : paramType = 'double' mg . write ( 'static {0}::{1}::{2}* make{2}( const std::vector<{3}> & {4} )' . format ( mg . name , modelName , valueName , paramType , vals ) ) with CppBlockScope ( mg ) : if numValues != 0 : mg . write ( paramType + ' ' + ', ' . join ( [ 'v{0} = vals[{0}]' . format ( i ) for i in range ( numValues ) ] ) + ';\n' ) mg . write ( 'return new {}::{}({});\n' . format ( mg . name + '::' + modelName , valueName , ', ' . join ( [ ( 'v' + str ( i ) ) for i in range ( numValues ) ] ) ) )