From 15b511e694f976686fdec1fb9f959f8a92f3b594 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 23 Feb 2019 12:02:00 -0500 Subject: More ranges stuff! Now with custom views --- src/views.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/views.h (limited to 'src/views.h') diff --git a/src/views.h b/src/views.h new file mode 100644 index 0000000..69bd2b5 --- /dev/null +++ b/src/views.h @@ -0,0 +1,62 @@ +#ifndef VIEWS_H_98651096 +#define VIEWS_H_98651096 + +#include "entity.h" +#include + +namespace views { + + inline auto isMoving() + { + return ranges::view::filter([] (const Entity& entity) { + return entity.moving; + }); + } + + inline auto isNotMoving() + { + return ranges::view::filter([] (const Entity& entity) { + return !entity.moving; + }); + } + + inline auto isControllable() + { + return ranges::view::filter([] (const Entity& entity) { + return entity.controllable; + }); + } + + inline auto isTrack() + { + return ranges::view::filter([] (const Entity& entity) { + return entity.isTrack; + }); + } + + inline auto isScheduled() + { + return ranges::view::filter([] (const Entity& entity) { + return entity.scheduled; + }); + } + + inline auto isOnLayer(Layer layer) + { + return ranges::view::filter([layer] (const Entity& entity) { + return entity.layer == layer; + }); + } + + inline auto canBePushedBy(ColliderType ctype) + { + return ranges::view::filter([ctype] (const Entity& entity) { + return entity.canBePushedBy.count(ctype); + }); + } + + + +} + +#endif /* end of include guard: VIEWS_H_98651096 */ -- cgit 1.4.1