Skip to content

Commit

Permalink
Check objects inside 'generic_factory' using 'T::check()' function
Browse files Browse the repository at this point in the history
  • Loading branch information
codemime committed Apr 25, 2016
1 parent 4b5c062 commit 2ae3eff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/generic_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ can be by it to implement its interface.
- a `was_loaded` member of type `bool`, which must have the value `false` before
the first call to `load`.
The type can also have:
- a 'check()' function (to run `generic_factory::check()` on all objects)
Those things must be visible from the factory, you may have to add this class as
friend if necessary.
Expand Down Expand Up @@ -254,6 +257,14 @@ class generic_factory
map[result.id] = cid;
return result;
}
/**
* Checks loaded/inserted objects for consistency
*/
void check() const {
for( const T &obj : list ) {
obj.check();
}
}
/**
* Returns the number of loaded objects.
*/
Expand Down
4 changes: 1 addition & 3 deletions src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,5 @@ void check_furniture_and_terrain()
debugmsg( "invalid furniture %s for closing %s", f.close.c_str(), f.id.c_str() );
}
}
for( const ter_t& t : terrain_data.get_all() ) {
t.check();
}
terrain_data.check();
}

0 comments on commit 2ae3eff

Please sign in to comment.