bool NodeEventCoordinator::Configure(const Configuration* inputJson) { JsonConfigurable::_useDefaults = InterventionFactory::useDefaults; initializeInterventionConfig( inputJson ); bool configured = JsonConfigurable::Configure( inputJson ); JsonConfigurable::_useDefaults = false; return configured; }
bool StandardInterventionDistributionEventCoordinator::Configure( const Configuration * inputJson ) { initializeInterventionConfig( inputJson ); //initConfigTypeMap("Number_Distributions", &num_distributions, Number_Distributions_DESC_TEXT, -1, 1e6, -1 ); // by convention, -1 means no limit initConfigTypeMap("Number_Repetitions", &num_repetitions, Number_Repetitions_DESC_TEXT, -1, 1000, -1 ); //if( num_repetitions > 1 ) // -1 = repeat without end, 0 is meaningless. want to think this one through more { initConfigTypeMap("Timesteps_Between_Repetitions", &tsteps_between_reps, Timesteps_Between_Repetitions_DESC_TEXT, -1, 10000 /*undefined*/, -1 /*off*/, "Number_Repetitions", "<>0" ); } //initConfigTypeMap("Include_Departures", &include_emigrants, Include_Departures_DESC_TEXT, false ); //initConfigTypeMap("Include_Arrivals", &include_immigrants, Include_Arrivals_DESC_TEXT, false ); demographic_restrictions.ConfigureRestrictions( this, inputJson ); bool retValue = JsonConfigurable::Configure( inputJson ); if( retValue && !JsonConfigurable::_dryrun) { demographic_restrictions.CheckConfiguration(); validateInterventionConfig( intervention_config._json ); if( HasNodeLevelIntervention() ) { // --------------------------------------------------------------------------- // --- If the user is attempting to define demographic restrictions when they // --- are using a node level intervention, then we need to error because these // --- restrictions are not doing anything. // --------------------------------------------------------------------------- if( !demographic_restrictions.HasDefaultRestrictions() ) { std::ostringstream msg ; msg << "In StandardInterventionDistributionEventCoordinator, demographic restrictions such as 'Demographic_Coverage'\n"; msg << "and 'Target_Gender' do not apply when distributing node level interventions such as "; msg << std::string( json::QuickInterpreter(intervention_config._json)["class"].As<json::String>() ); msg << ".\nThe node level intervention must handle the demographic restrictions."; throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, msg.str().c_str() ); } } } return retValue; }