// **************************************************************************
// Function:   Add
// Purpose:    adds a new parameter to the list of parameters
//             if a parameter with the same name already exists,
//             it updates the currently stored parameter with the provided values
// Parameters: inParam       - reference to a Param object representing the
//                             parameter,
//             inSortingHint - float value used as an additional sorting
//                             criterion.
// Returns:    N/A
// **************************************************************************
void
ParamList::Add( const Param& inParam, float inSortingHint )
{
  ByName( inParam.Name() );
  ParamEntry& entry = mParams[inParam.Name()];
  entry.Param = inParam;
  entry.SortingHint = inSortingHint;
}
// **************************************************************************
// Function:   Add
// Purpose:    adds a new parameter to the list of parameters
//             if a parameter with the same name already exists,
//             it updates the currently stored parameter with the provided values
// Parameters: inLine - ASCII string, as defined in project description,
//                           defining this parameter
// Returns:    true if inLine is a correct parameter line, false otherwise
// **************************************************************************
bool
ParamList::Add( const string& inLine )
{
  istringstream linestream( inLine );
  Param param;
  if( linestream >> param )
    ByName( param.Name() ) = param;
  return linestream;
}
// **************************************************************************
// Function:   ReadFromStream
// Purpose:    Member function for formatted stream input of the entire
//             parameter list. The list is cleared before reading.
//             For partial input, use another instance of type ParamList
//             to hold the desired subset as in ParamList::LoadParameterList().
//             All formatted input functions are, for consistency's sake,
//             supposed to use this function.
// Parameters: Input stream to read from.
// Returns:    Input stream.
// **************************************************************************
istream&
ParamList::ReadFromStream( istream& is )
{
  Clear();
  Param param;
  is >> ws;
  while( !is.eof() && is >> param >> ws )
    ByName( param.Name() ) = param;
  return is;
}
示例#4
0
bool
CoreModule::HandleParam( istream& is )
{
  if( mpStatevector && mpStatevector->StateValue( "Running" ) )
    BCIERR << "Unexpected Param message" << endl;

  Param p;
  if( p.ReadBinary( is ) )
    mParamlist[ p.Name() ] = p;
  return is;
}
bool
CoreModule::HandleParam( istream& is )
{
  if( mRunning )
    bcierr << "Unexpected Param message" << endl;

  ParamList& list = mReceivingNextModuleInfo ? mNextModuleInfo : mParamlist;
  Param p;
  if( p.ReadBinary( is ) )
    list[p.Name()] = p;
  return is ? true : false;
}
string
EnvironmentBase::DescribeValue( const Param& inParam, size_t inIdx1, size_t inIdx2 )
{
  ostringstream oss;
  oss << "Parameter \""
      << inParam.Section() << "->" << inParam.Name()
      << "\": Value";

  if( string( inParam.Type() ).find( "matrix" ) != string::npos )
    oss << " at index (" << inIdx1 + 1 << ", " << inIdx2 + 1 << ")";
  else if( string( inParam.Type() ).find( "list" ) != string::npos )
    oss << " at index " << inIdx1 + 1;

  return oss.str();
}