// ************************************************************************** // Function: LoadParameterList // Purpose: Loads the current list of parameters from a parameter file // It does NOT load system critical dynamic parameters (e.g., ports, // IP addresses) // Parameters: char *filename - filename of the parameterlist // nonexisting - if true, load parameters, even if they currently do // not exist in the list // Returns: true - successful // false - error // ************************************************************************** bool ParamList::Load( const string& inFileName, bool inImportNonexisting ) { ifstream file( inFileName.c_str() ); ParamList paramsFromFile; file >> paramsFromFile; if( file.fail() ) return false; // If desired, exclude parameters missing from the main parameter list. typedef set<string> NameSet; NameSet unwantedParams; if( !inImportNonexisting ) for( int i = 0; i < paramsFromFile.Size(); ++i ) if( !Exists( paramsFromFile[i].Name() ) ) unwantedParams.insert( paramsFromFile[i].Name() ); for( NameSet::const_iterator i = unwantedParams.begin(); i != unwantedParams.end(); ++i ) paramsFromFile.Delete( *i ); for( int i = 0; i < paramsFromFile.Size(); ++i ) { Param &p = paramsFromFile[i], &q = ByName( p.Name() ); if( !q.Readonly() ) q.AssignValues( p, true ); } return true; }
void CoreModule::AutoConfigFilters() { for( int i = 0; i < mParamlist.Size(); ++i ) mParamlist[i].Unchanged(); ParamList restoreParams; if( !mAutoConfig ) { restoreParams = mParamlist; if( restoreParams.Exists( "SubjectRun" ) ) restoreParams.Delete( "SubjectRun" ); // special case for backward compatibility reasons } EnvironmentBase::EnterPreflightPhase( &mParamlist, &mStatelist, &mStatevector ); SignalProperties Output( 0, 0 ); GenericFilter::PreflightFilters( mInputSignal.Properties(), Output ); EnvironmentBase::EnterNonaccessPhase(); mOutputSignal = GenericSignal( Output ); ModuleConnection& conn = IsLastModule() ? mOperator : mNextModule; if( conn.IsLocal() && conn.Protocol().Provides( ProtocolVersion::SharedSignalStorage ) ) mOutputSignal.ShareAcrossModules(); for( int i = 0; i < restoreParams.Size(); ++i ) { const Param& r = restoreParams[i]; Param& p = mParamlist[r.Name()]; if( p.Changed() ) { p = r; p.Unchanged(); } } if( mParamlist.Exists( "DebugLevel" ) && ::atoi( mParamlist["DebugLevel"].Value().c_str() ) ) { for( int i = 0; i < mParamlist.Size(); ++i ) if( mParamlist[i].Changed() ) bciout << "AutoConfig: " << mParamlist[i]; } if( mAutoConfig && bcierr__.Empty() ) { BroadcastParameterChanges(); if( !mOperator.Send( Output ) ) bcierr << "Could not send output properties to Operator module" << endl; } }
// ************************************************************************** // Function: LoadParameterList // Purpose: Loads the current list of parameters from a parameter file // It does NOT load system critical dynamic parameters (e.g., ports, // IP addresses) // Parameters: char *filename - filename of the parameterlist // nonexisting - if true, load parameters, even if they currently do // not exist in the list // Returns: true - successful // false - error // ************************************************************************** bool ParamList::Load( const string& inFileName, bool inImportNonexisting ) { ifstream file( inFileName.c_str() ); ParamList paramsFromFile; file >> paramsFromFile; if( file.fail() ) return false; typedef set<string> NameSet; NameSet unwantedParams; // Exclude parameters from unwanted sections. const char* unwantedSections[] = { "System", }; for( size_t j = 0; j < sizeof( unwantedSections ) / sizeof( *unwantedSections ); ++j ) for( ParamContainer::const_iterator i = paramsFromFile.mParams.begin(); i != paramsFromFile.mParams.end(); ++i ) if( Param::strciequal( i->Param.Section(), unwantedSections[ j ] ) ) unwantedParams.insert( i->Param.mName ); // If desired, exclude parameters missing from the main parameter list. if( !inImportNonexisting ) for( ParamContainer::const_iterator i = paramsFromFile.mParams.begin(); i != paramsFromFile.mParams.end(); ++i ) if( mNameIndex.find( i->Param.mName ) == mNameIndex.end() ) unwantedParams.insert( i->Param.mName ); for( NameSet::const_iterator i = unwantedParams.begin(); i != unwantedParams.end(); ++i ) paramsFromFile.Delete( *i ); for( ParamContainer::const_iterator i = paramsFromFile.mParams.begin(); i != paramsFromFile.mParams.end(); ++i ) ( *this )[ i->Param.mName ].AssignValues( i->Param ); return true; }