Skip to content

Commit

Permalink
libdoomsday: Added forAll iteration for GameProfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 9, 2016
1 parent 44051d3 commit 7b17e10
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doomsday/apps/libdoomsday/include/doomsday/gameprofiles.h
Expand Up @@ -63,11 +63,15 @@ class LIBDOOMSDAY_PUBLIC GameProfiles : public de::Profiles
*/
void setGames(Games &games);

de::LoopResult forAll(std::function<de::LoopResult (Profile &)> func);

protected:
AbstractProfile *profileFromInfoBlock(de::Info::BlockElement const &block);

private:
DENG2_PRIVATE(d)
};

typedef GameProfiles::Profile GameProfile;

#endif // LIBDOOMSDAY_GAMEPROFILES_H
1 change: 1 addition & 0 deletions doomsday/apps/libdoomsday/src/game.cpp
Expand Up @@ -87,6 +87,7 @@ DENG2_PIMPL(Game)
{
return profile->packages();
}
return StringList();
}
};

Expand Down
12 changes: 12 additions & 0 deletions doomsday/apps/libdoomsday/src/gameprofiles.cpp
Expand Up @@ -61,6 +61,18 @@ void GameProfiles::setGames(Games &games)
games.audienceForAddition() += d;
}

LoopResult GameProfiles::forAll(std::function<LoopResult (Profile &)> func)
{
return Profiles::forAll([&func] (AbstractProfile &prof) -> LoopResult
{
if(auto result = func(prof.as<Profile>()))
{
return result;
}
return LoopContinue;
});
}

Profiles::AbstractProfile *GameProfiles::profileFromInfoBlock(Info::BlockElement const &block)
{
std::unique_ptr<Profile> prof(new Profile);
Expand Down

0 comments on commit 7b17e10

Please sign in to comment.