@@ -204,7 +204,7 @@ void Community::InitializeFromFile(std::istream &p_infile)
204204 std::vector<std::string> explicit_species_decl_names; // names from "species <name> initialize()" declarations
205205 int implied_species_decl_count = 0 ; // number of "initialize()" seen without "species <name>"
206206
207- for (EidosASTNode *script_block_node : root_node->children_ )
207+ for (const EidosASTNode *script_block_node : root_node->children_ )
208208 {
209209 if (script_block_node->token_ ->token_type_ == EidosTokenType::kTokenIdentifier )
210210 {
@@ -326,7 +326,7 @@ void Community::InitializeFromFile(std::istream &p_infile)
326326 bool last_spec_is_ticks_all = false ; // "ticks all" is a special syntax; there is no species named "all" so it must be tracked with a separate flag
327327 bool last_spec_is_species_all = false ; // "species all" is a special syntax; there is no species named "all" so it must be tracked with a separate flag
328328
329- for (EidosASTNode *script_block_node : root_node->children_ )
329+ for (const EidosASTNode *script_block_node : root_node->children_ )
330330 {
331331 if ((script_block_node->token_ ->token_type_ == EidosTokenType::kTokenIdentifier ) && (script_block_node->children_ .size () == 1 ))
332332 {
@@ -493,7 +493,7 @@ void Community::ValidateScriptBlockCaches(void)
493493
494494#if DEBUG_BLOCK_REG_DEREG
495495 std::cout << " ValidateScriptBlockCaches() recaching, AllScriptBlocks() is:" << std::endl;
496- for (SLiMEidosBlock *script_block : script_blocks)
496+ for (const SLiMEidosBlock *script_block : script_blocks)
497497 {
498498 std::cout << " " ;
499499 script_block->Print (std::cout);
@@ -547,7 +547,7 @@ void Community::ValidateScriptBlockCaches(void)
547547
548548#if DEBUG_BLOCK_REG_DEREG
549549 std::cout << " ValidateScriptBlockCaches() recached, late() events cached are:" << std::endl;
550- for (SLiMEidosBlock *script_block : cached_late_events_)
550+ for (const SLiMEidosBlock *script_block : cached_late_events_)
551551 {
552552 std::cout << " " ;
553553 script_block->Print (std::cout);
@@ -1095,7 +1095,7 @@ void Community::AddScriptBlock(SLiMEidosBlock *p_script_block, EidosInterpreter
10951095
10961096#if DEBUG_BLOCK_REG_DEREG
10971097 std::cout << " Tick " << tick_ << " : AddScriptBlock() just added a block, script_blocks_ is:" << std::endl;
1098- for (SLiMEidosBlock *script_block : script_blocks_)
1098+ for (const SLiMEidosBlock *script_block : script_blocks_)
10991099 {
11001100 std::cout << " " ;
11011101 script_block->Print (std::cout);
@@ -1124,7 +1124,7 @@ void Community::DeregisterScheduledScriptBlocks(void)
11241124 if (scheduled_deregistrations_.size ())
11251125 {
11261126 std::cout << " Tick " << tick_ << " : DeregisterScheduledScriptBlocks() planning to remove:" << std::endl;
1127- for (SLiMEidosBlock *script_block : scheduled_deregistrations_)
1127+ for (const SLiMEidosBlock *script_block : scheduled_deregistrations_)
11281128 {
11291129 std::cout << " " ;
11301130 script_block->Print (std::cout);
@@ -1167,7 +1167,7 @@ void Community::DeregisterScheduledScriptBlocks(void)
11671167 if (scheduled_deregistrations_.size ())
11681168 {
11691169 std::cout << " Tick " << tick_ << " : DeregisterScheduledScriptBlocks() after removal:" << std::endl;
1170- for (SLiMEidosBlock *script_block : script_blocks_)
1170+ for (const SLiMEidosBlock *script_block : script_blocks_)
11711171 {
11721172 std::cout << " " ;
11731173 script_block->Print (std::cout);
@@ -1186,7 +1186,7 @@ void Community::DeregisterScheduledInteractionBlocks(void)
11861186 if (scheduled_interaction_deregs_.size ())
11871187 {
11881188 std::cout << " Tick " << tick_ << " : DeregisterScheduledInteractionBlocks() planning to remove:" << std::endl;
1189- for (SLiMEidosBlock *script_block : scheduled_interaction_deregs_)
1189+ for (const SLiMEidosBlock *script_block : scheduled_interaction_deregs_)
11901190 {
11911191 std::cout << " " ;
11921192 script_block->Print (std::cout);
@@ -1229,7 +1229,7 @@ void Community::DeregisterScheduledInteractionBlocks(void)
12291229 if (scheduled_interaction_deregs_.size ())
12301230 {
12311231 std::cout << " Tick " << tick_ << " : DeregisterScheduledInteractionBlocks() after removal:" << std::endl;
1232- for (SLiMEidosBlock *script_block : script_blocks_)
1232+ for (const SLiMEidosBlock *script_block : script_blocks_)
12331233 {
12341234 std::cout << " " ;
12351235 script_block->Print (std::cout);
@@ -1269,12 +1269,12 @@ bool Community::SubpopulationIDInUse(slim_objectid_t p_subpop_id)
12691269 // been used, or is reserved for use in some way by, by any SLiM species or by any tree sequence.
12701270
12711271 // First check our own data structures; we now do not allow reuse of subpop ids, even disjoint in time
1272- for (Species *species : all_species_)
1272+ for (const Species *species : all_species_)
12731273 if (species->used_subpop_ids_ .find (p_subpop_id) != species->used_subpop_ids_ .end ())
12741274 return true ;
12751275
12761276 // Then have each species check for a conflict with its tree-sequence population table
1277- for (Species *species : all_species_)
1277+ for (const Species *species : all_species_)
12781278 if (species->_SubpopulationIDInUse (p_subpop_id))
12791279 return true ;
12801280
@@ -1287,7 +1287,7 @@ bool Community::SubpopulationNameInUse(const std::string &p_subpop_name)
12871287 // been used, or is reserved for use in some way by, by any SLiM species or by any tree sequence.
12881288
12891289 // First check our own data structures; we now do not allow reuse of subpop names, even disjoint in time
1290- for (Species *species : all_species_)
1290+ for (const Species *species : all_species_)
12911291 if (species->used_subpop_names_ .count (p_subpop_name))
12921292 return true ;
12931293
@@ -1298,7 +1298,7 @@ bool Community::SubpopulationNameInUse(const std::string &p_subpop_name)
12981298
12991299Subpopulation *Community::SubpopulationWithID (slim_objectid_t p_subpop_id)
13001300{
1301- for (Species *species : all_species_)
1301+ for (const Species *species : all_species_)
13021302 {
13031303 Subpopulation *found_subpop = species->SubpopulationWithID (p_subpop_id);
13041304
@@ -1311,7 +1311,7 @@ Subpopulation *Community::SubpopulationWithID(slim_objectid_t p_subpop_id)
13111311
13121312Subpopulation *Community::SubpopulationWithName (const std::string &p_subpop_name)
13131313{
1314- for (Species *species : all_species_)
1314+ for (const Species *species : all_species_)
13151315 {
13161316 Subpopulation *found_subpop = species->SubpopulationWithName (p_subpop_name);
13171317
@@ -1324,7 +1324,7 @@ Subpopulation *Community::SubpopulationWithName(const std::string &p_subpop_name
13241324
13251325MutationType *Community::MutationTypeWithID (slim_objectid_t p_muttype_id)
13261326{
1327- for (Species *species : all_species_)
1327+ for (const Species *species : all_species_)
13281328 {
13291329 MutationType *found_muttype = species->MutationTypeWithID (p_muttype_id);
13301330
@@ -1337,7 +1337,7 @@ MutationType *Community::MutationTypeWithID(slim_objectid_t p_muttype_id)
13371337
13381338GenomicElementType *Community::GenomicElementTypeWithID (slim_objectid_t p_getype_id)
13391339{
1340- for (Species *species : all_species_)
1340+ for (const Species *species : all_species_)
13411341 {
13421342 GenomicElementType *found_getype = species->GenomicElementTypeWithID (p_getype_id);
13431343
@@ -2043,7 +2043,7 @@ void Community::FlagUnevaluatedScriptBlockTickRanges()
20432043
20442044 std::vector<SLiMEidosBlock*> &script_blocks = AllScriptBlocks ();
20452045
2046- for (SLiMEidosBlock *script_block : script_blocks)
2046+ for (const SLiMEidosBlock *script_block : script_blocks)
20472047 {
20482048 if ((script_block->type_ != SLiMEidosBlockType::SLiMEidosInitializeCallback) &&
20492049 !script_block->tick_range_evaluated_ )
@@ -2063,7 +2063,7 @@ slim_tick_t Community::FirstTick(void)
20632063
20642064 // Figure out our first tick; it is the earliest tick in which an Eidos event is set up to run,
20652065 // since an Eidos event that adds a subpopulation is necessary to get things started
2066- for (SLiMEidosBlock *script_block : script_blocks)
2066+ for (const SLiMEidosBlock *script_block : script_blocks)
20672067 {
20682068 if ((script_block->type_ == SLiMEidosBlockType::SLiMEidosEventFirst) ||
20692069 (script_block->type_ == SLiMEidosBlockType::SLiMEidosEventEarly) ||
@@ -2105,7 +2105,7 @@ slim_tick_t Community::EstimatedLastTick(void)
21052105 // The estimate is derived from the last tick in which an Eidos block is registered.
21062106 // Any block type works, since the simulation could plausibly be stopped within a callback.
21072107 // However, blocks that do not specify an end tick don't count.
2108- for (SLiMEidosBlock *script_block : script_blocks)
2108+ for (const SLiMEidosBlock *script_block : script_blocks)
21092109 {
21102110 if (script_block->tick_range_is_sequence_ )
21112111 {
@@ -2235,7 +2235,7 @@ bool Community::_RunOneTick(void)
22352235 gSLiMScheduling << " # tick " << tick_ << " : " ;
22362236 bool first_species = true ;
22372237
2238- for (Species *species : all_species_)
2238+ for (const Species *species : all_species_)
22392239 {
22402240 if (!first_species)
22412241 gSLiMScheduling << " , " ;
@@ -2360,7 +2360,7 @@ void Community::AllSpecies_RunInitializeCallbacks(void)
23602360 DeregisterScheduledScriptBlocks ();
23612361
23622362 // compile results from initialization into our overall state
2363- for (Species *species : all_species_)
2363+ for (const Species *species : all_species_)
23642364 {
23652365 const std::map<slim_objectid_t ,MutationType*> &muttypes = species->MutationTypes ();
23662366 const std::map<slim_objectid_t ,GenomicElementType*> &getypes = species->GenomicElementTypes ();
@@ -2548,15 +2548,15 @@ void Community::AllSpecies_CheckIntegrity(void)
25482548{
25492549#if DEBUG
25502550 // Check the integrity of all the information in the individuals and haplosomes of the parental population
2551- for (Species *species : all_species_)
2551+ for (const Species *species : all_species_)
25522552 species->Species_CheckIntegrity ();
25532553#endif
25542554
25552555#if DEBUG
25562556 // Check for species consistency across all of the objects in each species
25572557 for (size_t species_index = 0 ; species_index < all_species_.size (); ++species_index)
25582558 {
2559- Species *species = all_species_[species_index];
2559+ const Species *species = all_species_[species_index];
25602560
25612561 if (&species->community_ != this )
25622562 EIDOS_TERMINATION << " ERROR (Community::AllSpecies_CheckIntegrity): (internal error) species->community_ mismatch." << EidosTerminate ();
@@ -2567,7 +2567,7 @@ void Community::AllSpecies_CheckIntegrity(void)
25672567 if (species->species_id_ != (int )species_index)
25682568 EIDOS_TERMINATION << " ERROR (Community::AllSpecies_CheckIntegrity): (internal error) species->species_id_ mismatch." << EidosTerminate ();
25692569
2570- for (Chromosome *chromosome : species->Chromosomes ())
2570+ for (const Chromosome *chromosome : species->Chromosomes ())
25712571 {
25722572 if (&chromosome->species_ != species)
25732573 EIDOS_TERMINATION << " ERROR (Community::AllSpecies_CheckIntegrity): (internal error) chromosome->species_ mismatch." << EidosTerminate ();
@@ -2576,7 +2576,7 @@ void Community::AllSpecies_CheckIntegrity(void)
25762576 EIDOS_TERMINATION << " ERROR (Community::AllSpecies_CheckIntegrity): (internal error) chromosome->community_ mismatch." << EidosTerminate ();
25772577 }
25782578
2579- Population &population = species->population_ ;
2579+ const Population &population = species->population_ ;
25802580 const std::map<slim_objectid_t ,MutationType*> &muttypes = species->MutationTypes ();
25812581 const std::map<slim_objectid_t ,GenomicElementType*> &getypes = species->GenomicElementTypes ();
25822582
@@ -2604,9 +2604,9 @@ void Community::AllSpecies_CheckIntegrity(void)
26042604 return ;
26052605#endif
26062606
2607- for (Species *species : all_species_)
2607+ for (const Species *species : all_species_)
26082608 {
2609- for (Chromosome *chromosome : species->Chromosomes ())
2609+ for (const Chromosome *chromosome : species->Chromosomes ())
26102610 {
26112611 // Check the integrity of the mutation registry; all MutationIndex values should be in range
26122612 int registry_size;
@@ -2945,7 +2945,7 @@ bool Community::_RunOneTickWF(void)
29452945#if DEBUG
29462946 // now that fitness calculations are done, do a crosscheck of all trait values
29472947 // this is disabled by a global flag while we are running some self-tests
2948- for (Species *species : all_species_)
2948+ for (const Species *species : all_species_)
29492949 species->CrosscheckAllTraitValues ();
29502950#endif
29512951
@@ -3255,7 +3255,7 @@ bool Community::_RunOneTickNonWF(void)
32553255
32563256#if DEBUG
32573257 // now that fitness calculations are done, do a crosscheck of all trait values
3258- for (Species *species : all_species_)
3258+ for (const Species *species : all_species_)
32593259 species->CrosscheckAllTraitValues ();
32603260#endif
32613261
@@ -3502,7 +3502,7 @@ void Community::TabulateSLiMMemoryUsage_Community(SLiMMemoryUsage_Community *p_u
35023502 p_usage->mutationPerTraitBuffer = 0.0 ;
35033503 p_usage->mutationUnusedPoolSpace = 0.0 ;
35043504
3505- for (Species *species : all_species_)
3505+ for (const Species *species : all_species_)
35063506 {
35073507 if (species->HasGenetics ())
35083508 {
0 commit comments